Messaging: RabbitMQ, Apache Kafka, Pulsar, and JMS
Integrate Spring Boot with RabbitMQ, Apache Kafka, Apache Pulsar, JMS (ActiveMQ/Artemis), WebSockets, and Spring Integration via auto-configured starters.
Use this file to discover all available pages before exploring further.
Spring Boot provides first-class support for a wide variety of messaging systems through dedicated auto-configuration starters. Whether you need point-to-point queues, publish-subscribe topics, or streaming event logs, Spring Boot configures the required connection factories, templates, and listener containers so you can focus on message handling logic rather than infrastructure setup.
RabbitMQ / AMQP
spring-boot-starter-amqp — Lightweight, reliable message broker with rich routing via exchanges and queues.
Apache Kafka
spring-boot-starter-kafka — High-throughput distributed event streaming for real-time data pipelines.
Apache Pulsar
spring-boot-starter-pulsar — Cloud-native messaging with multi-tenancy, geo-replication, and tiered storage.
JMS
spring-boot-starter-activemq / spring-boot-starter-artemis — Java Message Service with embedded broker support.
The Advanced Message Queuing Protocol (AMQP) is a platform-neutral, wire-level protocol for message-oriented middleware. Spring Boot offers several conveniences for working with AMQP through RabbitMQ, including auto-configured AmqpTemplate and AmqpAdmin beans.Configuration:
@Componentpublic class MyBean { @RabbitListener(queues = "someQueue") public void processMessage(String content) { // handle message }}
By default, if retries are disabled and the listener throws an exception, the delivery is retried indefinitely. Set defaultRequeueRejected to false or throw AmqpRejectAndDontRequeueException to prevent infinite redelivery.
Apache Kafka is supported by providing auto-configuration of the spring-kafka project. Kafka configuration is controlled by external configuration properties in spring.kafka.*.Configuration:
@Componentpublic class MyBean { private final KafkaTemplate<String, String> kafkaTemplate; public MyBean(KafkaTemplate<String, String> kafkaTemplate) { this.kafkaTemplate = kafkaTemplate; } public void send(String message) { kafkaTemplate.send("someTopic", message); }}
Receiving messages with @KafkaListener:
MyBean.java
@Componentpublic class MyBean { @KafkaListener(topics = "someTopic") public void processMessage(String content) { // handle message }}
To create a topic on startup, add a bean of type NewTopic. If the topic already exists, the bean is ignored.
Kafka Streams:Spring Boot auto-configures the required KafkaStreamsConfiguration bean as long as kafka-streams is on the classpath and Kafka Streams is enabled with @EnableKafkaStreams:
Apache Pulsar is supported by providing auto-configuration of the Spring for Apache Pulsar project.Starter:spring-boot-starter-pulsarConnection configuration:
When spring-boot-starter-activemq is on the classpath, Spring Boot auto-configures a ConnectionFactory. An embedded broker starts automatically if no broker URL is specified.
Spring Integration provides a framework for building message-driven architectures based on enterprise integration patterns. Spring Boot provides auto-configuration and a starter for Spring Integration:
Spring Boot auto-configures the SpringIntegration management infrastructure. If spring-integration-jmx is also on the classpath, message processing statistics are published via JMX.