Can I use broadway rabbitmq to consume from 2 queues with 1 connection?

Hi there!,

As far as I understand RabbitMQ — Broadway v1.0.3, consume messages from a queue "my_queue" involves a
MyBroadway module, that starts a BroadwayRabbitMQ.Producer, makes one connection, one channel to server.

If I want to consume from "another_queue", I’ll need another module, that will make it’s own connection and channel?

I though the connection, channel model of rabbitmq would rather suggest, one connection, many channel?
https://www.rabbitmq.com/channels.html#basics

Can I use broadway to have one connection, many channels?

Cheers!

I am not 100% sure. I will have to verify another time, but I believe you need to specify a second producer:

Here is the example:

      producer: [
        module: {BroadwayRabbitMQ.Producer,
          queue: "my_queue",
          qos: [
            prefetch_count: 50,
          ]
        },
        concurrency: 1
      ],

For a second producer queue, you have to do this:

      producer: [
        module: {BroadwayRabbitMQ.Producer,
          queue: "my_queue",
          qos: [
            prefetch_count: 50,
          ]
        },
        module: {BroadwayRabbitMQ.Producer,
          queue: "my_second_queue",
          qos: [
            prefetch_count: 50,
          ]
        },
        concurrency: 1
      ],

From what I see in the broadway rabbitmq library, this will create a new rabbitmq client for the second queue. It will involve another channel on RabbitMQ.

I’m pretty sure this is not possible…

1 Like