org.springframework.integration.channel
Class QueueChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractPollableChannel
org.springframework.integration.channel.QueueChannel
- All Implemented Interfaces:
- org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, NamedComponent, PollableChannel, TrackableComponent, MessageChannel
- Direct Known Subclasses:
- PriorityChannel, RendezvousChannel
public class QueueChannel
- extends AbstractPollableChannel
Simple implementation of a message channel. Each 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
.
- Author:
- Mark Fisher, Oleg Zhurakousky
Constructor Summary |
QueueChannel()
Create a channel with "unbounded" queue capacity. |
QueueChannel(java.util.concurrent.BlockingQueue<Message<?>> queue)
Create a channel with the specified queue. |
QueueChannel(int capacity)
Create a channel with the specified queue capacity. |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
QueueChannel
public QueueChannel(java.util.concurrent.BlockingQueue<Message<?>> queue)
- Create a channel with the specified queue.
QueueChannel
public QueueChannel(int capacity)
- Create a channel with the specified queue capacity.
QueueChannel
public QueueChannel()
- Create a channel with "unbounded" queue capacity. The actual capacity value is
Integer.MAX_VALUE
. Note that a bounded queue is recommended, since an
unbounded queue may lead to OutOfMemoryErrors.
doSend
protected boolean doSend(Message<?> message,
long timeout)
- Description copied from class:
AbstractMessageChannel
- Subclasses must implement this method. A non-negative timeout indicates
how long to wait if the channel is at capacity (if the value is 0, it
must return immediately with or without success). A negative timeout
value indicates that the method should block until either the message is
accepted or the blocking thread is interrupted.
- Specified by:
doSend
in class AbstractMessageChannel
doReceive
protected Message<?> doReceive(long timeout)
- Description copied from class:
AbstractPollableChannel
- Subclasses must implement this method. A non-negative timeout indicates
how long to wait if the channel is empty (if the value is 0, it must
return immediately with or without success). A negative timeout value
indicates that the method should block until either a message is
available or the blocking thread is interrupted.
- Specified by:
doReceive
in class AbstractPollableChannel
clear
public java.util.List<Message<?>> clear()
- Remove all
Messages
from this channel.
purge
public java.util.List<Message<?>> purge(MessageSelector selector)
- Remove any
Messages
that are not accepted by the provided selector.
getQueueSize
public int getQueueSize()
getRemainingCapacity
public int getRemainingCapacity()