org.springframework.integration.channel
Class PriorityChannel

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
                  extended by org.springframework.integration.channel.PriorityChannel
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, NamedComponent, PollableChannel, TrackableComponent, MessageChannel

public class PriorityChannel
extends QueueChannel

A message channel that prioritizes messages based on a Comparator. The default comparator is based upon the message header's 'priority'.


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
PriorityChannel()
          Create a channel with an unbounded queue.
PriorityChannel(java.util.Comparator<Message<?>> comparator)
          Create a channel with an unbounded queue.
PriorityChannel(int capacity)
          Create a channel with the specified queue capacity.
PriorityChannel(int capacity, java.util.Comparator<Message<?>> comparator)
          Create a channel with the specified queue capacity.
 
Method Summary
protected  Message<?> doReceive(long timeout)
          Subclasses must implement this method.
protected  boolean doSend(Message<?> message, long timeout)
          Subclasses must implement this method.
 
Methods inherited from class org.springframework.integration.channel.QueueChannel
clear, getQueueSize, getRemainingCapacity, purge
 
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

PriorityChannel

public PriorityChannel(int capacity,
                       java.util.Comparator<Message<?>> comparator)
Create a channel with the specified queue capacity. If the capacity is a non-positive value, the queue will be unbounded. Message priority will be determined by the provided Comparator. If the comparator is null, the priority will be based upon the value of MessageHeaders.getPriority().


PriorityChannel

public PriorityChannel(int capacity)
Create a channel with the specified queue capacity. Message priority will be based upon the value of MessageHeaders.getPriority().


PriorityChannel

public PriorityChannel(java.util.Comparator<Message<?>> comparator)
Create a channel with an unbounded queue. Message priority will be determined by the provided Comparator. If the comparator is null, the priority will be based upon the value of MessageHeaders.getPriority().


PriorityChannel

public PriorityChannel()
Create a channel with an unbounded queue. Message priority will be based on the value of MessageHeaders.getPriority().

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.

Overrides:
doSend in class QueueChannel

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.

Overrides:
doReceive in class QueueChannel