Spring AMQP

org.springframework.amqp.rabbit.core
Class RabbitTemplate

java.lang.Object
  extended by org.springframework.amqp.rabbit.connection.RabbitAccessor
      extended by org.springframework.amqp.rabbit.core.RabbitTemplate
All Implemented Interfaces:
AmqpTemplate, MessageListener, RabbitOperations, PublisherCallbackChannel.Listener, InitializingBean

public class RabbitTemplate
extends RabbitAccessor
implements RabbitOperations, MessageListener, PublisherCallbackChannel.Listener

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 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 ConnectionFactory. There are strategies available for converting messages to and from Java objects ( MessageConverter) and for converting message headers (known as message properties in AMQP, see 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.

Since:
1.0
Author:
Mark Pollack, Mark Fisher, Dave Syer, Gary Russell

Nested Class Summary
static interface RabbitTemplate.ConfirmCallback
           
static interface RabbitTemplate.ReturnCallback
           
 
Field Summary
 
Fields inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
logger
 
Constructor Summary
RabbitTemplate()
          Convenient constructor for use with setter injection.
RabbitTemplate(ConnectionFactory connectionFactory)
          Create a rabbit template with default strategies and settings.
 
Method Summary
 void convertAndSend(Object object)
          Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
 void convertAndSend(Object message, MessagePostProcessor messagePostProcessor)
          Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
 void convertAndSend(String routingKey, Object object)
          Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
 void convertAndSend(String routingKey, Object object, CorrelationData correlationData)
           
 void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor)
          Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
 void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
           
 void convertAndSend(String exchange, String routingKey, Object object)
          Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
 void convertAndSend(String exchange, String routingKey, Object object, CorrelationData corrationData)
           
 void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor)
          Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
 void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor, CorrelationData correlationData)
           
protected  Message convertMessageIfNecessary(Object object)
           
 Object convertSendAndReceive(Object message)
          Basic RPC pattern with conversion.
 Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor)
          Basic RPC pattern with conversion.
 Object convertSendAndReceive(String routingKey, Object message)
          Basic RPC pattern with conversion.
 Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor)
          Basic RPC pattern with conversion.
 Object convertSendAndReceive(String exchange, String routingKey, Object message)
          Basic RPC pattern with conversion.
 Object convertSendAndReceive(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor)
          Basic RPC pattern with conversion.
 void correlationconvertAndSend(Object object, CorrelationData correlationData)
           
protected  void doSend(com.rabbitmq.client.Channel channel, String exchange, String routingKey, Message message, CorrelationData correlationData)
          Send the given message to the specified exchange.
protected  Message doSendAndReceive(String exchange, String routingKey, Message message)
          Send a message and wait for a reply.
protected  Message doSendAndReceiveWithFixed(String exchange, String routingKey, Message message)
           
protected  Message doSendAndReceiveWithTemporary(String exchange, String routingKey, Message message)
           
<T> T
execute(ChannelCallback<T> action)
           
 MessageConverter getMessageConverter()
          Return the message converter for this template.
 Collection<CorrelationData> getUnconfirmed(long age)
          Gets unconfirmed correlatiom data older than age and removes them.
 String getUUID()
          Returns the UUID used to identify this Listener for returns.
 void handleConfirm(PendingConfirm pendingConfirm, boolean ack)
          Invoked by the channel when a confirm is received.
 void handleReturn(int replyCode, String replyText, String exchange, String routingKey, com.rabbitmq.client.AMQP.BasicProperties properties, byte[] body)
           
protected  void initDefaultStrategies()
          Set up the default strategies.
