class OrderedMessageSender extends java.lang.Object implements MessageChannel
ExecutorSubscribableChannel
, one at a time.
The channel must have been configured with configureOutboundChannel(org.springframework.messaging.MessageChannel, boolean)
.Modifier and Type | Class and Description |
---|---|
private static class |
OrderedMessageSender.CallbackInterceptor |
Modifier and Type | Field and Description |
---|---|
private MessageChannel |
channel |
(package private) static java.lang.String |
COMPLETION_TASK_HEADER |
private Log |
logger |
private java.util.Queue<Message<?>> |
messages |
private java.util.concurrent.atomic.AtomicBoolean |
sendInProgress |
INDEFINITE_TIMEOUT
Constructor and Description |
---|
OrderedMessageSender(MessageChannel channel,
Log logger) |
Modifier and Type | Method and Description |
---|---|
private void |
addCompletionCallback(Message<?> msg) |
(package private) static void |
configureOutboundChannel(MessageChannel channel,
boolean preservePublishOrder)
Install or remove an
ExecutorChannelInterceptor that invokes a
completion task once the message is handled. |
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.
|
private void |
sendNextMessage() |
private void |
trySend() |
static final java.lang.String COMPLETION_TASK_HEADER
private final MessageChannel channel
private final Log logger
private final java.util.Queue<Message<?>> messages
private final java.util.concurrent.atomic.AtomicBoolean sendInProgress
public OrderedMessageSender(MessageChannel channel, Log logger)
public boolean send(Message<?> message)
MessageChannel
Message
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 MessageChannel
message
- the message to sendpublic boolean send(Message<?> message, long timeout)
MessageChannel
send
in interface MessageChannel
message
- the message to sendtimeout
- the timeout in milliseconds or MessageChannel.INDEFINITE_TIMEOUT
true
if the message is sent, false
if not
including a timeout of an interrupt of the sendprivate void trySend()
private void sendNextMessage()
private void addCompletionCallback(Message<?> msg)
static void configureOutboundChannel(MessageChannel channel, boolean preservePublishOrder)
ExecutorChannelInterceptor
that invokes a
completion task once the message is handled.channel
- the channel to configurepreservePublishOrder
- whether preserve order is on or off based on
which an interceptor is either added or removed.