org.springframework.integration.channel
Class QueueChannel

java.lang.Object
  extended by org.springframework.integration.channel.AbstractMessageChannel
      extended by org.springframework.integration.channel.QueueChannel
All Implemented Interfaces:
org.springframework.beans.factory.BeanNameAware, MessageChannel, BlockingSource, BlockingTarget, Source, Target
Direct Known Subclasses:
PriorityChannel, RendezvousChannel

public class QueueChannel
extends AbstractMessageChannel

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

Field Summary
static int DEFAULT_CAPACITY
           
private  java.util.concurrent.BlockingQueue<Message<?>> queue
           
 
Constructor Summary
QueueChannel()
          Create a channel with the default queue capacity.
QueueChannel(java.util.concurrent.BlockingQueue<Message<?>> queue, DispatcherPolicy dispatcherPolicy)
          Create a channel with the specified queue and dispatcher policy.
QueueChannel(int capacity)
          Create a channel with the specified queue capacity.
QueueChannel(int capacity, DispatcherPolicy dispatcherPolicy)
          Create a channel with the specified queue capacity and dispatcher policy.
 
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.
 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.AbstractMessageChannel
addInterceptor, getDispatcherPolicy, getName, receive, receive, send, send, setBeanName, setInterceptors, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CAPACITY

public static final int DEFAULT_CAPACITY
See Also:
Constant Field Values

queue

private final java.util.concurrent.BlockingQueue<Message<?>> queue
Constructor Detail

QueueChannel

public QueueChannel(java.util.concurrent.BlockingQueue<Message<?>> queue,
                    DispatcherPolicy dispatcherPolicy)
Create a channel with the specified queue and dispatcher policy.


QueueChannel

public QueueChannel(int capacity,
                    DispatcherPolicy dispatcherPolicy)
Create a channel with the specified queue capacity and dispatcher policy.


QueueChannel

public QueueChannel(int capacity)
Create a channel with the specified queue capacity.


QueueChannel

public QueueChannel()
Create a channel with the default queue capacity.

See Also:
DEFAULT_CAPACITY
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: AbstractMessageChannel
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 AbstractMessageChannel

clear

public java.util.List<Message<?>> clear()
Description copied from interface: MessageChannel
Remove all Messages from this channel.


purge

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