Class QueueChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractPollableChannel
org.springframework.integration.channel.QueueChannel
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- ExecutorChannelInterceptorAware,- QueueChannelOperations,- ComponentSourceAware,- ExpressionCapable,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageChannel,- PollableChannel,- InterceptableChannel
- Direct Known Subclasses:
- PriorityChannel,- RendezvousChannel
Simple implementation of a message channel. Each 
Message is placed in
 a BlockingQueue whose capacity may be specified upon construction.
 The capacity must be a positive integer value. For a zero-capacity version
 based upon a SynchronousQueue, consider the
 RendezvousChannel.- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannelAbstractMessageChannel.ChannelInterceptorListNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsFields inherited from class org.springframework.integration.channel.AbstractMessageChannelinterceptors, metersFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.messaging.MessageChannelINDEFINITE_TIMEOUT
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a channel with "unbounded" queue capacity.QueueChannel(int capacity) Create a channel with the specified queue capacity.QueueChannel(Queue<Message<?>> queue) Create a channel with the specified queue.
- 
Method SummaryModifier and TypeMethodDescriptionclear()Remove allMessagesfrom this channel.voiddestroy()protected Message<?> doReceive(long timeout) Subclasses must implement this method.protected booleanSubclasses must implement this method.intObtain the current number of queuedMessagesin this channel.intObtain the remaining capacity of this channel.purge(MessageSelector selector) Remove anyMessagesthat are not accepted by the provided selector.voidregisterMetricsCaptor(MetricsCaptor metricsCaptor) Inject aMetricsCaptor.Methods inherited from class org.springframework.integration.channel.AbstractPollableChanneladdInterceptor, addInterceptor, getIntegrationPatternType, hasExecutorInterceptors, receive, receive, removeInterceptor, removeInterceptor, setInterceptorsMethods inherited from class org.springframework.integration.channel.AbstractMessageChannelgetComponentType, getFullChannelName, getIChannelInterceptorList, getInterceptors, getMetricsCaptor, getOverrides, isApplicationRunning, isLoggingEnabled, isObserved, onInit, registerObservationRegistry, send, send, setDatatypes, setLoggingEnabled, setMessageConverter, setObservationConvention, setShouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetManagedName, getManagedType, getThisAs, setManagedName, setManagedTypeMethods inherited from interface org.springframework.messaging.support.InterceptableChannelgetInterceptorsMethods inherited from interface org.springframework.messaging.MessageChannelsend, sendMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Field Details- 
queueSemaphore
 
- 
- 
Constructor Details- 
QueueChannel
- 
QueueChannelpublic QueueChannel(int capacity) Create a channel with the specified queue capacity.- Parameters:
- capacity- The capacity.
 
- 
QueueChannelpublic QueueChannel()Create a channel with "unbounded" queue capacity. The actual capacity value isInteger.MAX_VALUE. Note that a bounded queue is recommended, since an unbounded queue may lead to OutOfMemoryErrors.
 
- 
- 
Method Details- 
registerMetricsCaptorDescription copied from interface:IntegrationManagementInject aMetricsCaptor. Ignored ifObservationRegistryis provided.- Specified by:
- registerMetricsCaptorin interface- IntegrationManagement
- Overrides:
- registerMetricsCaptorin class- AbstractMessageChannel
- Parameters:
- metricsCaptor- the captor.
- See Also:
 
- 
doSendDescription 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.- Specified by:
- doSendin class- AbstractMessageChannel
- Parameters:
- message- The message.
- timeout- The timeout.
- Returns:
- true if the sendwas successful.
 
- 
doReceiveDescription 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.- Specified by:
- doReceivein class- AbstractPollableChannel
- Parameters:
- timeout- The timeout.
- Returns:
- The message, or null.
 
- 
clearDescription copied from interface:QueueChannelOperationsRemove allMessagesfrom this channel.- Specified by:
- clearin interface- QueueChannelOperations
- Returns:
- The messages that were removed.
 
- 
purgeDescription copied from interface:QueueChannelOperationsRemove anyMessagesthat are not accepted by the provided selector.- Specified by:
- purgein interface- QueueChannelOperations
- Parameters:
- selector- The message selector.
- Returns:
- The list of messages that were purged.
 
- 
getQueueSizepublic int getQueueSize()Description copied from interface:QueueChannelOperationsObtain the current number of queuedMessagesin this channel.- Specified by:
- getQueueSizein interface- QueueChannelOperations
- Returns:
- The current number of queued Messagesin this channel.
 
- 
getRemainingCapacitypublic int getRemainingCapacity()Description copied from interface:QueueChannelOperationsObtain the remaining capacity of this channel.- Specified by:
- getRemainingCapacityin interface- QueueChannelOperations
- Returns:
- The remaining capacity of this channel.
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Specified by:
- destroyin interface- IntegrationManagement
- Overrides:
- destroyin class- AbstractMessageChannel
 
 
-