wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
805 stars 129 forks source link

[v0.12.4] Declaring consumers on the same queue name but different exchanges creates bindings on the same queue #192

Open ntauth opened 15 hours ago

ntauth commented 15 hours ago

I'll make it short, I am declaring two consumers like this:

    rabbitMQSub, err := gorabbitmq.NewConsumer(
        rabbitMQConnWithAck,
        func(d gorabbitmq.Delivery) gorabbitmq.Action {
            return s.onUpdateChatMetadataTask(ctx, d)
        },
        "tx_outbox_tasks_queue",
        gorabbitmq.WithConsumerOptionsRoutingKey("tx_outbox_task"),
        gorabbitmq.WithConsumerOptionsExchangeName("chats"),
        gorabbitmq.WithConsumerOptionsConcurrency(defaultConcurrency),
        gorabbitmq.WithConsumerOptionsLogger(wrappers.NewRabbitMQLoggerWrapper(log.Tech().Sugar())),
    )
    rabbitMQSub, err := gorabbitmq.NewConsumer(
        rabbitMQConnWithAck,
        func(d gorabbitmq.Delivery) gorabbitmq.Action {
            return s.onSendExternalMessageTask(ctx, d)
        },
        "tx_outbox_tasks_queue",
        gorabbitmq.WithConsumerOptionsRoutingKey("tx_outbox_task"),
        gorabbitmq.WithConsumerOptionsExchangeName("messages"),
        gorabbitmq.WithConsumerOptionsConcurrency(defaultConcurrency),
        gorabbitmq.WithConsumerOptionsLogger(wrappers.NewRabbitMQLoggerWrapper(log.Tech().Sugar())),
    )

Ad here is what I see on the RabbitMQ management page:

image

Only one queue is declared, and the chats and messages exchanges both push to the same queue. Am I missing something?