Class AbstractMessagingTemplate<D>
java.lang.Object
org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
org.springframework.messaging.core.AbstractMessageReceivingTemplate<D>
org.springframework.messaging.core.AbstractMessagingTemplate<D>
- Type Parameters:
- D- the destination type
- All Implemented Interfaces:
- MessageReceivingOperations<D>, MessageRequestReplyOperations<D>, MessageSendingOperations<D>
- Direct Known Subclasses:
- AbstractDestinationResolvingMessagingTemplate, JmsMessagingTemplate
public abstract class AbstractMessagingTemplate<D>
extends AbstractMessageReceivingTemplate<D>
implements MessageRequestReplyOperations<D>
An extension of 
AbstractMessageReceivingTemplate that adds support for
request-reply style operations as defined by MessageRequestReplyOperations.- Since:
- 4.0
- Author:
- Mark Fisher, Rossen Stoyanchev, Stephane Nicoll, Juergen Hoeller
- 
Field SummaryFields inherited from class AbstractMessageSendingTemplateCONVERSION_HINT_HEADER, logger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> @Nullable TconvertSendAndReceive(D destination, Object request, Class<T> targetClass) Convert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessageto the given destination, receive the reply and convert its body of the specified target class.<T> @Nullable TconvertSendAndReceive(D destination, Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Convert the given request Object to serialized form, possibly using aMessageConverter, apply the given post-processor and send the resultingMessageto the given destination, receive the reply and convert its body of the given target class.<T> @Nullable TconvertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) Convert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessagewith the given headers, to the specified destination, receive the reply and convert its body of the specified target class.<T> @Nullable TconvertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Convert the given request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-processor and send the resultingMessageto the specified destination, receive the reply and convert its body of the given target class.<T> @Nullable TconvertSendAndReceive(Object request, Class<T> targetClass) Convert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessageto a default destination, receive the reply and convert its body of the specified target class.<T> @Nullable TconvertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Convert the given request Object to serialized form, possibly using aMessageConverter, apply the given post-processor and send the resultingMessageto a default destination, receive the reply and convert its body of the given target class.<T> @Nullable TConvert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessagewith the given headers, to the specified destination, receive the reply and convert its body of the specified target class.<T> @Nullable TconvertSendAndReceive(Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Convert the given request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-processor and send the resultingMessageto the specified destination, receive the reply and convert its body of the given target class.doSendAndReceive(D destination, Message<?> requestMessage) Actually send the given request message to the given destination and receive a reply message for it.sendAndReceive(D destination, Message<?> requestMessage) Send a request message and receive the reply from the given destination.sendAndReceive(Message<?> requestMessage) Send a request message and receive the reply from a default destination.Methods inherited from class AbstractMessageReceivingTemplatedoConvert, doReceive, receive, receive, receiveAndConvert, receiveAndConvertMethods inherited from class AbstractMessageSendingTemplateconvertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, doSend, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, send, setDefaultDestination, setMessageConverter
- 
Constructor Details- 
AbstractMessagingTemplatepublic AbstractMessagingTemplate()
 
- 
- 
Method Details- 
sendAndReceiveDescription copied from interface:MessageRequestReplyOperationsSend a request message and receive the reply from a default destination.- Specified by:
- sendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- requestMessage- the message to send
- Returns:
- the reply, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
sendAndReceivepublic @Nullable Message<?> sendAndReceive(D destination, Message<?> requestMessage) throws MessagingException Description copied from interface:MessageRequestReplyOperationsSend a request message and receive the reply from the given destination.- Specified by:
- sendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- destination- the target destination
- requestMessage- the message to send
- Returns:
- the reply, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(Object request, Class<T> targetClass) throws MessagingException Description copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessageto a default destination, receive the reply and convert its body of the specified target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- request- payload for the request message to send
- targetClass- the target type to convert the payload of the reply to
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(D destination, Object request, Class<T> targetClass) throws MessagingException Description copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessageto the given destination, receive the reply and convert its body of the specified target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- destination- the target destination
- request- payload for the request message to send
- targetClass- the target type to convert the payload of the reply to
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingExceptionDescription copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessagewith the given headers, to the specified destination, receive the reply and convert its body of the specified target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- request- payload for the request message to send
- headers- the headers for the request message to send
- targetClass- the target type to convert the payload of the reply to
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingExceptionDescription copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, send it as aMessagewith the given headers, to the specified destination, receive the reply and convert its body of the specified target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- destination- the target destination
- request- payload for the request message to send
- headers- the headers for the request message to send
- targetClass- the target type to convert the payload of the reply to
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingException Description copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, apply the given post-processor and send the resultingMessageto a default destination, receive the reply and convert its body of the given target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- request- payload for the request message to send
- targetClass- the target type to convert the payload of the reply to
- postProcessor- post-process to apply to the request message
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(D destination, Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingException Description copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, apply the given post-processor and send the resultingMessageto the given destination, receive the reply and convert its body of the given target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- destination- the target destination
- request- payload for the request message to send
- targetClass- the target type to convert the payload of the reply to
- postProcessor- post-process to apply to the request message
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingExceptionDescription copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-processor and send the resultingMessageto the specified destination, receive the reply and convert its body of the given target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- request- payload for the request message to send
- targetClass- the target type to convert the payload of the reply to
- postProcessor- post-process to apply to the request message
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
convertSendAndReceivepublic <T> @Nullable T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingExceptionDescription copied from interface:MessageRequestReplyOperationsConvert the given request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-processor and send the resultingMessageto the specified destination, receive the reply and convert its body of the given target class.- Specified by:
- convertSendAndReceivein interface- MessageRequestReplyOperations<D>
- Parameters:
- destination- the target destination
- request- payload for the request message to send
- targetClass- the target type to convert the payload of the reply to
- postProcessor- post-process to apply to the request message
- Returns:
- the payload of the reply message, possibly nullif the message could not be received, for example due to a timeout
- Throws:
- MessagingException
 
- 
doSendAndReceiveActually send the given request message to the given destination and receive a reply message for it.- Parameters:
- destination- the target destination
- requestMessage- the message to send
- Returns:
- the received reply, possibly nullif the message could not be received, for example due to a timeout
 
 
-