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.ChannelInterceptorListNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields inherited from class org.springframework.integration.channel.QueueChannel
queueSemaphoreFields inherited from class org.springframework.integration.channel.AbstractMessageChannel
interceptors, metersFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.messaging.MessageChannel
INDEFINITE_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionCreate 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 providedPriorityCapableChannelMessageStoreand group id for message store operations. -
Method Summary
Methods inherited from class org.springframework.integration.channel.QueueChannel
clear, destroy, getQueueSize, purge, registerMetricsCaptorMethods inherited from class org.springframework.integration.channel.AbstractPollableChannel
addInterceptor, addInterceptor, getIntegrationPatternType, hasExecutorInterceptors, receive, receive, removeInterceptor, removeInterceptor, setInterceptorsMethods inherited from class org.springframework.integration.channel.AbstractMessageChannel
getComponentType, getFullChannelName, getIChannelInterceptorList, getInterceptors, getMetricsCaptor, getOverrides, isLoggingEnabled, isObserved, onInit, registerObservationRegistry, send, send, setDatatypes, setLoggingEnabled, setMessageConverter, setObservationConvention, setShouldTrackMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getThisAs, setManagedName, setManagedTypeMethods inherited from interface org.springframework.messaging.support.InterceptableChannel
getInterceptorsMethods inherited from interface org.springframework.messaging.MessageChannel
send, sendMethods 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 providedPriorityCapableChannelMessageStoreand group id for message store operations.- Parameters:
messageGroupStore- thePriorityCapableChannelMessageStoreto 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- theMessageGroupQueueto use.- Since:
- 5.0
-
-
Method Details
-
getRemainingCapacity
public int getRemainingCapacity()Description copied from interface:QueueChannelOperationsObtain the remaining capacity of this channel.- Specified by:
getRemainingCapacityin interfaceQueueChannelOperations- Overrides:
getRemainingCapacityin classQueueChannel- Returns:
- The remaining capacity of this channel.
-
doSend
Description copied from class:AbstractMessageChannelSubclasses 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:
doSendin classQueueChannel- Parameters:
message- The message.timeout- The timeout.- Returns:
- true if the
sendwas successful.
-
doReceive
Description copied from class:AbstractPollableChannelSubclasses 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:
doReceivein classQueueChannel- Parameters:
timeout- The timeout.- Returns:
- The message, or null.
-