Class OrderedMessageChannelDecorator
java.lang.Object
org.springframework.messaging.simp.broker.OrderedMessageChannelDecorator
- All Implemented Interfaces:
MessageChannel
Decorator for an
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 previous has been
processed. This decorator is intended to be applied per session.- Since:
- 5.1
- Author:
- Rossen Stoyanchev
-
Field Summary
Fields inherited from interface org.springframework.messaging.MessageChannel
INDEFINITE_TIMEOUT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
configureInterceptor
(MessageChannel channel, boolean preserveOrder) Install or remove anExecutorChannelInterceptor
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 aMessage
to this channel.boolean
Send a message, blocking until either the message is accepted or the specified timeout period elapses.static boolean
supportsOrderedMessages
(MessageChannel channel) Whether the channel has beenconfigured
with an interceptor for sequential handling.
-
Constructor Details
-
OrderedMessageChannelDecorator
-
-
Method Details
-
send
Description copied from interface:MessageChannel
Send aMessage
to this channel. If the message is sent successfully, the method returnstrue
. If the message cannot be sent due to a non-fatal reason, the method returnsfalse
. 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)
.- Specified by:
send
in interfaceMessageChannel
- Parameters:
message
- the message to send- Returns:
- whether the message was sent
-
send
Description copied from interface:MessageChannel
Send a message, blocking until either the message is accepted or the specified timeout period elapses.- Specified by:
send
in interfaceMessageChannel
- Parameters:
message
- the message to sendtimeout
- the timeout in milliseconds orMessageChannel.INDEFINITE_TIMEOUT
- Returns:
true
if the message is sent,false
if not including a timeout of an interrupt of the send
-
configureInterceptor
Install or remove anExecutorChannelInterceptor
that invokes a completion task, if found in the headers of the message.- Parameters:
channel
- the channel to configurepreserveOrder
- whether preserve the order or publication; when "true" an interceptor is inserted, when "false" it removed.
-
supportsOrderedMessages
Whether the channel has beenconfigured
with an interceptor for sequential handling.- Since:
- 6.1
-
getNextMessageTask
Obtain the task to release the next message, if found.
-