protected  boolean isChannelLocallyTransacted(com.rabbitmq.client.Channel channel)
          Check whether the given Channel is locally transacted, that is, whether its transaction is managed by this template's Channel handling and not by an external transaction coordinator.
 boolean isConfirmListener()
           
 boolean isReturnListener()
           
 void onMessage(Message message)
           
 Message receive()
          Receive a message if there is one from a default queue.
 Message receive(String queueName)
          Receive a message if there is one from a specific queue.
 Object receiveAndConvert()
          Receive a message if there is one from a default queue and convert it to a Java object.
 Object receiveAndConvert(String queueName)
          Receive a message if there is one from a specific queue and convert it to a Java object.
 void removePendingConfirmsReference(com.rabbitmq.client.Channel channel, SortedMap<Long,PendingConfirm> unconfirmed)
          When called, this listener must remove all references to the pending confirm map.
 void send(Message message)
          Send a message to a default exchange with a default routing key.
 void send(String routingKey, Message message)
          Send a message to a default exchange with a specific routing key.
 void send(String exchange, String routingKey, Message message)
          Send a message to a specific exchange with a specific routing key.
 void send(String exchange, String routingKey, Message message, CorrelationData correlationData)
           
 Message sendAndReceive(Message message)
          Basic RPC pattern.
 Message sendAndReceive(String routingKey, Message message)
          Basic RPC pattern.
 Message sendAndReceive(String exchange, String routingKey, Message message)
          Basic RPC pattern.
 void setConfirmCallback(RabbitTemplate.ConfirmCallback confirmCallback)
           
 void setCorrelationKey(String correlationKey)
          If set to 'correlationId' (default) the correlationId property will be used; otherwise the supplied key will be used.
 void setEncoding(String encoding)
          The encoding to use when inter-converting between byte arrays and Strings in message properties.
 void setExchange(String exchange)
          The name of the default exchange to use for send operations when none is specified.
 void setImmediate(boolean immediate)
          Deprecated. - RabbitMQ no longer supports this option when publishing messages.
 void setMandatory(boolean mandatory)
           
 void setMessageConverter(MessageConverter messageConverter)
          Set the message converter for this template.
 void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
          Set the MessagePropertiesConverter for this template.
 void setQueue(String queue)
          The name of the default queue to receive messages from when none is specified explicitly.
 void setReplyQueue(Queue replyQueue)
          A queue for replies; if not provided, a temporary exclusive, auto-delete queue will be used for each reply.
 void setReplyTimeout(long replyTimeout)
          Specify the timeout in milliseconds to be used when waiting for a reply Message when using one of the sendAndReceive methods.
 void setReturnCallback(RabbitTemplate.ReturnCallback returnCallback)
           
 void setRoutingKey(String routingKey)
          The value of a default routing key to use for send operations when none is specified.
 
Methods inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
afterPropertiesSet, convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RabbitTemplate

public RabbitTemplate()
Convenient constructor for use with setter injection. Don't forget to set the connection factory.


RabbitTemplate

public RabbitTemplate(ConnectionFactory connectionFactory)
Create a rabbit template with default strategies and settings.

Parameters:
connectionFactory - the connection factory to use
Method Detail

initDefaultStrategies

protected void initDefaultStrategies()
Set up the default strategies. Subclasses can override if necessary.


setExchange

public void setExchange(String exchange)
The name of the default exchange to use for send operations when none is specified. Defaults to "" which is the default exchange in the broker (per the AMQP specification).

Parameters:
exchange - the exchange name to use for send operations

setRoutingKey

public void setRoutingKey(String routingKey)
The value of a default routing key to use for send operations when none is specified. Default is empty which is not helpful when using the default (or any direct) exchange, but fine if the exchange is a headers exchange for instance.

Parameters:
routingKey - the default routing key to use for send operations

setQueue

public void setQueue(String queue)
The name of the default queue to receive messages from when none is specified explicitly.

Parameters:
queue - the default queue name to use for receive

setEncoding

public void setEncoding(String encoding)
The encoding to use when inter-converting between byte arrays and Strings in message properties.

Parameters:
encoding - the encoding to set

setReplyQueue

public void setReplyQueue(Queue replyQueue)
A queue for replies; if not provided, a temporary exclusive, auto-delete queue will be used for each reply.

Parameters:
replyQueue - the replyQueue to set

setReplyTimeout

public void setReplyTimeout(long replyTimeout)
Specify the timeout in milliseconds to be used when waiting for a reply Message when using one of the sendAndReceive methods. The default value is defined as DEFAULT_REPLY_TIMEOUT. A negative value indicates an indefinite timeout. Not used in the plain receive methods because there is no blocking receive operation defined in the protocol.

