public class OrderedMessageChannelDecorator extends Object implements MessageChannel
ExecutorSubscribableChannel that ensures messages
are processed in the order they were published to the channel. Messages are
sent one at a time with the next one released when the prevoius has been
processed. This decorator is intended to be applied per session.INDEFINITE_TIMEOUT| Constructor and Description |
|---|
OrderedMessageChannelDecorator(MessageChannel channel,
Log logger) |
| Modifier and Type | Method and Description |
|---|---|
static void |
configureInterceptor(MessageChannel channel,
boolean preserveOrder)
Install or remove an
ExecutorChannelInterceptor that invokes a
completion task, if found in the headers of the message. |
static Runnable |
getNextMessageTask(Message<?> message)
Obtain the task to release the next message, if found.
|
boolean |
send(Message<?> message)
Send a
Message to this channel. |
boolean |
send(Message<?> message,
long timeout)
Send a message, blocking until either the message is accepted or the
specified timeout period elapses.
|
public OrderedMessageChannelDecorator(MessageChannel channel, Log logger)
public boolean send(Message<?> message)
MessageChannelMessage to this channel. If the message is sent successfully,
the method returns true. If the message cannot be sent due to a
non-fatal reason, the method returns false. The method may also
throw a RuntimeException in case of non-recoverable errors.
This method may block indefinitely, depending on the implementation.
To provide a maximum wait time, use MessageChannel.send(Message, long).
send in interface MessageChannelmessage - the message to sendpublic boolean send(Message<?> message, long timeout)
MessageChannelsend in interface MessageChannelmessage - the message to sendtimeout - the timeout in milliseconds or MessageChannel.INDEFINITE_TIMEOUTtrue if the message is sent, false if not
including a timeout of an interrupt of the send@Nullable public static Runnable getNextMessageTask(Message<?> message)
public static void configureInterceptor(MessageChannel channel, boolean preserveOrder)
ExecutorChannelInterceptor that invokes a
completion task, if found in the headers of the message.channel - the channel to configurepreserveOrder - whether preserve the order or publication; when
"true" an interceptor is inserted, when "false" it removed.