[rabbitmq-discuss] Help: how a publisher could know number of consumers

Marek Majkowski majek04 at gmail.com
Thu Dec 9 12:46:41 GMT 2010


Hi,

On Wed, Dec 8, 2010 at 23:48, Pascal Dergane <pascaldergane at gmail.com> wrote:
> I use rabbitmq java client 1.7 with corresponding server on linux (centOs)
> system.
> I've got a publisher that post a message to an exchange "myExchange" with
> routing Key "myRoutingKey" (direct mode).
> My system has a few consumers (say 20), each one connected to the same
> exchange "myExchange", binding with routing key "myRoutingKey", each
> consumers connected with a specific queue ("queue1" for first consumer,
> "queue2" for second, etc...).
> I expect that each consumer will process the message, and after will deliver
> a response to the publisher on the replyQueue.
> How the publisher could know that there's 20 consumers subscribing to the
> exchange when it publis the message?

You can't know that. Instead, you can:
 - get number of consumers for the queue (by doing queue.declare)
 - set a "immediate" flag on a message, to make sure it was
   delivered to at least one queue.

Cheers,
  Marek


More information about the rabbitmq-discuss mailing list