Class AbstractMessageReceivingTemplate<D>
- java.lang.Object
- org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
- org.springframework.messaging.core.AbstractMessageReceivingTemplate<D>
- All Implemented Interfaces:
MessageReceivingOperations<D>
,MessageSendingOperations<D>
- Direct Known Subclasses:
AbstractMessagingTemplate
public abstract class AbstractMessageReceivingTemplate<D> extends AbstractMessageSendingTemplate<D> implements MessageReceivingOperations<D>
An extension ofAbstractMessageSendingTemplate
that adds support for receive style operations as defined byMessageReceivingOperations
.- Since:
- 4.1
- Author:
- Mark Fisher, Rossen Stoyanchev, Stephane Nicoll
Field Summary
Fields inherited from class org.springframework.messaging.core.AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger
Constructor Summary
Constructors Constructor Description AbstractMessageReceivingTemplate()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T> T
doConvert(Message<?> message, Class<T> targetClass)
Convert from the given message to the given target class.protected abstract Message<?>
doReceive(D destination)
Actually receive a message from the given destination.Message<?>
receive()
Receive a message from a default destination.Message<?>
receive(D destination)
Receive a message from the given destination.<T> T
receiveAndConvert(D destination, Class<T> targetClass)
Receive a message from the given destination and convert its payload to the specified target class.<T> T
receiveAndConvert(Class<T> targetClass)
Receive a message from a default destination and convert its payload to the specified target class.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 Detail
AbstractMessageReceivingTemplate
public AbstractMessageReceivingTemplate()
Method Detail
receive
public Message<?> receive()
Description copied from interface:MessageReceivingOperations
Receive a message from a default destination.- Specified by:
receive
in interfaceMessageReceivingOperations<D>
- Returns:
- the received message, possibly
null
if the message could not be received, for example due to a timeout
receive
public Message<?> receive(D destination)
Description copied from interface:MessageReceivingOperations
Receive a message from the given destination.- Specified by:
receive
in interfaceMessageReceivingOperations<D>
- Parameters:
destination
- the target destination- Returns:
- the received message, possibly
null
if the message could not be received, for example due to a timeout
doReceive
protected abstract Message<?> doReceive(D destination)
Actually receive a message from the given destination.- Parameters:
destination
- the target destination- Returns:
- the received message, possibly
null
if the message could not be received, for example due to a timeout
receiveAndConvert
public <T> T receiveAndConvert(Class<T> targetClass)
Description copied from interface:MessageReceivingOperations
Receive a message from a default destination and convert its payload to the specified target class.- Specified by:
receiveAndConvert
in interfaceMessageReceivingOperations<D>
- Parameters:
targetClass
- the target class to convert the payload to- Returns:
- the converted payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout
receiveAndConvert
public <T> T receiveAndConvert(D destination, Class<T> targetClass)
Description copied from interface:MessageReceivingOperations
Receive a message from the given destination and convert its payload to the specified target class.- Specified by:
receiveAndConvert
in interfaceMessageReceivingOperations<D>
- Parameters:
destination
- the target destinationtargetClass
- the target class to convert the payload to- Returns:
- the converted payload of the reply message, possibly
null
if the message could not be received, for example due to a timeout