watermill
watermill copied to clipboard
[watermill-amqp] Issue with exclusive or auto-delete queues after reconnection
Hi
It looks like current AMQP pub/sub implementation doesn't re-create queues after reconnection. It cause errors in case of "exclusive" or "auto-delete" queues in RabbitMQ:
cannot consume from channel: Exception (404) Reason: "NOT_FOUND - no queue 'macsvc_reva2.orbitsoft_5065325975852691651' in vhost '/'
Here example of configuration which cause problems:
conf := amqp.Config{
Connection: amqp.ConnectionConfig{
AmqpURI: "amqp://user:[email protected]:5672/"
},
Marshaler: amqp.DefaultMarshaler{},
Exchange: amqp.ExchangeConfig{
GenerateName: func(topic string) string {
return "test_exchange"
},
Type: "fanout",
Durable: false,
},
Queue: amqp.QueueConfig{
GenerateName: func(topic string) string {
hostname, err := os.Hostname()
if err != nil {
hostname = "unknown"
}
return "mysvc_" + hostname + "_" + strconv.Itoa(rand.Int())
},
Exclusive: true,
},
QueueBind: amqp.QueueBindConfig{
GenerateRoutingKey: func(topic string) string {
return ""
},
},
Publish: amqp.PublishConfig{
GenerateRoutingKey: func(topic string) string {
return topic
},
},
Consume: amqp.ConsumeConfig{
Qos: amqp.QosConfig{
PrefetchCount: 5,
},
},
TopologyBuilder: &amqp.DefaultTopologyBuilder{},
}
I opened a duplicated PR.