"Explain how RocketMQ ensures that no messages are lost in a distributed environment. What mechanisms are in place at the producer, broker, and consumer levels?"
RocketMQ is one of Alibaba's most critical middleware components, processing trillions of messages daily. Understanding its reliability guarantees demonstrates deep knowledge of Alibaba's infrastructure and distributed messaging concepts in general.
Cover the producer side: synchronous send with retry, transaction messages for exactly-once semantics with local transactions.
Cover the broker side: synchronous disk flush (sync flush vs async flush trade-off), master-slave replication with syncDouble-write mode.
Cover the consumer side: manual ACK after successful processing, retry queue for failed messages, dead-letter queue as final fallback.
Discuss end-to-end: message trace for full-link tracking and reconciliation mechanisms.
RocketMQ guarantees reliability at three levels. At the producer level, synchronous send mode waits for broker acknowledgment before returning success, with automatic retry on failure (default 2 retries). For scenarios requiring local-transaction-plus-message atomicity, RocketMQ's transaction message feature uses a half-message mechanism: the message is invisible to consumers until the local transaction commits, and a check-back mechanism handles ambiguous states. At the broker level, synchronous flush mode ensures messages are written to disk before acknowledging the producer, and Dledger-based replication synchronizes data across replicas before returning. At the consumer level, messages are only marked as consumed after the business logic succeeds — if processing fails, the message re-enters the retry queue with exponential backoff, and after max retries, it moves to the dead-letter queue for manual inspection. I'd also implement consumer-side idempotency using a message-ID deduplication table to handle redeliveries safely.
Distinguish between "at-least-once" and "exactly-once" delivery semantics — RocketMQ primarily guarantees at-least-once, with idempotency handling exact-once at the application level.
Know the trade-off between sync flush (safer, slower) and async flush (faster, slight risk of loss on crash).
Mention transaction messages — they are a unique and powerful feature of RocketMQ that interviewers love to discuss.
RocketMQ supports transaction messages, scheduled messages, and message filtering natively. Kafka excels in throughput for log-style streaming. RocketMQ was designed for business messaging where reliability and feature richness matter more than raw throughput.
With async flush, the message could be lost. With sync flush enabled, the broker only acknowledges after the disk write completes, so no acknowledged message is lost. This is why critical business messages use sync flush mode.
HireMe AI listens to your interview in real-time, detects questions, and generates instant answer suggestions — so you never freeze up again.
Try HireMe AI Free