[rabbitmq-discuss] Using Subscriptions in different ways (was Re: Multiple consumers)

Tony Garnock-Jones tonyg at lshift.net
Tue Jul 28 13:46:52 BST 2009


Hi Adriana,

Adriana Rodean wrote:
> I subscribed like this but now i get the published message only when
> both subscribers are online.
> If subscribers are offline when message is published neither of them
> gets the message.
> What can i change so the subscribers get the message even if they are
> offline when message is published?

I see.

For this, you *will* need to use named queues -- you will still need one 
queue per subscriber, but instead of making them autodelete, you'll make 
them durable.

So you'll, for each subscriber,

  - decide on a queue name unique to the subscriber

  - ExchangeDeclare your exchange, as you did in your original code

  - QueueDeclare the subscriber's own queue:
        channel.QueueDeclare(queueName, true);
    The "true" parameter makes it durable (i.e. survives broker
    restarts)

  - QueueBind, as you did in your original code

  - create a Subscription on the subscriber's queue, as you did in
    your original code

Ultimately, then, the only change from your original code is that each 
subscriber should be talking to the server about their own individual 
queues.

Regards,
   Tony





More information about the rabbitmq-discuss mailing list