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 Summary
Fields inherited from class AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger -
Constructor Summary
Constructors -
Method Summary
Modifier 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 AbstractMessageReceivingTemplate
doConvert, doReceive, receive, receive, receiveAndConvert, receiveAndConvertMethods inherited from class AbstractMessageSendingTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, doConvert, doSend, getDefaultDestination, getMessageConverter, getRequiredDefaultDestination, processHeadersToSend, send, send, setDefaultDestination, setMessageConverter
-
Constructor Details
-
AbstractMessagingTemplate
public AbstractMessagingTemplate()
-
-
Method Details
-
sendAndReceive
Description copied from interface:MessageRequestReplyOperationsSend a request message and receive the reply from a default destination.- Specified by:
sendAndReceivein interfaceMessageRequestReplyOperations<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
-
sendAndReceive
public @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 interfaceMessageRequestReplyOperations<D>- Parameters:
destination- the target destinationrequestMessage- the message to send- Returns:
- the reply, possibly
nullif the message could not be received, for example due to a timeout - Throws:
MessagingException
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
request- payload for the request message to sendtargetClass- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
destination- the target destinationrequest- payload for the request message to sendtargetClass- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
request- payload for the request message to sendheaders- the headers for the request message to sendtargetClass- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
destination- the target destinationrequest- payload for the request message to sendheaders- the headers for the request message to sendtargetClass- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
request- payload for the request message to sendtargetClass- the target type to convert the payload of the reply topostProcessor- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
destination- the target destinationrequest- payload for the request message to sendtargetClass- the target type to convert the payload of the reply topostProcessor- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
request- payload for the request message to sendtargetClass- the target type to convert the payload of the reply topostProcessor- 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
-
convertSendAndReceive
public <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 interfaceMessageRequestReplyOperations<D>- Parameters:
destination- the target destinationrequest- payload for the request message to sendtargetClass- the target type to convert the payload of the reply topostProcessor- 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
-
doSendAndReceive
Actually send the given request message to the given destination and receive a reply message for it.- Parameters:
destination- the target destinationrequestMessage- the message to send- Returns:
- the received reply, possibly
nullif the message could not be received, for example due to a timeout
-