[rabbitmq-discuss] Receiving Undelivered Persistent Messages
Vidit Drolia
viditdrolia at gmail.com
Mon Aug 10 03:16:55 BST 2009
On Sun, Aug 9, 2009 at 7:02 PM, Matthias Radestock<matthias at lshift.net> wrote:
> Vidit,
>
> Vidit Drolia wrote:
>>
>> I am using a durable exchange, durable queue and persistent delivery
>> mode for messages. This makes sure that the messages I receive are
>> persisted till they have been consumed.
>
> More precisely, this makes sure messages are persisted until a consumer has
> *acknowledged* them.
>
>> The consumer is receiving messages by subscription. However, if the
>> consumer dies, the next time it runs again it receives only one
>> message. I believe this is by design of receiving messages by
>> subscription.
>
> Err, no. When a consumer's channel or connection are closed then all
> unacknowledged messages become available for consumption by other (or
> subsequent) consumers.
>
> Is that not what you are seeing?
>
When a consumer's channel is closed, then all unacknowledged messages
are still available in the queue for subsequent consumers. If there
are N messages in the queue when the last consumer died, then when a
new consumer fires up, 1 message is delivered when the consumer
requests for a message by subscription. That is to say, executing:
while(true){
delivery = consumer.nextDelivery();
//do something...
//acknowledge for delivery
}
will deliver 1 message leaving N-1 messages in the queue. However,
after one execution of the above loop, the consumer keeps waiting for
the next delivery, even though there are N-1 messages in the queue. My
question was, is this supposed to happen by design of a subscription.
If so, then that means I need to pro-actively consume the messages
using channel.basicGet(). If not, then how can I get the exchange to
deliver all the messages available in the queue?
Regards,
--
Vidit Drolia
>
> Regards,
>
> Matthias.
>
More information about the rabbitmq-discuss
mailing list