Helper class that simplifies synchronous RabbitMQ access (sending and receiving messages).
The default settings are for non-transactional messaging, which reduces the amount of data exchanged with the broker. To use a new transaction for every send or receive set the {@link #setChannelTransacted(boolean) channelTransacted}flag. To extend the transaction over multiple invocations (more efficient), you can use a Spring transaction to bracket the calls (with channelTransacted=true
as well).
The only mandatory property is the {@link #setConnectionFactory(ConnectionFactory) ConnectionFactory}. There are strategies available for converting messages to and from Java objects ( {@link #setMessageConverter(MessageConverter) MessageConverter}) and for converting message headers (known as message properties in AMQP, see {@link #setMessagePropertiesConverter(MessagePropertiesConverter) MessagePropertiesConverter}). The defaults probably do something sensible for typical use cases, as long as the message content-type is set appropriately.
The "send" methods all have overloaded versions that allow you to explicitly target an exchange and a routing key, or you can set default values to be used in all send operations. The plain "receive" methods allow you to explicitly target a queue to receive from, or you can set a default value for the template that applies to all explicit receives. The convenience methods for send and receive use the sender defaults if no exchange or routing key is specified, but they always use a temporary queue for the receive leg, so the default queue is ignored.
@author Mark Pollack
@author Mark Fisher
@author Dave Syer
@author Gary Russell
@author Artem Bilan
@since 1.0