Messaging solves a simple problem: the system that receives an order does not have to wait for the system that processes it. Doing it right takes discipline. We use RabbitMQ in 15 systems, among them messaging platforms, and the rules below come from what broke in production.
Exchange and queue design
Exchanges per domain. One topic exchange per business context, with routing keys such as order.created or sms.sent. Consumers bind by pattern and receive only what matters to them.
One queue per consumer. Each service has its own queue. If two services need the same event, each gets its own copy. Sharing a queue between different consumers causes a fight over messages.
Durable queues and persistent messages. Without them, a broker restart wipes out the work. For replicated durable queues we use quorum queues (mirroring of classic queues was removed in RabbitMQ 4.0).
Prefetch. Prefetch limits how many messages a consumer receives without acknowledging. A low value spreads load more evenly. A high value increases throughput. We tune it per task type.
End-to-end reliability
Publisher confirms. The producer only considers the message sent after the broker confirms.
Transactional outbox. The producer writes the message in the same database transaction and a separate process publishes it. This avoids the classic case: the database wrote, the publish failed and the system is inconsistent.
Manual consumer acknowledgment. The ack happens only after the work finishes. If the consumer dies midway, the message returns to the queue.
Idempotency. Since delivery is at least once, the consumer must tolerate repetition. We store the ID of the processed message or design the operation to be repeatable, such as an upsert by business key.
Retries, DLQ and poison messages
Not every failure deserves the same response.
- Transient failure (timeout, service down): immediate retry and then delayed retries with exponential backoff. In MassTransit, we configure UseMessageRetry and delayed redelivery.
- Permanent failure (malformed message, violated rule): repeating does not help. The message goes straight to the DLQ.
- Poison message: the one that crashes the consumer in a loop. The retry limit takes it out of the main queue.
The DLQ is monitored, has an alert and a reprocessing procedure. A dead-letter queue with no owner becomes a silent trash can. We usually build a simple tool to inspect, fix and republish.
MassTransit in .NET
MassTransit abstracts the broker and delivers typed consumers, filters, retries, an outbox with Entity Framework, sagas for long flows and OpenTelemetry instrumentation. We use sagas for processes such as billing and approval, where state must survive restarts. MassTransit version 9 is commercial and version 8 remains under Apache 2.0; we review the license with you before choosing. More on the technical base in .NET development.
Operations
Metrics that matter. Queue depth, age of the oldest message, inbound and outbound rate, active consumers, unacknowledged messages and DLQ size. The most useful alert is age, because it shows real delay for the user.
Flow control. Memory and disk limits, and a back-pressure policy for producers. A slow consumer must not take the broker down.
Kubernetes. The broker runs in the cluster or as a managed service, depending on the case, and consumers scale with HPA based on queue depth. See Kubernetes experts.
Contract versioning. Messages evolve with optional fields, and an old version coexists with the new one during migration.
Working with a Brazilian team
Our engineers are based in Brazil, in time zones that overlap with the US working day, and we communicate in English.
How we deliver in weeks
- Our own boilerplates. A .NET messaging library with outbox, idempotency, retries, DLQ and metrics dashboards ready.
- AI agents with senior review. Agents generate consumers, contracts and tests. A senior engineer reviews the design and every change.
- The same team from assessment to deploy. The person who analyzes the queues deploys the fix.
- Fixed scope after the assessment. The free assessment maps queues, failures and risks, and proposes a plan with a timeline in weeks.
Common mistakes we fix
A queue used as a database. Messages that sit in the queue for days mask a broken consumer. The queue should drain. If it accumulates, the age alert fires and someone investigates.
A consumer with no retry limit. A malformed message becomes an infinite loop and eats CPU. We define the maximum attempts and the final destination.
Giant messages. Carrying files inside the message weighs on the broker. We store the file in object storage and send only the reference.
Assumed ordering. RabbitMQ preserves order per queue with a single consumer, but retries and parallel consumers break it. When order matters, we partition by business key and design the consumer to tolerate out-of-order arrival.
No failure testing. We take down the consumer, the broker and the network in staging to see what happens. Only then does messaging go to production.
Broker security
Users and permissions per service, with access only to the queues and exchanges they need. TLS on connections, virtual hosts per environment and passwords in a vault. Admin console traffic restricted to the internal network. Each service sees only its own part of the messaging.
Related
See how a RabbitMQ worker processes asynchronous tasks in the Regina Festas case. We have also run messaging with RabbitMQ in production for other clients. It is part of the custom software development service. Request the free assessment.