Class PriorityChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractPollableChannel
org.springframework.integration.channel.QueueChannel
org.springframework.integration.channel.PriorityChannel
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ExecutorChannelInterceptorAware
,QueueChannelOperations
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageChannel
,PollableChannel
,InterceptableChannel
A message channel that prioritizes messages based on a
Comparator
.
The default comparator is based upon the message header's 'priority'.- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.channel.QueueChannel
queueSemaphore
Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel
interceptors, meters
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.messaging.MessageChannel
INDEFINITE_TIMEOUT
-
Constructor Summary
ConstructorDescriptionCreate a channel with an unbounded queue.PriorityChannel
(int capacity) Create a channel with the specified queue capacity.PriorityChannel
(int capacity, Comparator<Message<?>> comparator) Create a channel with the specified queue capacity.PriorityChannel
(Comparator<Message<?>> comparator) Create a channel with an unbounded queue.PriorityChannel
(MessageGroupQueue messageGroupQueue) Create a channel based on the providedMessageGroupQueue
.PriorityChannel
(PriorityCapableChannelMessageStore messageGroupStore, Object groupId) Create a channel based on the providedPriorityCapableChannelMessageStore
and group id for message store operations. -
Method Summary
Methods inherited from class org.springframework.integration.channel.QueueChannel
clear, destroy, getQueueSize, purge, registerMetricsCaptor
Methods inherited from class org.springframework.integration.channel.AbstractPollableChannel
addInterceptor, addInterceptor, getIntegrationPatternType, hasExecutorInterceptors, receive, receive, removeInterceptor, removeInterceptor, setInterceptors
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
getComponentType, getFullChannelName, getIChannelInterceptorList, getInterceptors, getMetricsCaptor, getOverrides, isLoggingEnabled, isObserved, onInit, registerObservationRegistry, send, send, setDatatypes, setLoggingEnabled, setMessageConverter, setObservationConvention, setShouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, 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.support.management.IntegrationManagement
getManagedName, getManagedType, getThisAs, setManagedName, setManagedType
Methods inherited from interface org.springframework.messaging.support.InterceptableChannel
getInterceptors
Methods inherited from interface org.springframework.messaging.MessageChannel
send, send
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
PriorityChannel
public PriorityChannel()Create a channel with an unbounded queue. Message priority will be based on the value ofStaticMessageHeaderAccessor.getPriority(Message)
. -
PriorityChannel
public PriorityChannel(int capacity) Create a channel with the specified queue capacity. Message priority will be based upon the value ofStaticMessageHeaderAccessor.getPriority(Message)
.- Parameters:
capacity
- The queue capacity.
-
PriorityChannel
Create a channel with an unbounded queue. Message priority will be determined by the providedComparator
. If the comparator isnull
, the priority will be based upon the value ofStaticMessageHeaderAccessor.getPriority(Message)
.- Parameters:
comparator
- The comparator.
-
PriorityChannel
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 providedComparator
. If the comparator isnull
, the priority will be based upon the value ofStaticMessageHeaderAccessor.getPriority(Message)
.- Parameters:
capacity
- The capacity.comparator
- The comparator.
-
PriorityChannel
Create a channel based on the providedPriorityCapableChannelMessageStore
and group id for message store operations.- Parameters:
messageGroupStore
- thePriorityCapableChannelMessageStore
to use.groupId
- to group message for this channel in the message store.- Since:
- 5.0
-
PriorityChannel
Create a channel based on the providedMessageGroupQueue
.- Parameters:
messageGroupQueue
- theMessageGroupQueue
to use.- Since:
- 5.0
-
-
Method Details
-
getRemainingCapacity
public int getRemainingCapacity()Description copied from interface:QueueChannelOperations
Obtain the remaining capacity of this channel.- Specified by:
getRemainingCapacity
in interfaceQueueChannelOperations
- Overrides:
getRemainingCapacity
in classQueueChannel
- Returns:
- The remaining capacity of this channel.
-
doSend
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 classQueueChannel
- Parameters:
message
- The message.timeout
- The timeout.- Returns:
- true if the
send
was successful.
-
doReceive
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 classQueueChannel
- Parameters:
timeout
- The timeout.- Returns:
- The message, or null.
-