public class RabbitTemplate extends RabbitAccessor implements org.springframework.beans.factory.BeanFactoryAware, RabbitOperations, org.springframework.amqp.core.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.
| Modifier and Type | Class and Description |
|---|---|
static interface |
RabbitTemplate.ConfirmCallback |
static interface |
RabbitTemplate.ReturnCallback |
logger| Constructor and Description |
|---|
RabbitTemplate()
Convenient constructor for use with setter injection.
|
RabbitTemplate(ConnectionFactory connectionFactory)
Create a rabbit template with default strategies and settings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
convertAndSend(java.lang.Object object) |
void |
convertAndSend(java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor) |
void |
convertAndSend(java.lang.String routingKey,
java.lang.Object object) |
void |
convertAndSend(java.lang.String routingKey,
java.lang.Object object,
CorrelationData correlationData) |
void |
convertAndSend(java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor) |
void |
convertAndSend(java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
CorrelationData correlationData) |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object object) |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object object,
CorrelationData correlationData) |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor) |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
CorrelationData correlationData) |
protected org.springframework.amqp.core.Message |
convertMessageIfNecessary(java.lang.Object object) |
java.lang.Object |
convertSendAndReceive(java.lang.Object message) |
java.lang.Object |
convertSendAndReceive(java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor) |
java.lang.Object |
convertSendAndReceive(java.lang.String routingKey,
java.lang.Object message) |
java.lang.Object |
convertSendAndReceive(java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor) |
java.lang.Object |
convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message) |
java.lang.Object |
convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor) |
void |
correlationconvertAndSend(java.lang.Object object,
CorrelationData correlationData)
Deprecated.
|
void |
correlationConvertAndSend(java.lang.Object object,
CorrelationData correlationData) |
protected void |
doSend(com.rabbitmq.client.Channel channel,
java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message,
CorrelationData correlationData)
Send the given message to the specified exchange.
|
protected org.springframework.amqp.core.Message |
doSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message)
Send a message and wait for a reply.
|
protected org.springframework.amqp.core.Message |
doSendAndReceiveWithFixed(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message) |
protected org.springframework.amqp.core.Message |
doSendAndReceiveWithTemporary(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message) |
<T> T |
execute(ChannelCallback<T> action) |
org.springframework.amqp.support.converter.MessageConverter |
getMessageConverter()
Return the message converter for this template.
|
java.util.Collection<CorrelationData> |
getUnconfirmed(long age)
Gets unconfirmed correlation data older than age and removes them.
|
java.lang.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,
java.lang.String replyText,
java.lang.String exchange,
java.lang.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(org.springframework.amqp.core.Message message) |
org.springframework.amqp.core.Message |
receive() |
org.springframework.amqp.core.Message |
receive(java.lang.String queueName) |
java.lang.Object |
receiveAndConvert() |
java.lang.Object |
receiveAndConvert(java.lang.String queueName) |
<R,S> boolean |
receiveAndReply(org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback) |
<R,S> boolean |
receiveAndReply(org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
org.springframework.amqp.core.ReplyToAddressCallback<S> replyToAddressCallback) |
<R,S> boolean |
receiveAndReply(org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
java.lang.String exchange,
java.lang.String routingKey) |
<R,S> boolean |
receiveAndReply(java.lang.String queueName,
org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback) |
<R,S> boolean |
receiveAndReply(java.lang.String queueName,
org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
org.springframework.amqp.core.ReplyToAddressCallback<S> replyToAddressCallback) |
<R,S> boolean |
receiveAndReply(java.lang.String queueName,
org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
java.lang.String replyExchange,
java.lang.String replyRoutingKey) |
void |
removePendingConfirmsReference(com.rabbitmq.client.Channel channel,
java.util.SortedMap<java.lang.Long,PendingConfirm> unconfirmed)
When called, this listener must remove all references to the
pending confirm map.
|
void |
send(org.springframework.amqp.core.Message message) |
void |
send(java.lang.String routingKey,
org.springframework.amqp.core.Message message) |
void |
send(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message) |
void |
send(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message,
CorrelationData correlationData) |
org.springframework.amqp.core.Message |
sendAndReceive(org.springframework.amqp.core.Message message) |
org.springframework.amqp.core.Message |
sendAndReceive(java.lang.String routingKey,
org.springframework.amqp.core.Message message) |
org.springframework.amqp.core.Message |
sendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message) |
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setConfirmCallback(RabbitTemplate.ConfirmCallback confirmCallback) |
void |
setCorrelationKey(java.lang.String correlationKey)
If set to 'correlationId' (default) the correlationId property
will be used; otherwise the supplied key will be used.
|
void |
setEncoding(java.lang.String encoding)
The encoding to use when inter-converting between byte arrays and Strings in message properties.
|
void |
setExchange(java.lang.String exchange)
The name of the default exchange to use for send operations when none is specified.
|
void |
setMandatory(boolean mandatory) |
void |
setMandatoryExpression(org.springframework.expression.Expression mandatoryExpression) |
void |
setMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)
Set the message converter for this template.
|
void |
setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
Set the
MessagePropertiesConverter for this template. |
void |
setQueue(java.lang.String queue)
The name of the default queue to receive messages from when none is specified explicitly.
|
void |
setReceiveConnectionFactorySelectorExpression(org.springframework.expression.Expression receiveConnectionFactorySelectorExpression)
A SpEL
Expression to evaluate
against each receive queueName, if the provided RabbitAccessor.getConnectionFactory()
is an instance of AbstractRoutingConnectionFactory. |
void |
setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)
Add a
RecoveryCallback which is used for the retryTemplate.execute. |
void |
setReplyQueue(org.springframework.amqp.core.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 |
setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
Add a
RetryTemplate which will be used for all rabbit operations. |
void |
setReturnCallback(RabbitTemplate.ReturnCallback returnCallback) |
void |
setRoutingKey(java.lang.String routingKey)
The value of a default routing key to use for send operations when none is specified.
|
void |
setSendConnectionFactorySelectorExpression(org.springframework.expression.Expression sendConnectionFactorySelectorExpression)
A SpEL
Expression to evaluate
against each request message, if the provided RabbitAccessor.getConnectionFactory()
is an instance of AbstractRoutingConnectionFactory. |
afterPropertiesSet, convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactorypublic RabbitTemplate()
public RabbitTemplate(ConnectionFactory connectionFactory)
connectionFactory - the connection factory to useprotected void initDefaultStrategies()
public void setExchange(java.lang.String exchange)
""
which is the default exchange in the broker (per the AMQP specification).exchange - the exchange name to use for send operationspublic void setRoutingKey(java.lang.String routingKey)
routingKey - the default routing key to use for send operationspublic void setQueue(java.lang.String queue)
queue - the default queue name to use for receivepublic void setEncoding(java.lang.String encoding)
encoding - the encoding to setpublic void setReplyQueue(org.springframework.amqp.core.Queue replyQueue)
replyQueue - the replyQueue to setpublic void setReplyTimeout(long replyTimeout)
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.replyTimeout - the reply timeout in millisecondssendAndReceive(String, String, Message),
convertSendAndReceive(String, String, Object)public void setMessageConverter(org.springframework.amqp.support.converter.MessageConverter messageConverter)
The default converter is a SimpleMessageConverter, which is able to handle byte arrays, Strings, and Serializable Objects depending on the message content type header.
messageConverter - The message converter.convertAndSend(java.lang.Object),
receiveAndConvert(),
SimpleMessageConverterpublic void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
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.messagePropertiesConverter - The message properties converter.public org.springframework.amqp.support.converter.MessageConverter getMessageConverter()
ChannelCallback implementations.public void setConfirmCallback(RabbitTemplate.ConfirmCallback confirmCallback)
public void setReturnCallback(RabbitTemplate.ReturnCallback returnCallback)
public void setMandatory(boolean mandatory)
public void setMandatoryExpression(org.springframework.expression.Expression mandatoryExpression)
mandatoryExpression - a SpEL Expression to evaluate against each request
message, if a returnCallback has been provided. The result of expression must be
a boolean value.public void setSendConnectionFactorySelectorExpression(org.springframework.expression.Expression sendConnectionFactorySelectorExpression)
Expression to evaluate
against each request message, if the provided RabbitAccessor.getConnectionFactory()
is an instance of AbstractRoutingConnectionFactory.
The result of this expression is used as lookupKey to get the target
ConnectionFactory from AbstractRoutingConnectionFactory
directly.
If this expression is evaluated to null, we fallback to the normal
AbstractRoutingConnectionFactory logic.
If there is no target ConnectionFactory with the evaluated lookupKey,
we fallback to the normal AbstractRoutingConnectionFactory logic
only if its property lenientFallback == true.
This expression is used for send operations.
sendConnectionFactorySelectorExpression - a SpEL Expression to evaluatepublic void setReceiveConnectionFactorySelectorExpression(org.springframework.expression.Expression receiveConnectionFactorySelectorExpression)
Expression to evaluate
against each receive queueName, if the provided RabbitAccessor.getConnectionFactory()
is an instance of AbstractRoutingConnectionFactory.
The result of this expression is used as lookupKey to get the target
ConnectionFactory from AbstractRoutingConnectionFactory
directly.
If this expression is evaluated to null, we fallback to the normal
AbstractRoutingConnectionFactory logic.
If there is no target ConnectionFactory with the evaluated lookupKey,
we fallback to the normal AbstractRoutingConnectionFactory logic
only if its property lenientFallback == true.
This expression is used for receive operations.
receiveConnectionFactorySelectorExpression - a SpEL Expression to evaluatepublic void setCorrelationKey(java.lang.String correlationKey)
correlationKey - the correlationKey to setpublic void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
RetryTemplate which will be used for all rabbit operations.retryTemplate - The retry template.public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)
RecoveryCallback which is used for the retryTemplate.execute.
If retryTemplate isn't provided recoveryCallback is ignored.
RecoveryCallback should produce result compatible with
execute(ChannelCallback, ConnectionFactory) return type.recoveryCallback - The retry recoveryCallback.public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwareorg.springframework.beans.BeansExceptionpublic java.util.Collection<CorrelationData> getUnconfirmed(long age)
age - in millisecondspublic void send(org.springframework.amqp.core.Message message)
throws org.springframework.amqp.AmqpException
send in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void send(java.lang.String routingKey,
org.springframework.amqp.core.Message message)
throws org.springframework.amqp.AmqpException
send in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void send(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message)
throws org.springframework.amqp.AmqpException
send in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void send(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.Object object)
throws org.springframework.amqp.AmqpException
convertAndSend in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpException@Deprecated
public void correlationconvertAndSend(java.lang.Object object,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void correlationConvertAndSend(java.lang.Object object,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String routingKey,
java.lang.Object object)
throws org.springframework.amqp.AmqpException
convertAndSend in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String routingKey,
java.lang.Object object,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object object)
throws org.springframework.amqp.AmqpException
convertAndSend in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object object,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor)
throws org.springframework.amqp.AmqpException
convertAndSend in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor)
throws org.springframework.amqp.AmqpException
convertAndSend in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor)
throws org.springframework.amqp.AmqpException
convertAndSend in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor,
CorrelationData correlationData)
throws org.springframework.amqp.AmqpException
org.springframework.amqp.AmqpExceptionpublic org.springframework.amqp.core.Message receive()
throws org.springframework.amqp.AmqpException
receive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic org.springframework.amqp.core.Message receive(java.lang.String queueName)
receive in interface org.springframework.amqp.core.AmqpTemplatepublic java.lang.Object receiveAndConvert()
throws org.springframework.amqp.AmqpException
receiveAndConvert in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object receiveAndConvert(java.lang.String queueName)
throws org.springframework.amqp.AmqpException
receiveAndConvert in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic <R,S> boolean receiveAndReply(org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback)
throws org.springframework.amqp.AmqpException
receiveAndReply in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic <R,S> boolean receiveAndReply(java.lang.String queueName,
org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback)
throws org.springframework.amqp.AmqpException
receiveAndReply in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic <R,S> boolean receiveAndReply(org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
java.lang.String exchange,
java.lang.String routingKey)
throws org.springframework.amqp.AmqpException
receiveAndReply in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic <R,S> boolean receiveAndReply(java.lang.String queueName,
org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
java.lang.String replyExchange,
java.lang.String replyRoutingKey)
throws org.springframework.amqp.AmqpException
receiveAndReply in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic <R,S> boolean receiveAndReply(org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
org.springframework.amqp.core.ReplyToAddressCallback<S> replyToAddressCallback)
throws org.springframework.amqp.AmqpException
receiveAndReply in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic <R,S> boolean receiveAndReply(java.lang.String queueName,
org.springframework.amqp.core.ReceiveAndReplyCallback<R,S> callback,
org.springframework.amqp.core.ReplyToAddressCallback<S> replyToAddressCallback)
throws org.springframework.amqp.AmqpException
receiveAndReply in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic org.springframework.amqp.core.Message sendAndReceive(org.springframework.amqp.core.Message message)
throws org.springframework.amqp.AmqpException
sendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic org.springframework.amqp.core.Message sendAndReceive(java.lang.String routingKey,
org.springframework.amqp.core.Message message)
throws org.springframework.amqp.AmqpException
sendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic org.springframework.amqp.core.Message sendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message)
throws org.springframework.amqp.AmqpException
sendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object convertSendAndReceive(java.lang.Object message)
throws org.springframework.amqp.AmqpException
convertSendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object convertSendAndReceive(java.lang.String routingKey,
java.lang.Object message)
throws org.springframework.amqp.AmqpException
convertSendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message)
throws org.springframework.amqp.AmqpException
convertSendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object convertSendAndReceive(java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor)
throws org.springframework.amqp.AmqpException
convertSendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object convertSendAndReceive(java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor)
throws org.springframework.amqp.AmqpException
convertSendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionpublic java.lang.Object convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object message,
org.springframework.amqp.core.MessagePostProcessor messagePostProcessor)
throws org.springframework.amqp.AmqpException
convertSendAndReceive in interface org.springframework.amqp.core.AmqpTemplateorg.springframework.amqp.AmqpExceptionprotected org.springframework.amqp.core.Message convertMessageIfNecessary(java.lang.Object object)
protected org.springframework.amqp.core.Message doSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message)
exchange - the exchange nameroutingKey - the routing keymessage - the message to sendprotected org.springframework.amqp.core.Message doSendAndReceiveWithTemporary(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message)
protected org.springframework.amqp.core.Message doSendAndReceiveWithFixed(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message)
public <T> T execute(ChannelCallback<T> action)
execute in interface RabbitOperationsprotected void doSend(com.rabbitmq.client.Channel channel,
java.lang.String exchange,
java.lang.String routingKey,
org.springframework.amqp.core.Message message,
CorrelationData correlationData)
throws java.lang.Exception
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.correlationData - The correlation data.java.io.IOException - If thrown by RabbitMQ API methodsjava.lang.Exceptionprotected boolean isChannelLocallyTransacted(com.rabbitmq.client.Channel channel)
channel - the Channel to checkConnectionFactoryUtils.isChannelTransactional(com.rabbitmq.client.Channel, org.springframework.amqp.rabbit.connection.ConnectionFactory),
RabbitAccessor.isChannelTransacted()public void handleConfirm(PendingConfirm pendingConfirm, boolean ack)
PublisherCallbackChannel.ListenerhandleConfirm in interface PublisherCallbackChannel.ListenerpendingConfirm - The pending confirmation, containing
correlation data.ack - true when 'ack', false when 'nack'.public void handleReturn(int replyCode,
java.lang.String replyText,
java.lang.String exchange,
java.lang.String routingKey,
com.rabbitmq.client.AMQP.BasicProperties properties,
byte[] body)
throws java.io.IOException
handleReturn in interface PublisherCallbackChannel.Listenerjava.io.IOExceptionpublic boolean isConfirmListener()
isConfirmListener in interface PublisherCallbackChannel.Listenerpublic boolean isReturnListener()
isReturnListener in interface PublisherCallbackChannel.Listenerpublic void removePendingConfirmsReference(com.rabbitmq.client.Channel channel,
java.util.SortedMap<java.lang.Long,PendingConfirm> unconfirmed)
PublisherCallbackChannel.ListenerremovePendingConfirmsReference in interface PublisherCallbackChannel.Listenerchannel - The channel.unconfirmed - The pending confirm map.public java.lang.String getUUID()
PublisherCallbackChannel.ListenergetUUID in interface PublisherCallbackChannel.Listenerpublic void onMessage(org.springframework.amqp.core.Message message)
onMessage in interface org.springframework.amqp.core.MessageListener