Class AbstractMessageSendingTemplate<D>
java.lang.Object
org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
- Type Parameters:
- D- the destination type
- All Implemented Interfaces:
- MessageSendingOperations<D>
- Direct Known Subclasses:
- AbstractMessageReceivingTemplate,- SimpMessagingTemplate
public abstract class AbstractMessageSendingTemplate<D>
extends Object
implements MessageSendingOperations<D>
Abstract base class for implementations of 
MessageSendingOperations.- Since:
- 4.0
- Author:
- Mark Fisher, Rossen Stoyanchev, Stephane Nicoll
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidconvertAndSend(D destination, Object payload) Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the given destination.voidConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the given destination.voidconvertAndSend(D destination, Object payload, Map<String, Object> headers, MessagePostProcessor postProcessor) Convert the given 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 given destination.voidconvertAndSend(D destination, Object payload, MessagePostProcessor postProcessor) Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.voidconvertAndSend(Object payload) Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to a default destination.voidconvertAndSend(Object payload, MessagePostProcessor postProcessor) Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.protected Message<?>Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and apply the given post processor.protected abstract voidReturn the configured default destination.Return the configuredMessageConverter.protected final DprocessHeadersToSend(Map<String, Object> headers) Provides access to the map of input headers before a send operation.voidSend a message to the given destination.voidSend a message to a default destination.voidsetDefaultDestination(D defaultDestination) Configure the default destination to use in send methods that don't have a destination argument.voidsetMessageConverter(MessageConverter messageConverter) Set theMessageConverterto use inconvertAndSendmethods.
- 
Field Details- 
CONVERSION_HINT_HEADERName of the header that can be set to provide further information (for example, aMethodParameterinstance) about the origin of the payload, to be taken into account as a conversion hint.- Since:
- 4.2
- See Also:
 
- 
logger
 
- 
- 
Constructor Details- 
AbstractMessageSendingTemplatepublic AbstractMessageSendingTemplate()
 
- 
- 
Method Details- 
setDefaultDestinationConfigure the default destination to use in send methods that don't have a destination argument. If a default destination is not configured, send methods without a destination argument will raise an exception if invoked.
- 
getDefaultDestinationReturn the configured default destination.
- 
setMessageConverterSet theMessageConverterto use inconvertAndSendmethods.By default, SimpleMessageConverteris used.- Parameters:
- messageConverter- the message converter to use
 
- 
getMessageConverterReturn the configuredMessageConverter.
- 
sendDescription copied from interface:MessageSendingOperationsSend a message to a default destination.- Specified by:
- sendin interface- MessageSendingOperations<D>
- Parameters:
- message- the message to send
 
- 
getRequiredDefaultDestination
- 
sendDescription copied from interface:MessageSendingOperationsSend a message to the given destination.- Specified by:
- sendin interface- MessageSendingOperations<D>
- Parameters:
- destination- the target destination
- message- the message to send
 
- 
doSend
- 
convertAndSendDescription copied from interface:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to a default destination.- Specified by:
- convertAndSendin interface- MessageSendingOperations<D>
- Parameters:
- payload- the Object to use as payload
- Throws:
- MessagingException
 
- 
convertAndSendDescription copied from interface:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message and send it to the given destination.- Specified by:
- convertAndSendin interface- MessageSendingOperations<D>
- Parameters:
- destination- the target destination
- payload- the Object to use as payload
- Throws:
- MessagingException
 
- 
convertAndSendpublic void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers) throws MessagingExceptionDescription copied from interface:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and send it to the given destination.- Specified by:
- convertAndSendin interface- MessageSendingOperations<D>
- Parameters:
- destination- the target destination
- payload- the Object to use as payload
- headers- the headers for the message to send
- Throws:
- MessagingException
 
- 
convertAndSendpublic void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException Description copied from interface:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.- Specified by:
- convertAndSendin interface- MessageSendingOperations<D>
- Parameters:
- payload- the Object to use as payload
- postProcessor- the post processor to apply to the message
- Throws:
- MessagingException
 
- 
convertAndSendpublic void convertAndSend(D destination, Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException Description copied from interface:MessageSendingOperationsConvert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.- Specified by:
- convertAndSendin interface- MessageSendingOperations<D>
- Parameters:
- destination- the target destination
- payload- the Object to use as payload
- postProcessor- the post processor to apply to the message
- Throws:
- MessagingException
 
- 
convertAndSendpublic void convertAndSend(D destination, Object payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) throws MessagingExceptionDescription copied from interface:MessageSendingOperationsConvert the given 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 given destination.- Specified by:
- convertAndSendin interface- MessageSendingOperations<D>
- Parameters:
- destination- the target destination
- payload- the Object to use as payload
- headers- the headers for the message to send
- postProcessor- the post processor to apply to the message
- Throws:
- MessagingException
 
- 
doConvertprotected Message<?> doConvert(Object payload, @Nullable Map<String, Object> headers, @Nullable MessagePostProcessor postProcessor) Convert the given Object to serialized form, possibly using aMessageConverter, wrap it as a message with the given headers and apply the given post processor.- Parameters:
- payload- the Object to use as payload
- headers- the headers for the message to send
- postProcessor- the post processor to apply to the message
- Returns:
- the converted message
 
- 
processHeadersToSendProvides access to the map of input headers before a send operation. Subclasses can modify the headers and then return the same or a different map.This default implementation in this class returns the input map. - Parameters:
- headers- the headers to send (or- nullif none)
- Returns:
- the actual headers to send (or nullif none)
 
 
-