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
-
Field Summary
Fields inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
convertSendAndReceive
(D destination, Object request, Class<T> targetClass) Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to the given destination, receive the reply and convert its body of the specified target class.<T> T
convertSendAndReceive
(D destination, Object request, Class<T> targetClass, MessagePostProcessor postProcessor) Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to the given destination, receive the reply and convert its body of the given target class.<T> T
convertSendAndReceive
(D destination, Object request, Map<String, Object> headers, Class<T> targetClass) Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
with the given headers, to the specified destination, receive the reply and convert its body of the specified target class.<T> T
convertSendAndReceive
(D destination, Object request, Map<String, Object> headers, Class<T> targetClass, 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 resultingMessage
to the specified destination, receive the reply and convert its body of the given target class.<T> T
convertSendAndReceive
(Object request, Class<T> targetClass) Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to a default destination, receive the reply and convert its body of the specified target class.<T> T
convertSendAndReceive
(Object request, Class<T> targetClass, MessagePostProcessor postProcessor) Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to a default destination, receive the reply and convert its body of the given target class.protected abstract Message<?>
doSendAndReceive
(D destination, Message<?> requestMessage) Message<?>
sendAndReceive
(D destination, Message<?> requestMessage) Send a request message and receive the reply from the given destination.Message<?>
sendAndReceive
(Message<?> requestMessage) Send a request message and receive the reply from a default destination.Methods inherited from class org.springframework.messaging.core.AbstractMessageReceivingTemplate
doConvert, doReceive, receive, receive, receiveAndConvert, receiveAndConvert
Methods inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate
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:MessageRequestReplyOperations
Send a request message and receive the reply from a default destination.- Specified by:
sendAndReceive
in interfaceMessageRequestReplyOperations<D>
- Parameters:
requestMessage
- the message to send- Returns:
- the reply, possibly
null
if the message could not be received, for example due to a timeout
-
sendAndReceive
Description copied from interface:MessageRequestReplyOperations
Send a request message and receive the reply from the given destination.- Specified by:
sendAndReceive
in interfaceMessageRequestReplyOperations<D>
- Parameters:
destination
- the target destinationrequestMessage
- the message to send- Returns:
- the reply, possibly
null
if the message could not be received, for example due to a timeout
-
doSendAndReceive
-
convertSendAndReceive
Description copied from interface:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to a default destination, receive the reply and convert its body of the specified target class.- Specified by:
convertSendAndReceive
in 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
null
if the message could not be received, for example due to a timeout
-
convertSendAndReceive
Description copied from interface:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
to the given destination, receive the reply and convert its body of the specified target class.- Specified by:
convertSendAndReceive
in 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
null
if the message could not be received, for example due to a timeout
-
convertSendAndReceive
@Nullable public <T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) Description copied from interface:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, send it as aMessage
with the given headers, to the specified destination, receive the reply and convert its body of the specified target class.- Specified by:
convertSendAndReceive
in 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
null
if the message could not be received, for example due to a timeout
-
convertSendAndReceive
@Nullable public <T> T convertSendAndReceive(Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Description copied from interface:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to a default destination, receive the reply and convert its body of the given target class.- Specified by:
convertSendAndReceive
in 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
null
if the message could not be received, for example due to a timeout
-
convertSendAndReceive
@Nullable public <T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Description copied from interface:MessageRequestReplyOperations
Convert the given request Object to serialized form, possibly using aMessageConverter
, apply the given post processor and send the resultingMessage
to the given destination, receive the reply and convert its body of the given target class.- Specified by:
convertSendAndReceive
in 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
null
if the message could not be received, for example due to a timeout
-
convertSendAndReceive
@Nullable public <T> T convertSendAndReceive(D destination, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Description copied from interface:MessageRequestReplyOperations
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 resultingMessage
to the specified destination, receive the reply and convert its body of the given target class.- Specified by:
convertSendAndReceive
in 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
null
if the message could not be received, for example due to a timeout
-