Tosh
Tosh

Reputation: 93

Rabbit MQ sending messages to two instances of the same app

RabbitMQ is sending a message to two instances of the same app, instead of one. The messages are not being published in a round robin manner. I am using the Java client. Not sure what am doing wrong.

This is how I set it up.

   Channel channel = connection.createChannel();
            channel.exchangeDeclare("exchange_name", "topic");
            channel.basicPublish("exchange_name", "binding.key",
                    MessageProperties.PERSISTENT_TEXT_PLAIN,
                    message.getBytes());
            channel.close();

Upvotes: 0

Views: 641

Answers (1)

Akash Bangera
Akash Bangera

Reputation: 36

To achieve round-robin, every producer and consumer should declare a named queue, and everyone should use the same queue name.

Messages will be published in a round-robin manner to every consumer looking at the same queue.

Upvotes: 2

Related Questions