Spring AMQP

Authors

Mark Pollack , Mark Fisher , Oleg Zhurakousky , Dave Syer , Gary Russell , Gunnar Hillert , Artem Bilan , Stéphane Nicoll , Arnaud Cogoluègnes

2.1.3.RELEASE

Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.


Table of Contents

1. Preface
2. Introduction
2.1. Quick Tour for the impatient
2.1.1. Introduction
Compatibility
Very, Very Quick
With XML Configuration
With Java Configuration
With Spring Boot Auto Configuration and an Async POJO Listener
2.2. What’s New
2.2.1. Changes in 2.1 Since 2.0
AMQP Client library
Package Changes
Publisher Confirms Changes
Listener Container Factory Improvements
Broker Event Listener
RabbitAdmin Changes
RabbitTemplate Changes
Message Conversion
Management REST API
@RabbitListener Changes
Async @RabbitListener Return
Connection Factory Bean Changes
Connection Factory Changes
Listener Container Changes
Immediate requeue
3. Reference
3.1. Using Spring AMQP
3.1.1. AMQP Abstractions
Introduction
Message
Exchange
Queue
Binding
3.1.2. Connection and Resource Management
Introduction
Naming Connections
Blocked Connections and Resource Constraints
Configuring the Underlying Client Connection Factory
RabbitConnectionFactoryBean and Configuring SSL
Routing Connection Factory
Queue Affinity and the LocalizedQueueConnectionFactory
Publisher Confirms and Returns
Connection and Channel Listeners
Logging Channel Close Events
Runtime Cache Properties
RabbitMQ Automatic Connection/Topology recovery
3.1.3. Adding Custom Client Connection Properties
3.1.4. AmqpTemplate
Introduction
Adding Retry Capabilities
Publishing is Asynchronous - How to Detect Success and Failures
Publisher Confirms and Returns
Scoped Operations
Messaging integration
Validated User Id
Using a Separate Connection
3.1.5. Sending messages
Introduction
Message Builder API
Publisher Returns
Batching
3.1.6. Receiving messages
Introduction
Polling Consumer
Asynchronous Consumer
Batched Messages
Consumer Events
Consumer Tags
Annotation-driven Listener Endpoints
Using Container Factories
Asynchronous @RabbitListener Return Types
Threading and Asynchronous Consumers
Choosing a Container
Detecting Idle Asynchronous Consumers
3.1.7. Containers and Broker-Named queues
3.1.8. Message Converters
Introduction
SimpleMessageConverter
SerializerMessageConverter
Jackson2JsonMessageConverter
MarshallingMessageConverter
Jackson2XmlMessageConverter
ContentTypeDelegatingMessageConverter
Java Deserialization
Message Properties Converters
3.1.9. Modifying Messages - Compression and More
3.1.10. Request/Reply Messaging
Introduction
Reply Timeout
RabbitMQ Direct reply-to
Message Correlation With A Reply Queue
Reply Listener Container
AsyncRabbitTemplate
Spring Remoting with AMQP
3.1.11. Configuring the broker
Introduction
Headers Exchange
Builder API for Queues and Exchanges
Declaring Collections of Exchanges, Queues, Bindings
Conditional Declaration
A Note On "id" and "name" Attributes
AnonymousQueue
3.1.12. Broker Event Listener
3.1.13. Delayed Message Exchange
3.1.14. RabbitMQ REST API
3.1.15. Exception Handling
3.1.16. Transactions
Introduction
Conditional Rollback
A note on Rollback of Received Messages
Using the RabbitTransactionManager
3.1.17. Message Listener Container Configuration
3.1.18. Listener Concurrency
SimpleMessageListenerContainer
DirectMessageListenerContainer
3.1.19. Exclusive Consumer
3.1.20. Listener Container Queues
3.1.21. Resilience: Recovering from Errors and Broker Failures
Introduction
Automatic Declaration of Exchanges, Queues and Bindings
Failures in Synchronous Operations and Options for Retry
Message Listeners and the Asynchronous Case
Exception Classification for Retry
3.1.22. Debugging
3.2. Logging Subsystem AMQP Appenders
3.2.1. Common properties
3.2.2. Log4j2 Appender
3.2.3. Logback Appender
3.2.4. Customizing the Messages
3.2.5. Customizing the Client Properties
Simple String Properties
Advanced Technique for Logback
3.2.6. Providing a Custom Queue Implementation
3.3. Sample Applications
3.3.1. Introduction
3.3.2. Hello World
Introduction
Synchronous Example
Asynchronous Example
3.3.3. Stock Trading
3.3.4. Receiving JSON from Non-Spring Applications
3.4. Testing Support
3.4.1. Introduction
3.4.2. Mockito Answer<?> Implementations
3.4.3. @RabbitListenerTest and RabbitListenerTestHarness
3.4.4. TestRabbitTemplate
3.4.5. JUnit4 @Rules
BrokerRunning
LongRunningIntegrationTest
3.4.6. JUnit5 Conditions
@RabbitAvailable Annotation
@LongRunning Annotation
4. Spring Integration - Reference
4.1. Spring Integration AMQP Support
4.1.1. Introduction
4.1.2. Inbound Channel Adapter
4.1.3. Outbound Channel Adapter
4.1.4. Inbound Gateway
4.1.5. Outbound Gateway
5. Other Resources
5.1. Further Reading
A. Change History
A.1. Current Release
A.2. Previous Releases
A.2.1. Changes in 2.0 Since 1.7
CachingConnectionFactory
AMQP Client library
General Changes
Deleted classes
New Listener Container
Log4j Appender
RabbitTemplate Changes
Listener Adapter
Listener Container Changes
Connection Factory Changes
Retry Changes
Anonymous Queue Naming
@RabbitListener Changes
Container Conditional Rollback
Remove Jackson 1.x support
JSON Message Converter
XML Parsers
Blocked Connection
A.2.2. Changes in 1.7 Since 1.6
AMQP Client library
Log4j2 upgrade
Logback Appender
Spring Retry upgrade
FasterXML Jackson upgrade
JUnit @Rules
Container Conditional Rollback
Connection Naming Strategy
Listener Container Changes
A.2.3. Earlier Releases
A.2.4. Changes in 1.6 Since 1.5
Testing Support
Builder
Namespace Changes
Listener Container Changes
AutoDeclare and RabbitAdmins
AmqpTemplate: receive with timeout
AsyncRabbitTemplate
RabbitTemplate Changes
Message Properties
RabbitAdmin Changes
@RabbitListener Changes
Delayed Message Exchange
Exchange internal flag
CachingConnectionFactory Changes
RabbitConnectionFactoryBean
Java Deserialization
JSON MessageConverter
Logging Appenders
A.2.5. Changes in 1.5 Since 1.4
spring-erlang is No Longer Supported
CachingConnectionFactory Changes
Properties to Control Container Queue Declaration Behavior
Class Package Change
DefaultMessagePropertiesConverter
@RabbitListener Improvements
Automatic Exchange, Queue, Binding Declaration
RabbitTemplate Changes
The RabbitManagementTemplate
Listener Container Bean Names (XML)
Class-Level @RabbitListener
SimpleMessageListenerContainer: BackOff support
Channel Close Logging
Application Events
Consumer Tag Configuration
MessageListenerAdapter
LocalizedQueueConnectionFactory
Anonymous Queue Naming
A.2.6. Changes in 1.4 Since 1.3
@RabbitListener Annotation
RabbitMessagingTemplate
Listener Container Missing Queues Fatal Attribute
RabbitTemplate ConfirmCallback Interface
RabbitConnectionFactoryBean
CachingConnectionFactory
Log Appender
Listener Queues
RabbitTemplate: mandatory and connectionFactorySelector Expressions
Listeners and the Routing Connection Factory
RabbitTemplate: RecoveryCallback option
MessageConversionException
RabbitMQ 3.4 Compatibility
ContentTypeDelegatingMessageConverter
A.2.7. Changes in 1.3 Since 1.2
Listener Concurrency
Listener Queues
Consumer Priority
Exclusive Consumer
Rabbit Admin
Direct Exchange Binding
AMQP Template
Caching Connection Factory
Binding Arguments
Routing Connection Factory
MessageBuilder and MessagePropertiesBuilder
RetryInterceptorBuilder
RepublishMessageRecoverer
Default Error Handler (Since 1.3.2)
Listener Container 'missingQueuesFatal` Property (Since 1.3.5)
A.2.8. Changes to 1.2 Since 1.1
RabbitMQ Version
Rabbit Admin
Rabbit Template
JSON Message Converters
Automatic Declaration of Queues, etc
AMQP Remoting
Requested Heart Beats
A.2.9. Changes to 1.1 Since 1.0
General
AMQP Log4j Appender