public class QueueChannel extends AbstractPollableChannel implements QueueChannelOperations
Message
is placed in
a BlockingQueue
whose capacity may be specified upon construction.
The capacity must be a positive integer value. For a zero-capacity version
based upon a SynchronousQueue
, consider the
RendezvousChannel
.AbstractMessageChannel.ChannelInterceptorList
logger
INDEFINITE_TIMEOUT
Constructor and Description |
---|
QueueChannel()
Create a channel with "unbounded" queue capacity.
|
QueueChannel(BlockingQueue<Message<?>> queue)
Create a channel with the specified queue.
|
QueueChannel(int capacity)
Create a channel with the specified queue capacity.
|
Modifier and Type | Method and Description |
---|---|
List<Message<?>> |
clear()
Remove all
Messages from this channel. |
protected Message<?> |
doReceive(long timeout)
Subclasses must implement this method.
|
protected boolean |
doSend(Message<?> message,
long timeout)
Subclasses must implement this method.
|
int |
getQueueSize() |
int |
getRemainingCapacity() |
List<Message<?>> |
purge(MessageSelector selector)
Remove any
Messages that are not accepted by the provided selector. |
receive, receive
addInterceptor, addInterceptor, getChannelInterceptors, getComponentType, getFullChannelName, getInterceptors, onInit, send, send, setConversionService, setDatatypes, setInterceptors, setMessageConverter, setShouldTrack
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setMessageBuilderFactory, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
send, send
getComponentName
public QueueChannel(BlockingQueue<Message<?>> queue)
queue
- The queue.public QueueChannel(int capacity)
capacity
- The capacity.public QueueChannel()
Integer.MAX_VALUE
. Note that a bounded queue is recommended, since an
unbounded queue may lead to OutOfMemoryErrors.protected boolean doSend(Message<?> message, long timeout)
AbstractMessageChannel
doSend
in class AbstractMessageChannel
message
- The message.timeout
- The timeout.protected Message<?> doReceive(long timeout)
AbstractPollableChannel
doReceive
in class AbstractPollableChannel
timeout
- The timeout.public List<Message<?>> clear()
QueueChannelOperations
Messages
from this channel.clear
in interface QueueChannelOperations
public List<Message<?>> purge(MessageSelector selector)
QueueChannelOperations
Messages
that are not accepted by the provided selector.purge
in interface QueueChannelOperations
selector
- The message selector.public int getQueueSize()
getQueueSize
in interface QueueChannelOperations
Messages
in this channel.public int getRemainingCapacity()
getRemainingCapacity
in interface QueueChannelOperations