Skip to content

RabbitMQ

Scope: designing exchanges, queues, publishers and consumers for RabbitMQ 4.x, following the current (4.4) documentation. Shared messaging rules aren't repeated here: publish events together with database changes through a transactional outbox (DATA-4, general/data.md), make operations safe to retry (API-1, general/api-design.md), buffer load with queues and retry with backoff (OPS-7, OPS-3, general/operations-reliability.md), and say which event-driven pattern you mean (STYLE-8 to STYLE-10, general/architecture-styles.md). For a log-based broker, see Apache Kafka; for secrets and least privilege, see general/security.md.

Entries are sorted by score from 1 to 10 (criteria): 9โ€“10 start here or strongly recommended, 6โ€“8 recommended, 1โ€“5 further reading or conditional.

Adopted references

  • 9 RabbitMQ documentation (RabbitMQ 4.4): the baseline. The guides on queue types, publishers, consumers, acknowledgements and confirms, dead lettering, access control, TLS and monitoring matter most for application work.
  • 8 Production Deployment Guidelines (RabbitMQ docs): the production checklist for storage, virtual hosts and users, resource limits, security, cluster size, and connection management in applications. Go through it before going live.
  • 8 Reliability Guide (RabbitMQ docs): what can fail, and how publisher confirms, acknowledgements, heartbeats, clustering and replicated queues protect messages on the publisher, broker and consumer sides.
  • 8 Consumer Acknowledgements and Publisher Confirms (RabbitMQ docs): acknowledgement modes, requeueing, prefetch and its effect on throughput, and when the broker confirms a published message.
  • 7 Quorum Queues (RabbitMQ docs): when to use replicated quorum queues and when not, how they differ from classic queues, poison message handling, delayed retry and replication.
  • 7 Streams and Superstreams (RabbitMQ docs): replicated append-only logs for large fan-outs, replay, high throughput and large backlogs, with retention and partitioned super streams.
  • 7 Monitoring (RabbitMQ docs): monitoring with Prometheus and Grafana, the key node and queue metrics, and health checks in stages.

Key rules

Queues and data safety

Consumers and failed messages

Connections and channels

Queue design

  • 7 RABBITMQ-9 Keep queues short: run enough consumers to keep up, cap queue length with a policy, and use a stream instead of a queue for large backlogs, replay or large fan-outs. Queues are optimised for being nearly empty and perform worse with millions of messages; classic queues no longer have a "lazy" mode for large backlogs. (RabbitMQ, Streams: use cases, Queue Length Limit, Quorum Queues: when not to use them, Lazy queues)
  • 7 RABBITMQ-10 Configure dead-lettering, TTLs, length limits and delivery limits through policies, not through x- arguments hard-coded in applications. Policies can be changed at any time for many queues at once, while hard-coded arguments need application changes and redeployment. The queue type is the exception: set it at declaration or through the default queue type. (RabbitMQ, Dead Letter Exchanges: configuration, Policies)

Security

Operations

How to enforce

Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.

  • 6 RabbitMQ Prometheus alerting rules (RabbitMQ Cluster Operator): ready-made Prometheus alerts, as Kubernetes PrometheusRule resources, for the metrics of the Prometheus plugin. HighConnectionChurn fires when connections are short-lived, and UnroutableMessages when messages are dropped or returned as unroutable. Partly checks RABBITMQ-4, RABBITMQ-8 and RABBITMQ-13.
  • 5 Operator policies (RabbitMQ docs): limits such as delivery-limit, max-length and overflow that operators apply to every matching queue; when an application's policy sets the same key, the more conservative value wins. Partly checks RABBITMQ-5 and RABBITMQ-9.
  • 5 rabbitmq-diagnostics check_certificate_expiration (RabbitMQ CLI): checks the expiry dates of the certificates on every TLS listener of a node, for example in a scheduled job. Partly checks RABBITMQ-12.

Tutorials and further reading