Apache Kafka vs RabbitMQ: When You Need a Log and When You Need a Queue
An order gets paid. Analytics needs to count the sale, the warehouse needs to release the order, and the customer needs a receipt. These requirements sound like three subscribers to the same message until something breaks: analytics needs to replay a week of orders, but nobody wants to email a week’s worth of receipts again.
That’s the distinction at the heart of this post: OrderPaid is a fact that more than one service might need to read again. SendReceipt is a job that should leave the queue once it succeeds. Kafka’s event log and RabbitMQ’s work queues give those messages different lifetimes.
Apache Kafka: Keep the History
A producer appends records to a Kafka topic. The topic is split into partitions, and every record has an offset: its position within that partition. Consumers pull records and commit the position they want to resume from. Committing an offset doesn’t delete the record. A typical event topic retains records according to its configured age or size limits, independent of how many times they’re read.
Say the checkout service publishes OrderPaid to an orders topic. Analytics and fulfillment use separate consumer groups, each with its own committed offsets. If the analytics code used the wrong currency conversion for a week, you can reprocess the retained events into a separate output or rewind that group after fixing the bug. Neither action moves the fulfillment group’s offsets. If the output isn’t safe to write twice, plan the backfill before touching the production group: resetting an offset doesn’t roll back rows your old consumer wrote.
Partitions matter for two reasons:
- Ordering. Kafka orders records within a partition, not across a topic. If
OrderPaidandOrderRefundedneed to be read in order for one order, route both records to the same partition, typically by keying them byorderIdwith a consistent partitioning scheme. Your application still has to preserve that order if it processes records concurrently. - Parallelism. In a standard consumer group, one consumer at a time is assigned to a partition. With three partitions and four consumers in the same group, the fourth consumer has nothing to read. Conversely, if one partition gets most of the traffic, more consumers won’t split that partition’s work. Check lag per partition before scaling the deployment.
Kafka is where I’d start for data pipelines, change data capture, or a stream that several teams need to consume independently. Before relying on replay, decide how far back consumers must be able to go. A seven-day backfill plan doesn’t help if the required records have already aged out or been compacted away.
RabbitMQ: Route Work and Acknowledge It
In RabbitMQ, a producer publishes to an exchange, which uses bindings to route the message to one or more queues. For example, a topic exchange can match receipt.email to an email queue and receipt.* to a separate audit queue. Workers on the same queue compete for deliveries; services on different matching queues each get their own delivery. RabbitMQ can do fan-out just fine. What a work queue doesn’t give you is a way to replay messages it has already removed.
For SendReceipt, I’d start with one queue, a small worker pool, manual acknowledgements, and a prefetch limit so a worker can’t pile up more unacknowledged deliveries than it can handle. RabbitMQ normally pushes the job to a worker, and removes it from that queue after the worker acknowledges it. If you need a replicated work queue, look at quorum queues; replication doesn’t remove the need for acknowledgements and retries.
Here’s the failure I’d test before shipping: the email provider accepts the receipt, then the worker dies before sending its acknowledgement. RabbitMQ can deliver the job to another worker. From the broker’s point of view, the first delivery never finished. From the customer’s point of view, the receipt has already been sent.
Use a stable job ID across deliveries and pass it as an idempotency key if the email provider supports one. A unique row in your own database can deduplicate effects you commit there, but it can’t make an external send and a local write atomic. Kafka has the same problem if a consumer performs an external action and dies before committing its offset. Kafka transactions can cover writes to Kafka and offset commits together; they don’t make an email or HTTP call exactly-once.
Retries need their own policy. If a downstream service is returning 503, immediately requeueing a failure can send the same job around in a tight loop while good jobs wait. Give transient failures a limited number of attempts with backoff. After that, park the job in a dead-letter queue and make sure someone can find it. A malformed job usually belongs there without a round of retries.
Side by Side
| Question | Kafka standard consumer groups | RabbitMQ work queues |
|---|---|---|
| What happens after successful processing? | The group commits its position; records remain subject to topic retention and cleanup. | The consumer acknowledges the delivery; the message is removed from that queue. |
| How do two services get the same message? | They read the same topic in separate consumer groups. | The exchange routes it to a separate queue for each service. |
| Can a new consumer read yesterday’s messages? | Yes, if they’re still retained and it starts at the appropriate offset. | Not from a queue that already acknowledged and removed them. |
| How do I add worker capacity? | Scale consumers up to the available partitions in a standard group; check for skew. | Add competing consumers and tune prefetch; retries and concurrency can change completion order. |
Acknowledging a Publish Is Not Acknowledging a Job
At a checkout code review, I’d look for two different signals: did the broker accept the message, and did a worker finish the work? RabbitMQ’s publisher confirms are separate from consumer acknowledgements. A publish can even be confirmed without reaching a queue, so if a job must be routed, publish with mandatory and handle returned messages as well as confirms.
On the Kafka side, acks=all means the write has been acknowledged by the current in-sync replicas, not necessarily by every configured replica. If you’re expecting a replicated order history, check min.insync.replicas too. With three replicas and a minimum of two, writes using acks=all fail rather than accepting single-replica writes when only the leader is in sync. That’s an availability trade-off worth trying in staging instead of discovering it during a broker outage.
The Line Isn’t Absolute
Kafka 4.2 made share groups production-ready. Unlike a standard consumer group, a share group lets multiple consumers work from the same partition and acknowledge records individually. That makes Kafka worth considering for some queue-style workloads if you already run it. It doesn’t turn the topic into a delete-on-ack work queue.
RabbitMQ Streams go the other way: a stream is an append-only log with configurable retention and non-destructive reads. A reader can start from an earlier offset without changing what other readers see. If you already run RabbitMQ and need replay, evaluate Streams rather than trying to turn a traditional queue into an archive.
What I’d Ship First
If checkout only needs to send receipts asynchronously, I’d start with a RabbitMQ queue and make the worker safe to retry. If several services need the same order history at their own pace, I’d start with Kafka and decide explicitly which consumers are safe to replay. A low-volume system can still need replay, and a high-volume one can still be mostly short-lived jobs. Volume alone doesn’t decide.
Running both can make sense when the same system needs independent replay and dedicated task routing or retry policies. A bridge can read OrderPaid from Kafka and publish SendReceipt to RabbitMQ. Don’t commit the Kafka offset until the publish is confirmed and you’ve handled unroutable messages. Then test a crash after confirmation but before the offset commit: the bridge will read the event again and may publish a duplicate. Derive the job ID from the original event so the worker can recognize the second attempt.
Before adding a second broker, I’d answer two questions: What has to be replayable next week? What has to be safe to retry tonight? Then I’d test those behaviors. On the dashboard, I’d track Kafka lag and replay time, or RabbitMQ’s oldest waiting job and dead-letter count. Throughput matters, but it won’t tell you whether a customer is still waiting for a receipt.