Parameters:
replyTimeout - the reply timeout in milliseconds
See Also:
sendAndReceive(String, String, Message), convertSendAndReceive(String, String, Object)

setMessageConverter

public void setMessageConverter(MessageConverter messageConverter)
Set the message converter for this template. Used to resolve Object parameters to convertAndSend methods and Object results from receiveAndConvert methods.

The default converter is a SimpleMessageConverter, which is able to handle byte arrays, Strings, and Serializable Objects depending on the message content type header.

See Also:
convertAndSend(java.lang.Object), receiveAndConvert(), SimpleMessageConverter

setMessagePropertiesConverter

public void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
Set the MessagePropertiesConverter for this template. This converter is used to convert between raw byte content in the message headers and plain Java objects. In particular there are limitations when dealing with very long string headers, which hopefully are rare in practice, but if you need to use long headers you might need to inject a special converter here.


getMessageConverter

public MessageConverter getMessageConverter()
Return the message converter for this template. Useful for clients that want to take advantage of the converter in ChannelCallback implementations.


setConfirmCallback

public void setConfirmCallback(RabbitTemplate.ConfirmCallback confirmCallback)

setReturnCallback

public void setReturnCallback(RabbitTemplate.ReturnCallback returnCallback)

setMandatory

public void setMandatory(boolean mandatory)

setImmediate

@Deprecated
public void setImmediate(boolean immediate)
Deprecated. - RabbitMQ no longer supports this option when publishing messages.


setCorrelationKey

public void setCorrelationKey(String correlationKey)
If set to 'correlationId' (default) the correlationId property will be used; otherwise the supplied key will be used.

Parameters:
correlationKey - the correlationKey to set

getUnconfirmed

public Collection<CorrelationData> getUnconfirmed(long age)
Gets unconfirmed correlatiom data older than age and removes them.

Parameters:
age - in millseconds
Returns:
the collection of correlation data for which confirms have not been received.

send

public void send(Message message)
          throws AmqpException
Description copied from interface: AmqpTemplate
Send a message to a default exchange with a default routing key.

Specified by:
send in interface AmqpTemplate
Parameters:
message - a message to send
Throws:
AmqpException - if there is a problem

send

public void send(String routingKey,
                 Message message)
          throws AmqpException
Description copied from interface: AmqpTemplate
Send a message to a default exchange with a specific routing key.

Specified by:
send in interface AmqpTemplate
Parameters:
routingKey - the routing key
message - a message to send
Throws:
AmqpException - if there is a problem

send

public void send(String exchange,
                 String routingKey,
                 Message message)
          throws AmqpException
Description copied from interface: AmqpTemplate
Send a message to a specific exchange with a specific routing key.

Specified by:
send in interface AmqpTemplate
Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
Throws:
AmqpException - if there is a problem

send

public void send(String exchange,
                 String routingKey,
                 Message message,
                 CorrelationData correlationData)
          throws AmqpException
Throws:
AmqpException

convertAndSend

public void convertAndSend(Object object)
                    throws AmqpException
Description copied from interface: AmqpTemplate
Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.

Specified by:
convertAndSend in interface AmqpTemplate
Parameters:
object - a message to send
Throws:
AmqpException - if there is a problem

correlationconvertAndSend

public void correlationconvertAndSend(Object object,
                                      CorrelationData correlationData)
                               throws AmqpException
Throws:
AmqpException

convertAndSend

public void convertAndSend(String routingKey,
                           Object object)
                    throws AmqpException
Description copied from interface: AmqpTemplate
Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.

Specified by:
convertAndSend in interface AmqpTemplate
Parameters:
routingKey - the routing key
object - a message to send
Throws:
AmqpException - if there is a problem

convertAndSend

public void convertAndSend(String routingKey,
                           Object object,
                           CorrelationData correlationData)
                    throws AmqpException
Throws:
AmqpException

convertAndSend

public void convertAndSend(String exchange,
                           String routingKey,
                           Object object)
                    throws AmqpException
Description copied from interface: AmqpTemplate
Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.

Specified by:
convertAndSend in interface AmqpTemplate
Parameters:
exchange - the name of the exchange
routingKey - the routing key
object - a message to send
Throws:
AmqpException - if there is a problem

