public interface MessagingOperations
Implemented by MessagingTemplate
. Even though most calling code
will depend on the template directly (e.g. to access setter methods), this
interface is a useful option to enhance testability, as it can easily be mocked
or stubbed.
Defines a variety of methods for sending and receiving Message
s
across MessageChannel
s including the use of converters where necessary.
Convenience methods also support sending and receiving based on channel name,
where the template will delegate to its ChannelResolver
to locate the
actual MessageChannel
instance.
MessagingTemplate
Modifier and Type | Method and Description |
---|---|
<T> void |
convertAndSend(MessageChannel channel,
T message)
Send the given object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
<T> void |
convertAndSend(MessageChannel channel,
T message,
MessagePostProcessor postProcessor)
Send the given object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
<T> void |
convertAndSend(java.lang.String channelName,
T message)
Send the given object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
<T> void |
convertAndSend(java.lang.String channelName,
T message,
MessagePostProcessor postProcessor)
Send the given object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
<T> void |
convertAndSend(T message)
Send the given object to the default channel, converting the object
to a message with a configured MessageConverter.
|
<T> void |
convertAndSend(T message,
MessagePostProcessor postProcessor)
Send the given object to the default channel, converting the object
to a message with a configured MessageConverter.
|
java.lang.Object |
convertSendAndReceive(MessageChannel channel,
java.lang.Object request)
Send the given request object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
java.lang.Object |
convertSendAndReceive(MessageChannel channel,
java.lang.Object request,
MessagePostProcessor requestPostProcessor)
Send the given request object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
java.lang.Object |
convertSendAndReceive(java.lang.Object request)
Send the given request object to the default channel, converting the object
to a message with a configured MessageConverter.
|
java.lang.Object |
convertSendAndReceive(java.lang.Object request,
MessagePostProcessor requestPostProcessor)
Send the given request object to the default channel, converting the object
to a message with a configured MessageConverter.
|
java.lang.Object |
convertSendAndReceive(java.lang.String channelName,
java.lang.Object request)
Send the given request object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
java.lang.Object |
convertSendAndReceive(java.lang.String channelName,
java.lang.Object request,
MessagePostProcessor requestPostProcessor)
Send the given request object to the specified channel, converting the object
to a message with a configured MessageConverter.
|
<P> Message<P> |
receive()
Receive a message synchronously from the default channel, but only
wait up to a specified time for delivery.
|
<P> Message<P> |
receive(PollableChannel channel)
Receive a message synchronously from the specified channel, but only
wait up to a specified time for delivery.
|
<P> Message<P> |
receive(java.lang.String channelName)
Receive a message synchronously from the specified channel, but only
wait up to a specified time for delivery.
|
java.lang.Object |
receiveAndConvert()
Receive a message synchronously from the default channel, but only
wait up to a specified time for delivery.
|
java.lang.Object |
receiveAndConvert(PollableChannel channel)
Receive a message synchronously from the specified channel, but only
wait up to a specified time for delivery.
|
java.lang.Object |
receiveAndConvert(java.lang.String channelName)
Receive a message synchronously from the specified channel, but only
wait up to a specified time for delivery.
|
<P> void |
send(Message<P> message)
Send a message to the default channel.
|
<P> void |
send(MessageChannel channel,
Message<P> message)
Send a message to the specified channel.
|
<P> void |
send(java.lang.String channelName,
Message<P> message)
Send a message to the specified channel.
|
Message<?> |
sendAndReceive(Message<?> requestMessage)
Send a message to the default channel and receive a reply.
|
Message<?> |
sendAndReceive(MessageChannel channel,
Message<?> requestMessage)
Send a message to the specified channel and receive a reply.
|
Message<?> |
sendAndReceive(java.lang.String channelName,
Message<?> requestMessage)
Send a message to the specified channel and receive a reply.
|
<P> void send(Message<P> message) throws MessagingException
This will only work with a default channel specified!
message
- the message to sendMessagingException
- if an error occurs during message sending<P> void send(MessageChannel channel, Message<P> message) throws MessagingException
channel
- the channel to which the message will be sentmessage
- the message to sendMessagingException
- if an error occurs during message sending<P> void send(java.lang.String channelName, Message<P> message) throws MessagingException
channelName
- the name of the channel to which the message will be sent
(to be resolved to an actual channel by a ChannelResolver)message
- the message to sendChannelResolutionException
- if the channel name cannot be resolvedMessagingException
- if an error occurs during message sending<T> void convertAndSend(T message) throws MessagingException
This will only work with a default channel specified!
message
- the object to convert to a messageMessagingException
- if an error occurs<T> void convertAndSend(MessageChannel channel, T message) throws MessagingException
channel
- the channel to send this message tomessage
- the object to convert to a messageMessagingException
- if an error occurs<T> void convertAndSend(java.lang.String channelName, T message) throws MessagingException
channelName
- the name of the channel to send this message to
(to be resolved to an actual channel by a ChannelResolver)message
- the object to convert to a messageMessagingException
- if an error occurs<T> void convertAndSend(T message, MessagePostProcessor postProcessor) throws MessagingException
This will only work with a default channel specified!
message
- the object to convert to a messagepostProcessor
- the callback to modify the messageMessagingException
- if an error occurs<T> void convertAndSend(MessageChannel channel, T message, MessagePostProcessor postProcessor) throws MessagingException
channel
- the channel to which the message will be sentmessage
- the object to convert to a messagepostProcessor
- the callback to modify the messageMessagingException
- if an error occurs<T> void convertAndSend(java.lang.String channelName, T message, MessagePostProcessor postProcessor) throws MessagingException
channelName
- the name of the channel to which the message will be sent
(to be resolved to an actual channel by a ChannelResolver)message
- the object to convert to a messagepostProcessor
- the callback to modify the messageMessagingException
- if an error occurs<P> Message<P> receive() throws MessagingException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default channel specified!
null
if the timeout expiresMessagingException
- if an error occurs during message reception<P> Message<P> receive(PollableChannel channel) throws MessagingException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
channel
- the channel from which a message should be receivednull
if the timeout expiresMessagingException
- if an error occurs during message reception<P> Message<P> receive(java.lang.String channelName) throws MessagingException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
channelName
- the name of the channel from which a message should be received
(to be resolved to an actual channel by a ChannelResolver)null
if the timeout expiresChannelResolutionException
- if the channel name cannot be resolvedMessagingException
- if an error occurs during message receptionjava.lang.Object receiveAndConvert() throws MessagingException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
This will only work with a default channel specified!
null
if the timeout expires.MessagingException
- if an error occurs during message receptionjava.lang.Object receiveAndConvert(PollableChannel channel) throws MessagingException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
channel
- the channel from which a message should be receivednull
if the timeout expires.MessagingException
- if an error occurs during message receptionjava.lang.Object receiveAndConvert(java.lang.String channelName) throws MessagingException
This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.
channelName
- the name of the channel from which a message should be received
(to be resolved to an actual channel by a ChannelResolver)null
if the timeout expires.MessagingException
- if an error occurs during message receptionMessage<?> sendAndReceive(Message<?> requestMessage)
This will only work with a default channel specified!
requestMessage
- the message to sendMessagingException
- if an error occursMessage<?> sendAndReceive(MessageChannel channel, Message<?> requestMessage)
channel
- the channel to which the request Message will be sentrequestMessage
- the message to sendMessagingException
- if an error occursMessage<?> sendAndReceive(java.lang.String channelName, Message<?> requestMessage)
channelName
- the name of the channel to which the request Message will be sent
(to be resolved to an actual channel by a ChannelResolver)requestMessage
- the message to sendChannelResolutionException
- if the channel name cannot be resolvedMessagingException
- if an error occursjava.lang.Object convertSendAndReceive(java.lang.Object request)
This will only work with a default channel specified!
request
- the object to convert to a request messageMessagingException
- if an error occursjava.lang.Object convertSendAndReceive(MessageChannel channel, java.lang.Object request)
channel
- the channel to which the request message will be sentrequest
- the object to convert to a request messageMessagingException
- if an error occursjava.lang.Object convertSendAndReceive(java.lang.String channelName, java.lang.Object request)
channelName
- the name of the channel to which the request message will be sent
(to be resolved to an actual channel by a ChannelResolver)request
- the object to convert to a request messageMessagingException
- if an error occursjava.lang.Object convertSendAndReceive(java.lang.Object request, MessagePostProcessor requestPostProcessor)
This will only work with a default channel specified!
request
- the object to convert to a request messagerequestPostProcessor
- the callback to modify the request messageMessagingException
- if an error occursjava.lang.Object convertSendAndReceive(MessageChannel channel, java.lang.Object request, MessagePostProcessor requestPostProcessor)
channel
- the channel to which the request message will be sentrequest
- the object to convert to a request messagerequestPostProcessor
- the callback to modify the request messageMessagingException
- if an error occursjava.lang.Object convertSendAndReceive(java.lang.String channelName, java.lang.Object request, MessagePostProcessor requestPostProcessor)
channelName
- the name of the channel to which the request message will be sent
(to be resolved to an actual channel by a ChannelResolver)request
- the object to convert to a request messagerequestPostProcessor
- the callback to modify the request messageMessagingException
- if an error occurs