public class RabbitMessagingTemplate extends org.springframework.messaging.core.AbstractMessagingTemplate<java.lang.String> implements RabbitMessageOperations, org.springframework.beans.factory.InitializingBean
RabbitMessageOperations.| Constructor and Description |
|---|
RabbitMessagingTemplate()
Constructor for use with bean properties.
|
RabbitMessagingTemplate(RabbitTemplate rabbitTemplate)
Create an instance with the
RabbitTemplate to use. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected org.springframework.messaging.MessagingException |
convertAmqpException(java.lang.RuntimeException ex) |
protected org.springframework.messaging.Message<?> |
convertAmqpMessage(org.springframework.amqp.core.Message message) |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload)
Convert the given Object to serialized form, possibly using a
MessageConverter,
wrap it as a message and send it to a specific exchange with a
specific routing key. |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.Object> headers)
Convert the given Object to serialized form, possibly using a
MessageConverter,
wrap it as a message with the given headers and send it to a
specific exchange with a specific routing key. |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.Object> headers,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using a
MessageConverter,
wrap it as a message with the given headers, apply the given post processor,
and send the resulting message to a specific exchange with a specific
routing key. |
void |
convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using a
MessageConverter,
wrap it as a message, apply the given post processor, and send
the resulting message to a specific exchange with a specific
routing key. |
<T> T |
convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.lang.Class<T> targetClass)
Convert the given request Object to serialized form, possibly using a
MessageConverter, send
it as a Message to a specific exchange with a specific routing key,
receive the reply and convert its body of the specified target class. |
<T> T |
convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor requestPostProcessor)
Convert the given request Object to serialized form, possibly using a
MessageConverter,
apply the given post processor and send the resulting Message to
a specific exchange with a specific routing key, receive the reply and
convert its body of the given target class. |
<T> T |
convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.Class<T> targetClass)
Convert the given request Object to serialized form, possibly using a
MessageConverter, send
it as a Message with the given headers, to a specific exchange
with a specific routing key, receive the reply and convert its body of
the specified target class. |
<T> T |
convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor requestPostProcessor)
Convert the given request Object to serialized form, possibly using a
MessageConverter,
wrap it as a message with the given headers, apply the given post processor
and send the resulting Message to a specific exchange with a
specific routing key,, receive the reply and convert its body of the
given target class. |
protected org.springframework.messaging.Message<?> |
doReceive(java.lang.String destination) |
protected void |
doSend(java.lang.String destination,
org.springframework.messaging.Message<?> message) |
protected void |
doSend(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> message) |
protected org.springframework.messaging.Message<?> |
doSendAndReceive(java.lang.String destination,
org.springframework.messaging.Message<?> requestMessage) |
protected org.springframework.messaging.Message<?> |
doSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> requestMessage) |
org.springframework.amqp.support.converter.MessageConverter |
getAmqpMessageConverter() |
RabbitTemplate |
getRabbitTemplate() |
void |
send(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> message)
Send a message to a specific exchange with a specific routing key.
|
org.springframework.messaging.Message<?> |
sendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> requestMessage)
Send a request message to a specific exchange with a specific routing key and
wait for the reply
|
void |
setAmqpMessageConverter(org.springframework.amqp.support.converter.MessageConverter amqpMessageConverter)
Set the
MessageConverter to use to convert a Message from
the messaging to and from a Message. |
void |
setRabbitTemplate(RabbitTemplate rabbitTemplate)
Set the
RabbitTemplate to use. |
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive, sendAndReceivedoConvert, receive, receive, receiveAndConvert, receiveAndConvertconvertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, send, setDefaultDestination, setMessageConverterclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, send, sendpublic RabbitMessagingTemplate()
setRabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) to be called.public RabbitMessagingTemplate(RabbitTemplate rabbitTemplate)
RabbitTemplate to use.rabbitTemplate - the template.public void setRabbitTemplate(RabbitTemplate rabbitTemplate)
RabbitTemplate to use.rabbitTemplate - the template.public RabbitTemplate getRabbitTemplate()
RabbitTemplate.public void setAmqpMessageConverter(org.springframework.amqp.support.converter.MessageConverter amqpMessageConverter)
MessageConverter to use to convert a Message from
the messaging to and from a Message.
By default, a MessagingMessageConverter is defined using a
SimpleMessageConverter
to convert the payload of the message.
Consider configuring a MessagingMessageConverter with a different
payload converter
for more advanced scenario.
amqpMessageConverter - the message converter.MessagingMessageConverterpublic org.springframework.amqp.support.converter.MessageConverter getAmqpMessageConverter()
MessageConverter to use to convert a Message
from the messaging to and from a Message.public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic void send(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> message)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationssend in interface RabbitMessageOperationsexchange - the name of the exchangeroutingKey - the routing keymessage - the message to sendorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter,
wrap it as a message and send it to a specific exchange with a
specific routing key.convertAndSend in interface RabbitMessageOperationsexchange - the name of the exchangeroutingKey - the routing keypayload - the Object to use as payloadorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.Object> headers)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter,
wrap it as a message with the given headers and send it to a
specific exchange with a specific routing key.convertAndSend in interface RabbitMessageOperationsexchange - the name of the exchangeroutingKey - the routing keypayload - the Object to use as payloadheaders - headers for the message to sendorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter,
wrap it as a message, apply the given post processor, and send
the resulting message to a specific exchange with a specific
routing key.convertAndSend in interface RabbitMessageOperationsexchange - the name of the exchangeroutingKey - the routing keypayload - the Object to use as payloadpostProcessor - the post processor to apply to the messageorg.springframework.messaging.MessagingExceptionpublic void convertAndSend(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.Object> headers,
org.springframework.messaging.core.MessagePostProcessor postProcessor)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter,
wrap it as a message with the given headers, apply the given post processor,
and send the resulting message to a specific exchange with a specific
routing key.convertAndSend in interface RabbitMessageOperationsexchange - the name of the exchangeroutingKey - the routing keypayload - the Object to use as payloadheaders - headers for the message to sendpostProcessor - the post processor to apply to the messageorg.springframework.messaging.MessagingExceptionpublic org.springframework.messaging.Message<?> sendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> requestMessage)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationssendAndReceive in interface RabbitMessageOperationsexchange - the name of the exchangeroutingKey - the routing keyrequestMessage - the message to sendnull if the message could not be received,
for example due to a timeoutorg.springframework.messaging.MessagingExceptionpublic <T> T convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.lang.Class<T> targetClass)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter, send
it as a Message to a specific exchange with a specific routing key,
receive the reply and convert its body of the specified target class.convertSendAndReceive in interface RabbitMessageOperationsT - return typeexchange - the name of the exchangeroutingKey - the routing keyrequest - payload for the request message to sendtargetClass - the target type to convert the payload of the reply tonull if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingExceptionpublic <T> T convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.Class<T> targetClass)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter, send
it as a Message with the given headers, to a specific exchange
with a specific routing key, receive the reply and convert its body of
the specified target class.convertSendAndReceive in interface RabbitMessageOperationsT - return typeexchange - the name of the exchangeroutingKey - the routing keyrequest - payload for the request message to sendheaders - headers for the request message to sendtargetClass - the target type to convert the payload of the reply tonull if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingExceptionpublic <T> T convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor requestPostProcessor)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter,
apply the given post processor and send the resulting Message to
a specific exchange with a specific routing key, receive the reply and
convert its body of the given target class.convertSendAndReceive in interface RabbitMessageOperationsT - return typeexchange - the name of the exchangeroutingKey - the routing keyrequest - payload for the request message to sendtargetClass - the target type to convert the payload of the reply torequestPostProcessor - post process to apply to the request messagenull if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingExceptionpublic <T> T convertSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
java.lang.Object request,
java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.Class<T> targetClass,
org.springframework.messaging.core.MessagePostProcessor requestPostProcessor)
throws org.springframework.messaging.MessagingException
RabbitMessageOperationsMessageConverter,
wrap it as a message with the given headers, apply the given post processor
and send the resulting Message to a specific exchange with a
specific routing key,, receive the reply and convert its body of the
given target class.convertSendAndReceive in interface RabbitMessageOperationsT - return typeexchange - the name of the exchangeroutingKey - the routing keyrequest - payload for the request message to sendheaders - headers for the message to sendtargetClass - the target type to convert the payload of the reply torequestPostProcessor - post process to apply to the request messagenull if the message
could not be received, for example due to a timeoutorg.springframework.messaging.MessagingExceptionprotected void doSend(java.lang.String destination,
org.springframework.messaging.Message<?> message)
doSend in class org.springframework.messaging.core.AbstractMessageSendingTemplate<java.lang.String>protected void doSend(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> message)
protected org.springframework.messaging.Message<?> doReceive(java.lang.String destination)
doReceive in class org.springframework.messaging.core.AbstractMessageReceivingTemplate<java.lang.String>protected org.springframework.messaging.Message<?> doSendAndReceive(java.lang.String destination,
org.springframework.messaging.Message<?> requestMessage)
doSendAndReceive in class org.springframework.messaging.core.AbstractMessagingTemplate<java.lang.String>protected org.springframework.messaging.Message<?> doSendAndReceive(java.lang.String exchange,
java.lang.String routingKey,
org.springframework.messaging.Message<?> requestMessage)
protected org.springframework.messaging.Message<?> convertAmqpMessage(org.springframework.amqp.core.Message message)
protected org.springframework.messaging.MessagingException convertAmqpException(java.lang.RuntimeException ex)