RabbitMQ
Queue Management
Message Brokering
Software Development
IT Solutions

How to pause or suspend RabbitMQ queue consumption

Codemia Knowledge Hub ·

Pausing consumption in RabbitMQ means getting the broker to stop delivering messages from a queue to its consumers for a while, for example during a burst of traffic, while a downstream system is down or under maintenance, or as part of a workflow. You can control this from the consumer side (stop acknowledging or stop consuming) or through channel QoS settings, but note that prefetch_count=0 does not pause delivery: RabbitMQ treats 0 as unlimited.

Two places to control consumption

  1. Consumer side: the client stops acknowledging or pauses its consumption. This depends on the consumer application implementing that logic.
  2. Broker side through QoS: the basic.qos method and prefetch_count limit how many unacknowledged messages RabbitMQ sends to a consumer. This is more centralized and can be tuned without much change to consumer logic.

1. Consumer pause (client controlled)

The client can stop acknowledging or stop consuming. In a typical AMQP client you defer the basic_ack call:

python
1def callback(ch, method, properties, body):
2    # Process message
3    if not ready_to_ack:
4        return
5    ch.basic_ack(delivery_tag=method.delivery_tag)

The messages stay unacknowledged while the client is not ready. The limitation is that RabbitMQ keeps sending messages unless a prefetch count is configured, because only the prefetch limit caps the number of unacknowledged deliveries.

2. Quality of Service configuration

QoS settings are applied on the channel:

python
1# Throttle: at most one unacknowledged message per consumer
2channel.basic_qos(prefetch_count=1)
3
4# Pause: cancel the consumer, then call basic_consume again to resume
5channel.basic_cancel(consumer_tag)

Do not use prefetch_count=0 for this. Per the RabbitMQ documentation, a prefetch_count of 0 is treated as infinite and allows any number of unacknowledged messages, so it removes the limit rather than stopping delivery. To throttle a consumer, set a small positive prefetch count and hold acknowledgements. To stop deliveries entirely, cancel the consumer and start consuming again when you want to resume.

What to plan for when pausing

  • Message batching: manage batch sizes to keep processing efficient and avoid message timeouts or failures.
  • Resource allocation: make sure the system is not overwhelmed when paused consumers resume.
  • Monitoring: track blocked queues and consumer status.

Practices for pause and resume

  • Graceful pause and resume: handle both actions cleanly to avoid message loss or duplication.
  • External configuration: keep prefetch values and pause durations in external configuration so they can be adjusted quickly.
  • Testing: test suspension scenarios regularly to confirm the system behaves as expected under different conditions.
FeatureDescription
Consumer-Side SuspensionConsumers temporarily stop acknowledging/messages.
Broker-Side ThrottlingRabbitMQ limits unacknowledged deliveries by prefetch_count (0 means no limit).
Impact ManagementRequired management of batch sizes and resource allocation.
Best PracticesRecommendations for implementing efficient suspension.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design