Why this matters
- RabbitMQ fits work queues and routing patterns Kafka does not simplify.
- Spring AMQP listeners need ack/nack discipline and poison-message handling.
- BookStore order notifications often start on Rabbit before scaling to Kafka.
Exchanges and queues
L1 · FresherProducers publish to exchanges; queues bind with routing keys — ideal for task queues and work distribution in BookStore.
@RabbitListener
L2 · IntermediateDeclare listeners with concurrency and prefetch to balance throughput and fair dispatch to consumers.
Ack modes
L3 · AdvancedManual ack after successful processing prevents message loss; auto-ack is faster but risky on failures mid-handler.
Kafka vs RabbitMQ
L4 · ExpertChoose Rabbit for competing consumers and complex routing; Kafka for high-volume event logs and replay.
Hook
BookStore notifies warehouses when stock drops below threshold. Spring AMQP connects BookStore to RabbitMQ with declarative listeners, JSON conversion, and error handlers aligned with Boot 3.5.
Dependencies and connection
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
spring:
rabbitmq:
host: rabbitmq.bookstore.internal
port: 5672
username: bookstore
password: ${RABBITMQ_PASSWORD}
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 6 sections
- Publishing from a service
- Listening with retry
- BookStore in action
- Runnable BookStore lab
- Failure modes in production
- JSON and records
Test yourself
Answer these before moving on — recall is what makes it stick.