CMD Guide
HomeSystem DesignKafka

RabbitMQ vs Kafka vs ActiveMQ

These three brokers behave differently because each stores and hands out a message via a fundamentally different data structure: Kafka appends every message to an immutable, partitioned log that consumers read by advancing their own offset (the broker never deletes on read); RabbitMQ routes each message through an exchange into one or more queues and deletes it the moment a consumer acknowledges; ActiveMQ implements the JMS queue/topic model, tracking per-message delivery state in the broker. Everything else — replay, ordering, throughput, routing power — falls out of that one design choice.

The mechanism, in one picture

The core split is who owns the read cursor. In a log, the consumer owns it, so many independent readers can sit at different positions and the same bytes can be re-read forever. In a queue, the broker owns delivery state, so a message is dequeued and destroyed once acknowledged — cheap and low-latency, but gone.

diagram
diagram

One event, traced through all three

Scenario: an e-commerce site emits order.created events at ~50,000/sec. Three independent consumers need each event — fraud scoring, email confirmation, and an analytics warehouse loader that occasionally must reprocess the last day. Follow one event, {orderId: 91007, customerId: 8842, amount: 149.00}.

StepKafkaRabbitMQActiveMQ
PublishProduce to topic orders; key = customerId 8842 → hash → partition 3 of 12Publish to topic exchange orders, routing key order.created.USSend to topic ORDERS
PlacementAppended at offset 15203 of partition 3; replicated to 2 follower brokers (ISR)Bindings copy it into fraud_q and email_q; analytics has its own bound queueBroker persists to KahaDB; one copy per durable subscriber (fraud, email, analytics)
ConsumeEach consumer group reads & commits its own offset; fraud commits 15204, analytics still at offset 0Broker pushes to each queue's consumer; each acks its own copyBroker pushes to each durable subscriber; each acks
After ackMessage stays until retention (e.g. 7 days) expires — untouched by acksMessage deleted from that queue immediatelyMessage deleted for that subscriber
Reprocess last dayseek analytics group to yesterday's offset — bytes are still thereImpossible from the broker; you must re-publish from an external storeImpossible; message is gone once acked
Ordering seenAll of customer 8842's events are in partition 3, so strictly ordered for that customer; no global order across the 12 partitionsFIFO within each queueFIFO within each destination

The load-bearing difference is the last two rows: Kafka's offset-owned-by-consumer design makes replay a one-line seek; the queue brokers treated the message as work to be consumed and destroyed.

The 10-dimension comparison

DimensionKafkaRabbitMQActiveMQ
1. Core modelDistributed append-only logAMQP exchange → queueJMS queue / topic
2. ThroughputVery high — millions/sec, sequential disk + batchingTens of thousands/sec/queueTens of thousands/sec
3. OrderingPer-partition only (not across a topic)Per-queue FIFOPer-destination FIFO
4. ConsumptionPull; consumer commits offsetPush; broker deletes on ackPush; broker deletes on ack
5. Replay / re-readYes — seek to any offset within retentionNo — acked messages are goneNo — acked messages are gone
6. Routing powerBasic: topic + partition keyRich: direct / topic / fanout / headers exchanges + bindingsSelectors, virtual topics, composite destinations
7. PriorityNo built-in message priorityYes (priority queues)Yes (JMS priority)
8. Replication / HABuilt-in per-partition replication (ISR/leader)Quorum queues (Raft) / classic mirrored queuesMaster-slave (shared store / KahaDB)
9. LatencyLow-ms, but batching favours throughput over tail latencySub-ms to low-ms — tuned for low latencyLow-ms
10. LicenseApache-2.0MPL-2.0 (Mozilla)Apache-2.0

Stream processing: Apache Kafka ships Kafka Streams natively (a library bundled with the Apache Kafka distribution); ksqlDB is a separate Confluent-licensed SQL layer that runs on top of Kafka — not part of Apache Kafka; RabbitMQ added a Streams log-like type in 3.9+ (2021) but it is not a stream-processing engine; ActiveMQ has no native stream processing and leans on external libraries.

When to use which — the decision

Stop comparing feature checklists and ask one question first: is this an event stream that multiple consumers replay, or is it work handed to a consumer once? That single distinction resolves most choices.

Trade-offs you are actually accepting

Pitfalls

Takeaways


Re-authored and deepened for this guide. Sources: Apache Kafka documentation (design, replication, consumer groups); RabbitMQ documentation (AMQP model, exchanges, quorum queues, Streams 3.9+); Apache ActiveMQ / Artemis documentation (JMS, protocols); Kleppmann, Designing Data-Intensive Applications, ch. 11 (message brokers vs logs); Confluent engineering blog on log-vs-queue semantics.

When NOT to pick each broker

Interviewer follow-ups & drills

  1. Why not “exactly-once” as the selection criterion? Classic queues are at-least-once; EOS is processing design, not a broker checkbox.
  2. Ops signals: Kafka consumer lag / under-replicated partitions; Rabbit queue depth & memory alarms; DLQ growth.
  3. Drill: Email send once per order, no replay needed → queue (SQS/Rabbit) + idempotent sender, not Kafka.
🤖 Don't fully get this? Learn it with Claude

Stuck on RabbitMQ vs Kafka vs ActiveMQ? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **RabbitMQ vs Kafka vs ActiveMQ** (System Design) and want to truly understand it. Explain RabbitMQ vs Kafka vs ActiveMQ from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **RabbitMQ vs Kafka vs ActiveMQ** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **RabbitMQ vs Kafka vs ActiveMQ** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **RabbitMQ vs Kafka vs ActiveMQ** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes