public abstract class AbstractMessageSendingTemplate<D> extends Object implements MessageSendingOperations<D>
MessageSendingOperations
.Modifier and Type | Field and Description |
---|---|
static String |
CONVERSION_HINT_HEADER
Name of the header that can be set to provide further information
(e.g.
|
protected Log |
logger |
Constructor and Description |
---|
AbstractMessageSendingTemplate() |
Modifier and Type | Method and Description |
---|---|
void |
convertAndSend(D destination,
Object payload)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message and send it to the given destination. |
void |
convertAndSend(D destination,
Object payload,
Map<String,Object> headers)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message with the given headers and send it to
the given destination. |
void |
convertAndSend(D destination,
Object payload,
Map<String,Object> headers,
MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message with the given headers, apply the given post processor,
and send the resulting message to the given destination. |
void |
convertAndSend(D destination,
Object payload,
MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message, apply the given post processor, and send
the resulting message to the given destination. |
void |
convertAndSend(Object payload)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message and send it to a default destination. |
void |
convertAndSend(Object payload,
MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using a
MessageConverter ,
wrap it as a message, apply the given post processor, and send
the resulting message to a default destination. |
protected Message<?> |
doConvert(Object payload,
Map<String,Object> headers,
MessagePostProcessor postProcessor)
Convert the given Object to serialized form, possibly using a
MessageConverter , wrap it as a message with the given
headers and apply the given post processor. |
protected abstract void |
doSend(D destination,
Message<?> message) |
D |
getDefaultDestination()
Return the configured default destination.
|
MessageConverter |
getMessageConverter()
Return the configured
MessageConverter . |
protected D |
getRequiredDefaultDestination() |
protected Map<String,Object> |
processHeadersToSend(Map<String,Object> headers)
Provides access to the map of input headers before a send operation.
|
void |
send(D destination,
Message<?> message)
Send a message to the given destination.
|
void |
send(Message<?> message)
Send a message to a default destination.
|
void |
setDefaultDestination(D defaultDestination)
Configure the default destination to use in send methods that don't have
a destination argument.
|
void |
setMessageConverter(MessageConverter messageConverter)
Set the
MessageConverter to use in convertAndSend methods. |
public static final String CONVERSION_HINT_HEADER
MethodParameter
instance) about the origin of the
payload, to be taken into account as a conversion hint.protected final Log logger
public void setDefaultDestination(D defaultDestination)
public D getDefaultDestination()
public void setMessageConverter(MessageConverter messageConverter)
MessageConverter
to use in convertAndSend
methods.
By default, SimpleMessageConverter
is used.
messageConverter
- the message converter to usepublic MessageConverter getMessageConverter()
MessageConverter
.public void send(Message<?> message)
MessageSendingOperations
send
in interface MessageSendingOperations<D>
message
- the message to sendprotected final D getRequiredDefaultDestination()
public void send(D destination, Message<?> message)
MessageSendingOperations
send
in interface MessageSendingOperations<D>
destination
- the target destinationmessage
- the message to sendpublic void convertAndSend(Object payload) throws MessagingException
MessageSendingOperations
MessageConverter
,
wrap it as a message and send it to a default destination.convertAndSend
in interface MessageSendingOperations<D>
payload
- the Object to use as payloadMessagingException
public void convertAndSend(D destination, Object payload) throws MessagingException
MessageSendingOperations
MessageConverter
,
wrap it as a message and send it to the given destination.convertAndSend
in interface MessageSendingOperations<D>
destination
- the target destinationpayload
- the Object to use as payloadMessagingException
public void convertAndSend(D destination, Object payload, Map<String,Object> headers) throws MessagingException
MessageSendingOperations
MessageConverter
,
wrap it as a message with the given headers and send it to
the given destination.convertAndSend
in interface MessageSendingOperations<D>
destination
- the target destinationpayload
- the Object to use as payloadheaders
- headers for the message to sendMessagingException
public void convertAndSend(Object payload, MessagePostProcessor postProcessor) throws MessagingException
MessageSendingOperations
MessageConverter
,
wrap it as a message, apply the given post processor, and send
the resulting message to a default destination.convertAndSend
in interface MessageSendingOperations<D>
payload
- the Object to use as payloadpostProcessor
- the post processor to apply to the messageMessagingException
public void convertAndSend(D destination, Object payload, MessagePostProcessor postProcessor) throws MessagingException
MessageSendingOperations
MessageConverter
,
wrap it as a message, apply the given post processor, and send
the resulting message to the given destination.convertAndSend
in interface MessageSendingOperations<D>
destination
- the target destinationpayload
- the Object to use as payloadpostProcessor
- the post processor to apply to the messageMessagingException
public void convertAndSend(D destination, Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor) throws MessagingException
MessageSendingOperations
MessageConverter
,
wrap it as a message with the given headers, apply the given post processor,
and send the resulting message to the given destination.convertAndSend
in interface MessageSendingOperations<D>
destination
- the target destinationpayload
- the Object to use as payloadheaders
- headers for the message to sendpostProcessor
- the post processor to apply to the messageMessagingException
protected Message<?> doConvert(Object payload, Map<String,Object> headers, MessagePostProcessor postProcessor)
MessageConverter
, wrap it as a message with the given
headers and apply the given post processor.payload
- the Object to use as payloadheaders
- headers for the message to sendpostProcessor
- the post processor to apply to the messageprotected Map<String,Object> processHeadersToSend(Map<String,Object> headers)
This default implementation in this class returns the input map.
headers
- the headers to send (or null
if none)null
if none)