org.springframework.integration.channel
Class PriorityChannel

java.lang.Object
  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:
org.springframework.beans.factory.BeanNameAware, MessageChannel, PollableChannel, BlockingSource, BlockingTarget, MessageSource, MessageTarget, PollableSource

public class PriorityChannel
extends QueueChannel

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

Author:
Mark Fisher

Nested Class Summary
private static class PriorityChannel.MessagePriorityComparator
           
 
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
 
Field Summary
private  java.util.concurrent.Semaphore semaphore
           
 
Fields inherited from class org.springframework.integration.channel.QueueChannel
DEFAULT_CAPACITY
 
Constructor Summary
PriorityChannel()
          Create a channel with the default queue capacity and dispatcher policy.
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, purge
 
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.channel.MessageChannel
getName
 
Methods inherited from interface org.springframework.integration.message.BlockingTarget
send, send
 

Field Detail

semaphore

private final java.util.concurrent.Semaphore semaphore
Constructor Detail

PriorityChannel

public PriorityChannel(int capacity,
                       java.util.Comparator<Message<?>> comparator)
Create a channel with the specified queue capacity. Priority will be based upon the provided PriorityChannel.MessagePriorityComparator.


PriorityChannel

public PriorityChannel(int capacity)
Create a channel with the specified queue capacity. Priority will be based upon the value of MessageHeader#getPriority().


PriorityChannel

public PriorityChannel()
Create a channel with the default queue capacity and dispatcher policy. Priority will be based on the value of MessageHeader#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