org.springframework.integration.channel
Class PriorityChannel

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

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
           
 
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 and default dispatcher policy.
PriorityChannel(int capacity, DispatcherPolicy dispatcherPolicy)
          Create a channel with the specified queue capacity and dispatcher policy.
PriorityChannel(int capacity, DispatcherPolicy dispatcherPolicy, java.util.Comparator<Message<?>> comparator)
          Create a channel with the specified queue capacity and dispatcher policy.
 
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.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

semaphore

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

PriorityChannel

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


PriorityChannel

public PriorityChannel(int capacity,
                       DispatcherPolicy dispatcherPolicy)
Create a channel with the specified queue capacity and dispatcher policy. Priority will be based upon the value of MessageHeader.getPriority().


PriorityChannel

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

Overrides:
doReceive in class QueueChannel