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 prevoius 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigureInterceptor(MessageChannel channel, boolean preserveOrder) Install or remove anExecutorChannelInterceptorthat invokes a completion task, if found in the headers of the message.static RunnablegetNextMessageTask(Message<?> message) Obtain the task to release the next message, if found.booleanSend aMessageto this channel.booleanSend a message, blocking until either the message is accepted or the specified timeout period elapses.
-
Constructor Details
-
OrderedMessageChannelDecorator
-
-
Method Details
-
send
Description copied from interface:MessageChannelSend aMessageto 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:
sendin interfaceMessageChannel- Parameters:
message- the message to send- Returns:
- whether or not the message was sent
-
send
Description copied from interface:MessageChannelSend a message, blocking until either the message is accepted or the specified timeout period elapses.- Specified by:
sendin interfaceMessageChannel- Parameters:
message- the message to sendtimeout- the timeout in milliseconds orMessageChannel.INDEFINITE_TIMEOUT- Returns:
trueif the message is sent,falseif not including a timeout of an interrupt of the send
-
getNextMessageTask
Obtain the task to release the next message, if found. -
configureInterceptor
Install or remove anExecutorChannelInterceptorthat 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.
-