Spring Integration

org.springframework.integration.channel
Class QueueChannel

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.channel.AbstractMessageChannel
          extended by org.springframework.integration.channel.AbstractPollableChannel
              extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
 
Field Summary
 
Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel
logger
 
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.
 
Method Summary
 java.util.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()
           
 java.util.List<Message<?>> purge(MessageSelector selector)
          Remove any Messages that are not accepted by the provided selector.
 
Methods inherited from class org.springframework.integration.channel.AbstractPollableChannel
receive, receive
 
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, getComponentType, getInterceptors, send, send, setConversionService, setDatatypes, setInterceptors, setShouldTrack
 
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
 
Methods inherited from interface org.springframework.integration.MessageChannel
send, send
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

Constructor Detail

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.

Method Detail

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()

Spring Integration