Video in progress
What happens when a message is redelivered in RabbitMQ, and how is that different from rewinding the offset in Kafka?
In RabbitMQ an unacked message goes back to the queue and can be sent to another consumer, while the rest of the messages keep moving. In Kafka it's not the message but the offset pointer that goes back: the partition is re-read from that point, and the following messages wait too.
📖 Answer
RabbitMQ tracks each message separately. If the consumer's channel closes or it calls basicNack(requeue=true), the message goes back to the queue with the redelivered=true flag. Meanwhile the other messages in the consumer's prefetch are being processed by other consumers, so the order easily breaks, but one bad message doesn't stop the whole queue.
In Kafka the log doesn't change. The consumer only stores a "where have I read up to" number. If it crashes, it re-reads from the last commit. One partition has one consumer, so the order is preserved, but everything behind a bad message waits.
In practice it plays out like this:
- In RabbitMQ, a message that always fails with
requeue=trueloops forever and eats CPU. You usually set up a dead-letter exchange and count the attempts (quorum queues have adelivery-limit). - In Kafka, the same situation blocks the partition, which is why you need a DLT.
- In Kafka, "skip one message and come back to it later" isn't natural; in RabbitMQ it's an ordinary thing.
- In Kafka you can re-read old messages at any time (within retention). In RabbitMQ an acked message is gone, except with Streams.
That's why RabbitMQ is often the more natural fit for a task queue, and Kafka for an event stream.
Sign up to mark studied questions and save your progress.