Class AbstractDestinationResolvingMessagingTemplate<D>
java.lang.Object
org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
org.springframework.messaging.core.AbstractMessageReceivingTemplate<D>
org.springframework.messaging.core.AbstractMessagingTemplate<D>
org.springframework.messaging.core.AbstractDestinationResolvingMessagingTemplate<D>
- Type Parameters:
D- the destination type
- All Implemented Interfaces:
DestinationResolvingMessageReceivingOperations<D>, DestinationResolvingMessageRequestReplyOperations<D>, DestinationResolvingMessageSendingOperations<D>, MessageReceivingOperations<D>, MessageRequestReplyOperations<D>, MessageSendingOperations<D>
- Direct Known Subclasses:
GenericMessagingTemplate
public abstract class AbstractDestinationResolvingMessagingTemplate<D>
extends AbstractMessagingTemplate<D>
implements DestinationResolvingMessageSendingOperations<D>, DestinationResolvingMessageReceivingOperations<D>, DestinationResolvingMessageRequestReplyOperations<D>
An extension of
AbstractMessagingTemplate that adds operations for sending
messages to a resolvable destination name. Supports destination resolving as defined by
the following interfaces:
- Since:
- 4.0
- Author:
- Mark Fisher, Rossen Stoyanchev
-
Field Summary
Fields inherited from class AbstractMessageSendingTemplate
CONVERSION_HINT_HEADER, logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> voidconvertAndSend(String destinationName, T payload) Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the resolved destination.<T> voidResolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the resolved destination.<T> voidconvertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-processor, and send the resulting message to the resolved destination.<T> voidconvertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) Resolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post-processor, and send the resulting message to the resolved destination.<T> @Nullable TconvertSendAndReceive(String destinationName, Object request, Class<T> targetClass) Resolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the resolved destination, receive a reply and convert its body to the specified target class.<T> @Nullable TconvertSendAndReceive(String destinationName, Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Resolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post-process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.<T> @Nullable TconvertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) Resolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the resolved destination, receive a reply and convert its body to the specified target class.<T> @Nullable TconvertSendAndReceive(String destinationName, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) Resolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.Return the configured destination resolver.Resolve the given destination name and receive a message from it.<T> @Nullable TreceiveAndConvert(String destinationName, Class<T> targetClass) Resolve the given destination name, receive a message from it, convert the payload to the specified target type.protected final DresolveDestination(String destinationName) voidResolve the given destination name to a destination and send a message to it.sendAndReceive(String destinationName, Message<?> requestMessage) Resolve the given destination name to a destination and send the given message, receive a reply and return it.voidsetDestinationResolver(@Nullable DestinationResolver<D> destinationResolver) Configure theDestinationResolverto use to resolve String destination names into actual destinations of type<D>.Methods inherited from class AbstractMessagingTemplate
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, doSendAndReceive, sendAndReceive, sendAndReceiveMethods 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, setMessageConverterMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MessageReceivingOperations
receive, receive, receiveAndConvert, receiveAndConvertMethods inherited from interface MessageRequestReplyOperations
convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, sendAndReceive, sendAndReceiveMethods inherited from interface MessageSendingOperations
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, send, send
-
Constructor Details
-
AbstractDestinationResolvingMessagingTemplate
public AbstractDestinationResolvingMessagingTemplate()
-
-
Method Details
-
setDestinationResolver
Configure theDestinationResolverto use to resolve String destination names into actual destinations of type<D>.This field does not have a default setting. If not configured, methods that require resolving a destination name will raise an
IllegalArgumentException.- Parameters:
destinationResolver- the destination resolver to use
-
getDestinationResolver
Return the configured destination resolver. -
resolveDestination
- Throws:
DestinationResolutionException
-
send
Description copied from interface:DestinationResolvingMessageSendingOperationsResolve the given destination name to a destination and send a message to it.- Specified by:
sendin interfaceDestinationResolvingMessageSendingOperations<D>- Parameters:
destinationName- the destination name to resolvemessage- the message to send- Throws:
MessagingException
-
convertAndSend
Description copied from interface:DestinationResolvingMessageSendingOperationsResolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the resolved destination.- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<D>- Parameters:
destinationName- the destination name to resolvepayload- the Object to use as payload- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers) throws MessagingExceptionDescription copied from interface:DestinationResolvingMessageSendingOperationsResolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the resolved destination.- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<D>- Parameters:
destinationName- the destination name to resolvepayload- the Object to use as payloadheaders- the headers for the message to send- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destinationName, T payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException Description copied from interface:DestinationResolvingMessageSendingOperationsResolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post-processor, and send the resulting message to the resolved destination.- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<D>- Parameters:
destinationName- the destination name to resolvepayload- the Object to use as payloadpostProcessor- the post-processor to apply to the message- Throws:
MessagingException
-
convertAndSend
public <T> void convertAndSend(String destinationName, T payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) throws MessagingExceptionDescription copied from interface:DestinationResolvingMessageSendingOperationsResolve the given destination name to a destination, convert the payload Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-processor, and send the resulting message to the resolved destination.- Specified by:
convertAndSendin interfaceDestinationResolvingMessageSendingOperations<D>- Parameters:
destinationName- the destination name to resolvepayload- the Object to use as payloadheaders- the headers for the message to sendpostProcessor- the post-processor to apply to the message- Throws:
MessagingException
-
receive
Description copied from interface:DestinationResolvingMessageReceivingOperationsResolve the given destination name and receive a message from it.- Specified by:
receivein interfaceDestinationResolvingMessageReceivingOperations<D>- Parameters:
destinationName- the destination name to resolve- Throws:
MessagingException
-
receiveAndConvert
public <T> @Nullable T receiveAndConvert(String destinationName, Class<T> targetClass) throws MessagingException Description copied from interface:DestinationResolvingMessageReceivingOperationsResolve the given destination name, receive a message from it, convert the payload to the specified target type.- Specified by:
receiveAndConvertin interfaceDestinationResolvingMessageReceivingOperations<D>- Parameters:
destinationName- the destination name to resolvetargetClass- the target class for the converted payload- Throws:
MessagingException
-
sendAndReceive
public @Nullable Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) throws MessagingException Description copied from interface:DestinationResolvingMessageRequestReplyOperationsResolve the given destination name to a destination and send the given message, receive a reply and return it.- Specified by:
sendAndReceivein interfaceDestinationResolvingMessageRequestReplyOperations<D>- Parameters:
destinationName- the name of the target destinationrequestMessage- the message to send- Returns:
- the received message, possibly
nullif the message could not be received, for example due to a timeout - Throws:
MessagingException
-
convertSendAndReceive
public <T> @Nullable T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass) throws MessagingException Description copied from interface:DestinationResolvingMessageRequestReplyOperationsResolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the resolved destination, receive a reply and convert its body to the specified target class.- Specified by:
convertSendAndReceivein interfaceDestinationResolvingMessageRequestReplyOperations<D>- Parameters:
destinationName- the name of the target destinationrequest- the payload for the request message to sendtargetClass- the target class to convert the payload of the reply to- Returns:
- the converted 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(String destinationName, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass) throws MessagingExceptionDescription copied from interface:DestinationResolvingMessageRequestReplyOperationsResolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the resolved destination, receive a reply and convert its body to the specified target class.- Specified by:
convertSendAndReceivein interfaceDestinationResolvingMessageRequestReplyOperations<D>- Parameters:
destinationName- the name of the target destinationrequest- the payload for the request message to sendheaders- the headers for the request message to sendtargetClass- the target class to convert the payload of the reply to- Returns:
- the converted 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(String destinationName, Object request, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingException Description copied from interface:DestinationResolvingMessageRequestReplyOperationsResolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post-process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.- Specified by:
convertSendAndReceivein interfaceDestinationResolvingMessageRequestReplyOperations<D>- Parameters:
destinationName- the name of the target destinationrequest- the payload for the request message to sendtargetClass- the target class to convert the payload of the reply topostProcessor- post-process for the request message- Returns:
- the converted 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(String destinationName, Object request, @Nullable Map<String, Object> headers, Class<T> targetClass, @Nullable MessagePostProcessor postProcessor) throws MessagingExceptionDescription copied from interface:DestinationResolvingMessageRequestReplyOperationsResolve the given destination name, convert the payload request Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers, apply the given post-process, and send the resulting message to the resolved destination, then receive a reply and convert its body to the specified target class.- Specified by:
convertSendAndReceivein interfaceDestinationResolvingMessageRequestReplyOperations<D>- Parameters:
destinationName- the name of the target destinationrequest- the payload for the request message to sendheaders- the headers for the request message to sendtargetClass- the target class to convert the payload of the reply topostProcessor- post-process for the request message- Returns:
- the converted payload of the reply message, possibly
nullif the message could not be received, for example due to a timeout - Throws:
MessagingException
-