[rabbitmq-discuss] Multiple consumers

Matthew Sackman matthew at lshift.net
Tue Jul 28 10:17:08 BST 2009

Hi Adriana,

On Tue, Jul 28, 2009 at 09:56:03AM +0300, Adriana Rodean wrote:
> When i publish message 1 subscriber receives the message. After i
> close this subscriber the other one receives the message.
> I want both subscribers to receive the message when they are open.
> What am i doing wrong?

When you subscribe, you're not setting the subscriber to auto-ack and
you're also not acknowledging the messages. You need to do one of these.

Without either of these, Rabbit will happily deliver messages to you,
but will hang on to them (because they've not been ack'd) and then when
the connection has been closed will add the messages back into the
queue. By ack'ing the messages, you tell Rabbit that you really have
received the messages and it can forget about them. Setting the
subscription to auto-ack mode does the same thing without you having to
sent explicit acks - i.e. it will consider the message acknowledged and
forget about it as soon as it's sent it to your consumer.


More information about the rabbitmq-discuss mailing list