The spring-boot-starter-amqp dependency adds Spring AMQP and the RabbitMQ Java client to your project and lets Spring Boot auto-configure the connection, a RabbitTemplate for sending, an AmqpAdmin for declaring queues, and the listener infrastructure behind @RabbitListener. You add one dependency, set a few spring.rabbitmq.* properties, and you can publish and consume messages without writing connection code.
In practice it is the Spring Boot entry point for RabbitMQ. Spring AMQP itself is protocol-level (AMQP 0-9-1), so the starter targets RabbitMQ rather than any AMQP 1.0 broker.
The starter is a dependency bundle with no code of its own. It pulls in spring-boot-starter, spring-messaging, and spring-rabbit (the Spring AMQP RabbitMQ module), which in turn brings the RabbitMQ Java client. Spring Boot's RabbitAutoConfiguration activates when those classes are present.
Add it with Maven:
Or with Gradle:
Do not set a version. The Spring Boot parent POM or the dependency management plugin supplies the version that matches your Boot release.
Once the starter is on the classpath, Boot registers these beans unless you define your own:
| Bean | Purpose |
|---|---|
CachingConnectionFactory | Connection and channel caching to the broker |
RabbitTemplate | Sends messages and does request/reply |
AmqpAdmin (RabbitAdmin) | Declares queues, exchanges and bindings found in the context |
RabbitMessagingTemplate | Spring Message based wrapper around the template |
| Listener container factories | Back @RabbitListener methods |
If you define a bean of the same type, the auto-configured one backs off. This is how you swap in a custom message converter or a differently tuned template.
The defaults point at localhost:5672 with the guest user, which RabbitMQ only allows from localhost. For any real broker, configure it in application.yml:
You can also use spring.rabbitmq.addresses for a cluster, spring.rabbitmq.ssl.enabled=true for TLS, and spring.rabbitmq.template.* to tune the template. Keep the password in an environment variable or a secret store, never in the file.
The following example declares a durable queue, sends a JSON message, and consumes it. AmqpAdmin creates the queue on startup because the Queue bean is in the context.
When Boot finds a single MessageConverter bean it applies it to both the template and the listener containers, so the record travels as JSON instead of Java serialization. Sending to the default exchange with the queue name as the routing key delivers straight to that queue. For topic or fanout routing, declare an exchange and a Binding bean as well.
The starter gives you working defaults, but production use needs a few decisions.
auto acknowledges after the listener returns and rejects when it throws. Use manual only when you need to control acks yourself.default-requeue-rejected: false or throw AmqpRejectAndDontRequeueException.spring.rabbitmq.publisher-confirm-type=correlated and publisher-returns=true when you must know the broker accepted a message.spring.rabbitmq.listener.simple.concurrency and max-concurrency for parallel consumers, and tune prefetch so a slow consumer does not hoard messages.QueueBuilder.durable(name).quorum().build().Spring AMQP targets AMQP 0-9-1 and is built and tested against RabbitMQ. Other brokers that speak that protocol may work, but the auto-configuration and the properties are RabbitMQ specific. For AMQP 1.0 brokers use a different client.
Yes, the starter is only the client side. Run a broker locally, for example with Docker, or use Spring Boot's Testcontainers and Docker Compose support during development.
Define a Jackson2JsonMessageConverter bean, as in the example above. Boot wires it into the RabbitTemplate and the listener containers automatically.
The AMQP starter talks to RabbitMQ using Spring AMQP, while the ActiveMQ starter uses JMS. Choose based on the broker your platform already runs; the programming models and routing concepts differ.
spring-boot-starter-amqp is the single dependency that brings Spring AMQP and the RabbitMQ client into a Spring Boot application. Boot then auto-configures the connection factory, RabbitTemplate, AmqpAdmin and listener containers from spring.rabbitmq.* properties. Add a JSON message converter, set acknowledgement and retry behaviour deliberately, and use dead-letter queues so the setup holds up in production.