On 20 January 2015 at 19:26:14, Peter Long (
peter...@gmail.com) wrote:
> I was wondering if there is a way to instruct the RabbitMQ server
> to temporarily pause delivery of new messages queued on a particular
> queue, allowing the queue depth to grow until instructed to let
> delivery resume. I am thinking of a scenario where some maintenance
> needs to be done downstream of the consumer(s), say the database
> used by the consumers needs to be restarted. I know that one solution
> is simply to stop the consumers. Unfortunately that would require
> some code refactoring which I would like to delay for now. At present
> my producers and consumers are running in the same process. I
> would like to keep the producers publishing to the queue, I just
> want to halt consumption.
Peter,
Simply cancel your consumer with the basic.cancel protocol method. However exactly that
is done slightly varies between clients but typically method name is basic_cancel or basicCancel
and it is a part of the channel API.
When, when you want to resume consumption, re-add your consumer, e.g. the same consumer instance
if your client is object-oriented, or begin consuming with the same function.
Note that _some_ consumers may be stateful and cannot be reused but as far as RabbitMQ is concerned,
you just cancel and register consumers. There is no pause operation.
--
MK
Staff Software Engineer, Pivotal/RabbitMQ