Spring Integration

org.springframework.integration.core
Interface MessagingOperations

All Known Implementing Classes:
AsyncMessagingTemplate, MessagingTemplate

public interface MessagingOperations

Specifies a basic set of messaging operations.

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 Messages across MessageChannels 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.

Since:
2.0
Author:
Mark Fisher
See Also:
MessagingTemplate

Method Summary
<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.
 

Method Detail

send

<P> void send(Message<P> message)
          throws MessagingException
Send a message to the default channel.

This will only work with a default channel specified!

Parameters:
message - the message to send
Throws:
MessagingException - if an error occurs during message sending

send

<P> void send(MessageChannel channel,
              Message<P> message)
          throws MessagingException
Send a message to the specified channel.

Parameters:
channel - the channel to which the message will be sent
message - the message to send
Throws:
MessagingException - if an error occurs during message sending

send

<P> void send(java.lang.String channelName,
              Message<P> message)
          throws MessagingException
Send a message to the specified channel.

Parameters:
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 send
Throws:
ChannelResolutionException - if the channel name cannot be resolved
MessagingException - if an error occurs during message sending

convertAndSend

<T> void convertAndSend(T message)
                    throws MessagingException
Send the given object to the default channel, converting the object to a message with a configured MessageConverter.

This will only work with a default channel specified!

Parameters:
message - the object to convert to a message
Throws:
MessagingException - if an error occurs

convertAndSend

<T> void convertAndSend(MessageChannel channel,
                        T message)
                    throws MessagingException
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter.

Parameters:
channel - the channel to send this message to
message - the object to convert to a message
Throws:
MessagingException - if an error occurs

convertAndSend

<T> void convertAndSend(java.lang.String channelName,
                        T message)
                    throws MessagingException
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter.

Parameters:
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 message
Throws:
MessagingException - if an error occurs

convertAndSend

<T> void convertAndSend(T message,
                        MessagePostProcessor postProcessor)
                    throws MessagingException
Send the given object to the default channel, converting the object to a message with a configured MessageConverter. The MessagePostProcessor callback allows for modification of the message after conversion.

This will only work with a default channel specified!

Parameters:
message - the object to convert to a message
postProcessor - the callback to modify the message
Throws:
MessagingException - if an error occurs

convertAndSend

<T> void convertAndSend(MessageChannel channel,
                        T message,
                        MessagePostProcessor postProcessor)
                    throws MessagingException
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter. The MessagePostProcessor callback allows for modification of the message after conversion.

Parameters:
channel - the channel to which the message will be sent
message - the object to convert to a message
postProcessor - the callback to modify the message
Throws:
MessagingException - if an error occurs

convertAndSend

<T> void convertAndSend(java.lang.String channelName,
                        T message,
                        MessagePostProcessor postProcessor)
                    throws MessagingException
Send the given object to the specified channel, converting the object to a message with a configured MessageConverter. The MessagePostProcessor callback allows for modification of the message after conversion.

Parameters:
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 message
postProcessor - the callback to modify the message
Throws:
MessagingException - if an error occurs

receive

<P> Message<P> receive()
                   throws MessagingException
Receive a message synchronously from the default channel, but only wait up to a specified time for delivery.

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!

Returns:
the message received from the default channel or null if the timeout expires
Throws:
MessagingException - if an error occurs during message reception

receive

<P> Message<P> receive(PollableChannel channel)
                   throws MessagingException
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery.

This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

Parameters:
channel - the channel from which a message should be received
Returns:
the message received from the channel or null if the timeout expires
Throws:
MessagingException - if an error occurs during message reception

receive

<P> Message<P> receive(java.lang.String channelName)
                   throws MessagingException
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery.

This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

Parameters:
channelName - the name of the channel from which a message should be received (to be resolved to an actual channel by a ChannelResolver)
Returns:
the message received from the channel or null if the timeout expires
Throws:
ChannelResolutionException - if the channel name cannot be resolved
MessagingException - if an error occurs during message reception

