Messaging Reference
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production; see the section bibliography for the reference material consulted while preparing these pages. |
Welcome to the Messaging reference. Messaging is asynchronous, broker-mediated communication between services: a producer publishes a message without waiting for a consumer to process it, and a broker takes on the job of storing, routing and redelivering that message until it is handled. This decouples producers from consumers in time, location and availability, and it underlies event-driven architectures, work distribution across competing consumers, and integration between systems that otherwise share nothing.
The examples in this section are written and verified against Apache Kafka 4.3.x, RabbitMQ 4.3.x, Spring Boot 4.1.x, Spring for Apache Kafka 4.1.x, Spring AMQP 4.1.x and Spring Cloud Stream 5.0.x.
If you are new to messaging, read Getting Started with Messaging first, then Messaging Models and Patterns and Delivery Guarantees for the concepts every broker page builds on. From there, read Kafka Architecture and RabbitMQ Architecture and the AMQP Model for the two brokers this section covers in depth, Kafka vs. RabbitMQ to compare them directly, and finally the Spring Boot integration pages to map both onto Spring Boot 4.1.
This section is broker- and protocol-first, not framework-first: it documents what the brokers and the wire protocols actually do, with plain Java client examples, before mapping any of it onto a framework. For the Spring Boot services that use these brokers, see the sibling SpringBoot Reference — in particular Messaging with Kafka and API-First: Messaging, which the Spring Boot integration pages below link to rather than duplicate.
Delivering messages to users' Apple devices is a different channel: a provider server sends them through the Apple Push Notification service (APNs), and the app side — registration, payloads, notification extensions and Live Activity updates — is covered on Notifications, APNs and Live Activities in the Apple Platforms section.
For messaging as a bridge into batch processing — launching jobs from messages and distributing chunk processing over a broker — see Spring Batch Integration in the sibling Spring Batch Reference.
For the equivalent mapping of this section’s broker concepts onto Quarkus, see Messaging with SmallRye Reactive Messaging in the sibling Quarkus Reference, listed again under "Other framework bindings" below.
What’s covered
Foundations
-
Getting Started with Messaging — the problem messaging solves, synchronous request/response vs. asynchronous messaging, brokered vs. brokerless, the shared vocabulary mapped across Kafka and RabbitMQ, running both brokers locally, and a first send/receive with each plain Java client.
-
Messaging Models and Patterns — point-to-point and publish/subscribe as the two base models, request/reply on top of them, and the Enterprise Integration Patterns the rest of this section refers to, each mapped onto its Kafka and RabbitMQ realisation.
-
Delivery Guarantees — at-most-once, at-least-once and exactly-once from both the producer and the consumer side, acknowledgements and redelivery, duplicates and idempotent consumers, ordering, and durability, with a configuration comparison table.
-
Messaging Protocols — AMQP 0-9-1, AMQP 1.0, the Kafka binary protocol, MQTT, STOMP, the RabbitMQ Stream protocol, WebSocket transports, and JMS/Jakarta Messaging, with a protocol-by-broker matrix.
Apache Kafka
-
Kafka Architecture — events, topics, partitions and offsets, segments and the on-disk log, brokers, KRaft controllers and the metadata log, replication, retention, log compaction, and tiered storage.
-
Kafka Producers — the Producer API, the record accumulator and batching, the partitioner,
acksandmin.insync.replicas, the idempotent producer, retries, compression, and a plain-Java producer example. -
Kafka Consumers — consumer groups, the poll loop, partition assignment and rebalancing (including the broker-driven KIP-848 protocol), static membership, offsets and commits, and a plain-Java consumer example.
-
Kafka Share Groups — Queues for Kafka (KIP-932): share groups vs. consumer groups, record acquisition locks, per-record outcomes and lock renewal, delivery counts and poison-message protection, and a plain-Java
ShareConsumerexample. -
Kafka Reliability and Exactly-Once — the reliability toolkit end to end — replication factor,
min.insync.replicas, producer and consumer discipline — then Kafka transactions (transactional.id,read_committed) and what exactly-once does and does not cover. -
Kafka Streams — topology,
KStream/KTable/GlobalKTable, stream-table duality, windowing, joins, state stores and changelog topics, exactly-once, and testing withTopologyTestDriver. -
Kafka Connect — source vs. sink connectors, standalone vs. distributed workers, tasks, converters, single message transforms, error handling and the sink dead-letter queue, and the transactional-outbox pattern via CDC.
-
Kafka Serialization and Schemas — serializers/deserializers as a contract, bytes vs. String vs. JSON vs. Avro/Protobuf/JSON Schema, and the case for a schema registry.
-
Kafka Operations and Monitoring — the CLI tools, partition-count decisions, dynamic configuration, key broker metrics and consumer lag, quotas, and geo-replication with MirrorMaker 2.
-
Kafka Security — listeners and security protocols, TLS encryption and mTLS authentication, SASL mechanisms, ACLs, and multi-tenancy.
RabbitMQ
-
RabbitMQ Architecture and the AMQP Model — connections, channels, virtual hosts, exchanges, bindings, queues and their properties, the Erlang/BEAM runtime, and clustering basics.
-
RabbitMQ Queue Types — classic, quorum and stream queues (and JMS queues), how to choose between them, and the migration path off classic mirrored queues.
-
RabbitMQ Publishing — publishing to an exchange, the mandatory flag and returns, alternate exchanges, publisher confirms, message properties, and publishing to streams.
-
RabbitMQ Consuming — push vs. pull consumption, acknowledgement modes, prefetch (QoS), consumer priorities and exclusivity, and consuming from streams.
-
RabbitMQ Routing Patterns — the six official tutorials as reusable patterns — work queues, publish/subscribe, routing, topics, RPC — plus headers-exchange routing and exchange-to-exchange bindings.
-
RabbitMQ Reliability, Dead-Lettering and TTL — connection recovery, confirms and manual acks, dead-letter exchanges, per-queue and per-message TTL, queue length limits, priorities, and retry topologies.
-
RabbitMQ and AMQP 1.0 — the v2 address format, sessions and links vs. channels, credit-based flow control, settlement outcomes, and the new
amqp-clientJava library. -
RabbitMQ Clustering, Federation and Shovel — clustering and the Khepri metadata store, federation, shovel, and when to use each versus a single cluster.
-
RabbitMQ Operations, Monitoring and Security — the management UI and HTTP API, CLI tools, policies, Prometheus/Grafana monitoring, and security (virtual hosts, permissions, TLS, OAuth 2.0/OIDC).
Comparison and practice
-
Kafka vs. RabbitMQ — a dimension-by-dimension comparison — design origin, data model, routing, consumer model, delivery guarantees, ordering, retention, per-message features, protocols, security, operations and runtime — closing with a decision table.
-
Messaging Patterns in Practice — the cross-broker patterns every production system needs: transactional outbox, idempotent consumers, retry and dead-letter handling, ordering keys and hot partitions, backpressure, correlation IDs, schema evolution, and saga choreography vs. orchestration.
Spring Boot integration
-
Spring Boot Messaging: Overview — the Spring messaging landscape and how to choose between Spring for Apache Kafka, Spring AMQP, Spring Cloud Stream and Spring Integration, the starters, and what this repository already documents elsewhere.
-
Spring for Apache Kafka — topic provisioning, request/reply, non-blocking retries with
@RetryableTopic, share consumers, exactly-once, and Kafka Streams — only what Messaging with Kafka does not already cover. -
Spring AMQP —
spring.rabbitmq.*configuration, topology as beans,@RabbitListener, retry and dead-letter configuration, request/reply, streams, and the AMQP 1.0 path. -
Spring Cloud Stream — the binder abstraction and the functional programming model, consumer groups and partitioning,
StreamBridge, and the Kafka and RabbitMQ binder specifics. -
Other Spring Messaging Options — application events, JMS/Jakarta Messaging, Spring Integration, WebSocket/STOMP, and Apache Pulsar.
-
Testing Messaging — Testcontainers with
@ServiceConnection,@EmbeddedKafka,spring-rabbit-test, the Spring Cloud Stream test binder, and AsyncAPI contract testing.
Other framework bindings
-
Messaging with SmallRye Reactive Messaging — the equivalent mapping of this section’s concepts onto Quarkus, via channels,
@Incoming/@Outgoing, and the Kafka, RabbitMQ, AMQP 1.0, Pulsar and JMS connectors.
Reference
-
Messaging Cheat Sheet — a one-page, printable summary of the whole section, with a downloadable PDF.
Bibliography
-
Apache Kafka documentation (primary source for every Kafka page) — the documentation entry point, Introduction, Quickstart, Docker, KRaft vs. ZooKeeper, Upgrading and notable per-release changes, the API overview, the Javadoc (including
ShareConsumer), broker, topic, group, producer, consumer and tiered-storage configuration references, the design documentation (persistence, replication, the idempotent producer, transactions, and the share consumer), the wire protocol, the log implementation, operations, KRaft operations, monitoring, geo-replication with MirrorMaker 2, tiered-storage operations, the next-generation consumer rebalance protocol, the transaction protocol, eligible leader replicas, the security overview, the Kafka Connect overview and user guide, Kafka Streams core concepts, architecture, the DSL developer guide and testing guide, the cited KIPs — KIP-500 (replace ZooKeeper), KIP-98 (exactly-once and transactions), KIP-405 (tiered storage), KIP-848 (next-generation consumer rebalance protocol) and KIP-932 (Queues for Kafka) — and the downloads/release-dates page. -
RabbitMQ documentation (primary source for every RabbitMQ page) — the documentation entry point, release information, the six official tutorials and the AMQP 0-9-1 concepts tutorial, the AMQP 0-9-1 protocol reference and the AMQP 0-9-1 specification, the AMQP 1.0 guide and the OASIS AMQP 1.0 standard, the protocols overview, MQTT and STOMP, publishers, consumers, confirms, consumer prefetch and direct reply-to, exchanges, queues, classic, quorum and stream queue types (with the stream plugin/protocol guide), channels, connections and virtual hosts, reliability, dead-lettering, TTL, priority, flow control, alarms and persistence configuration, clustering, the Khepri metadata store, federation, shovel and the Kubernetes operator, the management UI and HTTP API, policies, definitions export/import, monitoring and Prometheus, the production checklist and upgrading, access control and OAuth 2.0/OIDC, the client-libraries index and the Java API guide, the delayed-message exchange plugin and the community plugins index, and "Compare with other brokers: Kafka" — this last page is vendor-authored by the RabbitMQ team and is cited on Kafka vs. RabbitMQ only as one input among several, never as a neutral source on its own.
-
Spring documentation (primary source for the Spring Boot integration pages) — the Spring Boot 4.1 messaging reference and its AMQP, Kafka, JMS and Pulsar subsections, the Spring Integration subsection, the Testcontainers reference and the Docker Compose support guide, the application-properties appendix, the Spring for Apache Kafka 4.1 reference (including the share-consumer support, non-blocking retries, transactions and Kafka Streams support), the Spring AMQP 4.1 reference (including the stream plugin support, the RabbitMQ AMQP 1.0 client support and the generic AMQP 1.0 client), the Spring Cloud Stream 5.0 reference and its 4.0 migration guide (the annotation-based programming model’s removal), Spring Integration AMQP and Kafka support, Spring Framework JMS, Spring Modulith externalised events, and Spring for Apache Pulsar.
-
Patterns, schemas and tooling — Enterprise Integration Patterns (Hohpe & Woolf), the transactional outbox pattern and the Debezium outbox event router, Apache Avro, Confluent Schema Registry and AsyncAPI (as already used by API-First: Messaging), the Testcontainers Kafka module and RabbitMQ module, and Strimzi (Kafka on Kubernetes).
-
Consulted reference books (bibliography only — not the primary or main source for any page):
-
Narkhede, Neha; Shapira, Gwen; Palino, Todd. Kafka: The Definitive Guide: Real-Time Data and Stream Processing at Scale. O’Reilly Media, 1st ed., July 2017. ISBN 978-1-491-93616-0 — publisher page. Written against Kafka 0.9-0.10 and the ZooKeeper architecture, it predates KRaft, the KIP-848 rebalance protocol, share groups, tiered storage, MirrorMaker 2 and exactly-once v2, and describes MirrorMaker 1, older client APIs and ZooKeeper-based operations that Kafka 4.0 removed. It informs only the conceptual narrative on the Kafka Architecture, Kafka Producers, Kafka Consumers, Kafka Reliability and Exactly-Once, Kafka Connect and Kafka Streams pages.
-
Gutierrez, Felipe. Spring Boot Messaging: Messaging APIs for Enterprise and Integration Solutions. Apress, 2017. ISBN 978-1-4842-1225-7, DOI 10.1007/978-1-4842-1224-0 — publisher page. Written against Spring Boot 1.4 and a RabbitMQ 3.6-era broker, its Spring Cloud Stream annotation model was removed in Spring Cloud Stream 4.0, its "mirror queues" were removed in RabbitMQ 4.0, and it predates quorum queues, streams, native AMQP 1.0 and the current Spring AMQP / Spring Boot property and starter names. It informs only the messaging vocabulary and pattern taxonomy on Getting Started with Messaging and Messaging Models and Patterns, the AMQP-model explanation on RabbitMQ Architecture and the AMQP Model, and the map of Spring messaging options on Other Spring Messaging Options.
-
Both books above are consulted references only. Neither is the primary or main source for any page, and wherever either one and the Apache Kafka, RabbitMQ or Spring documentation disagree — or wherever a book is silent on something standardised or shipped after 2017 — the official documentation is authoritative.