org.springframework.integration.channel
Class QueueChannel

java.lang.Object
  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.BeanNameAware, PollableChannel, 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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
 
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 getMesssageCount()
           
 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, getInterceptors, getName, send, send, setBeanName, setInterceptors, 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.core.MessageChannel
getName, send, send
 

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()
Description copied from interface: PollableChannel
Remove all Messages from this channel.


purge

public java.util.List<Message<?>> purge(MessageSelector selector)
Description copied from interface: PollableChannel
Remove any Messages that are not accepted by the provided selector.


getMesssageCount

public int getMesssageCount()

getRemainingCapacity

public int getRemainingCapacity()