receiveAndConvert

java.lang.Object receiveAndConvert()
                                   throws MessagingException
Receive a message synchronously from the default channel, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

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!

Returns:
the message received from the channel or null if the timeout expires.
Throws:
MessagingException - if an error occurs during message reception

receiveAndConvert

java.lang.Object receiveAndConvert(PollableChannel channel)
                                   throws MessagingException
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

Parameters:
channel - the channel from which a message should be received
Returns:
the message received from the channel or null if the timeout expires.
Throws:
MessagingException - if an error occurs during message reception

receiveAndConvert

java.lang.Object receiveAndConvert(java.lang.String channelName)
                                   throws MessagingException
Receive a message synchronously from the specified channel, but only wait up to a specified time for delivery. Convert the message into an object with a configured MessageConverter.

This method should be used carefully, since it will block the thread until the message becomes available or until the timeout value is exceeded.

Parameters:
channelName - the name of the channel from which a message should be received (to be resolved to an actual channel by a ChannelResolver)
Returns:
the message received from the channel or null if the timeout expires.
Throws:
MessagingException - if an error occurs during message reception

sendAndReceive

Message<?> sendAndReceive(Message<?> requestMessage)
Send a message to the default channel and receive a reply.

This will only work with a default channel specified!

Parameters:
requestMessage - the message to send
Returns:
the reply Message if received within the receive timeout.
Throws:
MessagingException - if an error occurs

sendAndReceive

Message<?> sendAndReceive(MessageChannel channel,
                          Message<?> requestMessage)
Send a message to the specified channel and receive a reply.

Parameters:
channel - the channel to which the request Message will be sent
requestMessage - the message to send
Returns:
the reply Message if received within the receive timeout.
Throws:
MessagingException - if an error occurs

sendAndReceive

Message<?> sendAndReceive(java.lang.String channelName,
                          Message<?> requestMessage)
Send a message to the specified channel and receive a reply.

Parameters:
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 send
Returns:
the reply Message if received within the receive timeout.
Throws:
ChannelResolutionException - if the channel name cannot be resolved
MessagingException - if an error occurs

convertSendAndReceive

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. If a reply Message is received within the receive timeout, it will be converted and returned.

This will only work with a default channel specified!

Parameters:
request - the object to convert to a request message
Returns:
the result of converting the reply Message
Throws:
MessagingException - if an error occurs

convertSendAndReceive

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. If a reply Message is received within the receive timeout, it will be converted and returned.

Parameters:
channel - the channel to which the request message will be sent
request - the object to convert to a request message
Returns:
the result of converting the reply Message
Throws:
MessagingException - if an error occurs

convertSendAndReceive

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. If a reply Message is received within the receive timeout, it will be converted and returned.

Parameters:
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 message
Returns:
the result of converting the reply Message
Throws:
MessagingException - if an error occurs

convertSendAndReceive

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. The MessagePostProcessor callback allows for modification of the request message after conversion. If a reply Message is received within the receive timeout, it will be converted and returned.

This will only work with a default channel specified!

Parameters:
request - the object to convert to a request message
requestPostProcessor - the callback to modify the request message
Returns:
the result of converting the reply Message
Throws:
MessagingException - if an error occurs

convertSendAndReceive

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. The MessagePostProcessor callback allows for modification of the request message after conversion. If a reply Message is received within the receive timeout, it will be converted and returned.

Parameters:
channel - the channel to which the request message will be sent
request - the object to convert to a request message
requestPostProcessor - the callback to modify the request message
Returns:
the result of converting the reply Message
Throws:
MessagingException - if an error occurs

convertSendAndReceive

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. The MessagePostProcessor callback allows for modification of the request message after conversion. If a reply Message is received within the receive timeout, it will be converted and returned.

Parameters:
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 message
requestPostProcessor - the callback to modify the request message
Returns:
the result of converting the reply Message
Throws:
MessagingException - if an error occurs

Spring Integration