convertAndSend

public void convertAndSend(String exchange,
                           String routingKey,
                           Object object,
                           CorrelationData corrationData)
                    throws AmqpException
Throws:
AmqpException

convertAndSend

public void convertAndSend(Object message,
                           MessagePostProcessor messagePostProcessor)
                    throws AmqpException
Description copied from interface: AmqpTemplate
Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.

Specified by:
convertAndSend in interface AmqpTemplate
Parameters:
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Throws:
AmqpException - if there is a problem

convertAndSend

public void convertAndSend(String routingKey,
                           Object message,
                           MessagePostProcessor messagePostProcessor)
                    throws AmqpException
Description copied from interface: AmqpTemplate
Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.

Specified by:
convertAndSend in interface AmqpTemplate
Parameters:
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Throws:
AmqpException - if there is a problem

convertAndSend

public void convertAndSend(String routingKey,
                           Object message,
                           MessagePostProcessor messagePostProcessor,
                           CorrelationData correlationData)
                    throws AmqpException
Throws:
AmqpException

convertAndSend

public void convertAndSend(String exchange,
                           String routingKey,
                           Object message,
                           MessagePostProcessor messagePostProcessor)
                    throws AmqpException
Description copied from interface: AmqpTemplate
Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.

Specified by:
convertAndSend in interface AmqpTemplate
Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Throws:
AmqpException - if there is a problem

convertAndSend

public void convertAndSend(String exchange,
                           String routingKey,
                           Object message,
                           MessagePostProcessor messagePostProcessor,
                           CorrelationData correlationData)
                    throws AmqpException
Throws:
AmqpException

receive

public Message receive()
                throws AmqpException
Description copied from interface: AmqpTemplate
Receive a message if there is one from a default queue. Returns immediately, possibly with a null value.

Specified by:
receive in interface AmqpTemplate
Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

receive

public Message receive(String queueName)
Description copied from interface: AmqpTemplate
Receive a message if there is one from a specific queue. Returns immediately, possibly with a null value.

Specified by:
receive in interface AmqpTemplate
Parameters:
queueName - the name of the queue to poll
Returns:
a message or null if there is none waiting

receiveAndConvert

public Object receiveAndConvert()
                         throws AmqpException
Description copied from interface: AmqpTemplate
Receive a message if there is one from a default queue and convert it to a Java object. Returns immediately, possibly with a null value.

Specified by:
receiveAndConvert in interface AmqpTemplate
Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

receiveAndConvert

public Object receiveAndConvert(String queueName)
                         throws AmqpException
Description copied from interface: AmqpTemplate
Receive a message if there is one from a specific queue and convert it to a Java object. Returns immediately, possibly with a null value.

Specified by:
receiveAndConvert in interface AmqpTemplate
Parameters:
queueName - the name of the queue to poll
Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

sendAndReceive

public Message sendAndReceive(Message message)
                       throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern. Send a message to a default exchange with a default routing key and attempt to receive a response. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
sendAndReceive in interface AmqpTemplate
Parameters:
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

sendAndReceive

public Message sendAndReceive(String routingKey,
                              Message message)
                       throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern. Send a message to a default exchange with a specific routing key and attempt to receive a response. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
sendAndReceive in interface AmqpTemplate
Parameters:
routingKey - the routing key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

sendAndReceive

public Message sendAndReceive(String exchange,
                              String routingKey,
                              Message message)
                       throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern. Send a message to a specific exchange with a specific routing key and attempt to receive a response. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
sendAndReceive in interface AmqpTemplate
Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

public Object convertSendAndReceive(Object message)
                             throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
convertSendAndReceive in interface AmqpTemplate
Parameters:
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

public Object convertSendAndReceive(String routingKey,
                                    Object message)
                             throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
convertSendAndReceive in interface AmqpTemplate
Parameters:
routingKey - the routing key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

public Object convertSendAndReceive(String exchange,
                                    String routingKey,
                                    Object message)
                             throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
convertSendAndReceive in interface AmqpTemplate
Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

public Object convertSendAndReceive(Object message,
                                    MessagePostProcessor messagePostProcessor)
                             throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
