watermill icon indicating copy to clipboard operation
watermill copied to clipboard

[watermill-amqp] Issue with exclusive or auto-delete queues after reconnection

Open reva2 opened this issue 3 years ago • 1 comments

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{},
}

reva2 avatar Dec 02 '22 13:12 reva2

I opened a duplicated PR.

shaneing avatar Nov 17 '23 02:11 shaneing