org.springframework.integration.channel
Class PriorityChannel
java.lang.Object
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractPollableChannel
org.springframework.integration.channel.QueueChannel
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
Field Summary |
private java.util.concurrent.Semaphore |
semaphore
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
semaphore
private final java.util.concurrent.Semaphore semaphore
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()
.
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