D
- the destination typepublic abstract class AbstractMessageSendingTemplate<D> extends java.lang.Object implements MessageSendingOperations<D>
MessageSendingOperations
.Modifier and Type | Field and Description |
---|---|
static java.lang.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,
java.lang.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,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.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,
java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.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,
java.lang.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(java.lang.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(java.lang.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(java.lang.Object payload,
java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.Object> |
processHeadersToSend(java.util.Map<java.lang.String,java.lang.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 java.lang.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(@Nullable D defaultDestination)
@Nullable 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(java.lang.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, java.lang.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, java.lang.Object payload, @Nullable java.util.Map<java.lang.String,java.lang.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(java.lang.Object payload, @Nullable 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, java.lang.Object payload, @Nullable 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, java.lang.Object payload, @Nullable java.util.Map<java.lang.String,java.lang.Object> headers, @Nullable 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(java.lang.Object payload, @Nullable java.util.Map<java.lang.String,java.lang.Object> headers, @Nullable 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 message@Nullable protected java.util.Map<java.lang.String,java.lang.Object> processHeadersToSend(@Nullable java.util.Map<java.lang.String,java.lang.Object> headers)
This default implementation in this class returns the input map.
headers
- the headers to send (or null
if none)null
if none)