[rabbitmq-discuss] Clean shutdown of a consumer with prefetch

Matthias Radestock matthias at rabbitmq.com
Mon Nov 4 12:33:48 GMT 2013


On 04/11/13 12:16, Michael Klishin wrote:
> On 4 Nov 2013, at 16:08, Adam Ainsworth <Adam.Ainsworth at TraderMedia.co.uk> wrote:
>
>> Is it possible to empty the prefetch buffer when we are closing down to avoid this?
>
> I’m afraid not. Even if cancel your consumer first, there still may be in flight messages
> that were delivered but not acked.

Ah, but you are guaranteed not to get any more messages for a consumer 
after the basic.cancel_ok.

So to get an app to shut down without marking any messages as redelivered...

1) cancel the consumer,
2) continue processing messages
3) when basic.cancel_ok arrives, terminate the connection/channel.

Now, in most AMQP APIs, 3) is the result of 1) and both happen on a 
separate thread to 2), so some extra inter-thread signalling may be 
required.

Matthias.


More information about the rabbitmq-discuss mailing list