convertSendAndReceive in interface AmqpTemplate
Parameters:
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

public Object convertSendAndReceive(String routingKey,
                                    Object message,
                                    MessagePostProcessor messagePostProcessor)
                             throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
convertSendAndReceive in interface AmqpTemplate
Parameters:
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

public Object convertSendAndReceive(String exchange,
                                    String routingKey,
                                    Object message,
                                    MessagePostProcessor messagePostProcessor)
                             throws AmqpException
Description copied from interface: AmqpTemplate
Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.

Specified by:
convertSendAndReceive in interface AmqpTemplate
Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertMessageIfNecessary

protected Message convertMessageIfNecessary(Object object)

doSendAndReceive

protected Message doSendAndReceive(String exchange,
                                   String routingKey,
                                   Message message)
Send a message and wait for a reply.

Parameters:
exchange - the exchange name
routingKey - the routing key
message - the message to send
Returns:
the message that is received in reply

doSendAndReceiveWithTemporary

protected Message doSendAndReceiveWithTemporary(String exchange,
                                                String routingKey,
                                                Message message)

doSendAndReceiveWithFixed

protected Message doSendAndReceiveWithFixed(String exchange,
                                            String routingKey,
                                            Message message)

execute

public <T> T execute(ChannelCallback<T> action)
Specified by:
execute in interface RabbitOperations

doSend

protected void doSend(com.rabbitmq.client.Channel channel,
                      String exchange,
                      String routingKey,
                      Message message,
                      CorrelationData correlationData)
               throws Exception
Send the given message to the specified exchange.

Parameters:
channel - the RabbitMQ Channel to operate within
exchange - the name of the RabbitMQ exchange to send to
routingKey - the routing key
message - the Message to send
Throws:
IOException - if thrown by RabbitMQ API methods
Exception

isChannelLocallyTransacted

protected boolean isChannelLocallyTransacted(com.rabbitmq.client.Channel channel)
Check whether the given Channel is locally transacted, that is, whether its transaction is managed by this template's Channel handling and not by an external transaction coordinator.

Parameters:
channel - the Channel to check
Returns:
whether the given Channel is locally transacted
See Also:
ConnectionFactoryUtils.isChannelTransactional(com.rabbitmq.client.Channel, org.springframework.amqp.rabbit.connection.ConnectionFactory), RabbitAccessor.isChannelTransacted()

handleConfirm

public void handleConfirm(PendingConfirm pendingConfirm,
                          boolean ack)
Description copied from interface: PublisherCallbackChannel.Listener
Invoked by the channel when a confirm is received.

Specified by:
handleConfirm in interface PublisherCallbackChannel.Listener
Parameters:
pendingConfirm - The pending confirmation, containing correlation data.
ack - true when 'ack', false when 'nack'.

handleReturn

public void handleReturn(int replyCode,
                         String replyText,
                         String exchange,
                         String routingKey,
                         com.rabbitmq.client.AMQP.BasicProperties properties,
                         byte[] body)
                  throws IOException
Specified by:
handleReturn in interface PublisherCallbackChannel.Listener
Throws:
IOException

isConfirmListener

public boolean isConfirmListener()
Specified by:
isConfirmListener in interface PublisherCallbackChannel.Listener

isReturnListener

public boolean isReturnListener()
Specified by:
isReturnListener in interface PublisherCallbackChannel.Listener

removePendingConfirmsReference

public void removePendingConfirmsReference(com.rabbitmq.client.Channel channel,
                                           SortedMap<Long,PendingConfirm> unconfirmed)
Description copied from interface: PublisherCallbackChannel.Listener
When called, this listener must remove all references to the pending confirm map.

Specified by:
removePendingConfirmsReference in interface PublisherCallbackChannel.Listener
unconfirmed - The pending confirm map.

getUUID

public String getUUID()
Description copied from interface: PublisherCallbackChannel.Listener
Returns the UUID used to identify this Listener for returns.

Specified by:
getUUID in interface PublisherCallbackChannel.Listener
Returns:
A string representation of the UUID.

onMessage

public void onMessage(Message message)
Specified by:
onMessage in interface MessageListener

Spring AMQP