D - the destination typepublic 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(@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)
MessageSendingOperationssend in interface MessageSendingOperations<D>message - the message to sendprotected final D getRequiredDefaultDestination()
public void send(D destination, Message<?> message)
MessageSendingOperationssend in interface MessageSendingOperations<D>destination - the target destinationmessage - the message to sendpublic void convertAndSend(Object payload) throws MessagingException
MessageSendingOperationsMessageConverter,
wrap it as a message and send it to a default destination.convertAndSend in interface MessageSendingOperations<D>payload - the Object to use as payloadMessagingExceptionpublic void convertAndSend(D destination, Object payload) throws MessagingException
MessageSendingOperationsMessageConverter,
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 payloadMessagingExceptionpublic void convertAndSend(D destination, Object payload, @Nullable Map<String,Object> headers) throws MessagingException
MessageSendingOperationsMessageConverter,
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 - the headers for the message to sendMessagingExceptionpublic void convertAndSend(Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException
MessageSendingOperationsMessageConverter,
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 messageMessagingExceptionpublic void convertAndSend(D destination, Object payload, @Nullable MessagePostProcessor postProcessor) throws MessagingException
MessageSendingOperationsMessageConverter,
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 messageMessagingExceptionpublic void convertAndSend(D destination, Object payload, @Nullable Map<String,Object> headers, @Nullable MessagePostProcessor postProcessor) throws MessagingException
MessageSendingOperationsMessageConverter,
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 - the headers for the message to sendpostProcessor - the post processor to apply to the messageMessagingExceptionprotected Message<?> doConvert(Object payload, @Nullable Map<String,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 - the headers for the message to sendpostProcessor - the post processor to apply to the message@Nullable protected Map<String,Object> processHeadersToSend(@Nullable 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)