Class AbstractPollableChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractPollableChannel
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ExecutorChannelInterceptorAware
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageChannel
,PollableChannel
,InterceptableChannel
- Direct Known Subclasses:
QueueChannel
public abstract class AbstractPollableChannel
extends AbstractMessageChannel
implements PollableChannel, ExecutorChannelInterceptorAware
Base class for all pollable channels.
- Author:
- Mark Fisher, Artem Bilan, Gary Russell, Artem Bilan, Trung Pham
-
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.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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addInterceptor
(int index, ChannelInterceptor interceptor) Add a channel interceptor to the specified index of the list.void
addInterceptor
(ChannelInterceptor interceptor) Add a channel interceptor to the end of the list.protected abstract Message<?>
doReceive
(long timeout) Subclasses must implement this method.Return a pattern type this component implements.boolean
Message<?>
receive()
Receive the first available message from this channel.Message<?>
receive
(long timeout) Receive the first available message from this channel.removeInterceptor
(int index) boolean
removeInterceptor
(ChannelInterceptor interceptor) void
setInterceptors
(List<ChannelInterceptor> interceptors) Set the list of channel interceptors.Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
destroy, doSend, getComponentType, getFullChannelName, getIChannelInterceptorList, getInterceptors, getMetricsCaptor, getOverrides, isLoggingEnabled, onInit, registerMetricsCaptor, send, send, setDatatypes, setLoggingEnabled, setMessageConverter, 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
-
AbstractPollableChannel
public AbstractPollableChannel()
-
-
Method Details
-
getIntegrationPatternType
Description copied from interface:IntegrationPattern
Return a pattern type this component implements.- Specified by:
getIntegrationPatternType
in interfaceIntegrationPattern
- Overrides:
getIntegrationPatternType
in classAbstractMessageChannel
- Returns:
- the
IntegrationPatternType
this component implements.
-
receive
Receive the first available message from this channel. If the channel contains no messages, this method will block.- Specified by:
receive
in interfacePollableChannel
- Returns:
- the first available message or
null
if the receiving thread is interrupted.
-
receive
Receive the first available message from this channel. If the channel contains no messages, this method will block until the allotted timeout elapses. If the specified timeout is 0, the method will return immediately. If less than zero, it will block indefinitely (seereceive()
).- Specified by:
receive
in interfacePollableChannel
- Parameters:
timeout
- the timeout in milliseconds- Returns:
- the first available message or
null
if no message is available within the allotted time or the receiving thread is interrupted.
-
setInterceptors
Description copied from class:AbstractMessageChannel
Set the list of channel interceptors. This will clear any existing interceptors.- Specified by:
setInterceptors
in interfaceInterceptableChannel
- Overrides:
setInterceptors
in classAbstractMessageChannel
- Parameters:
interceptors
- The list of interceptors.
-
addInterceptor
Description copied from class:AbstractMessageChannel
Add a channel interceptor to the end of the list.- Specified by:
addInterceptor
in interfaceInterceptableChannel
- Overrides:
addInterceptor
in classAbstractMessageChannel
- Parameters:
interceptor
- The interceptor.
-
addInterceptor
Description copied from class:AbstractMessageChannel
Add a channel interceptor to the specified index of the list.- Specified by:
addInterceptor
in interfaceInterceptableChannel
- Overrides:
addInterceptor
in classAbstractMessageChannel
- Parameters:
index
- The index to add interceptor.interceptor
- The interceptor.
-
removeInterceptor
- Specified by:
removeInterceptor
in interfaceInterceptableChannel
- Overrides:
removeInterceptor
in classAbstractMessageChannel
-
removeInterceptor
- Specified by:
removeInterceptor
in interfaceInterceptableChannel
- Overrides:
removeInterceptor
in classAbstractMessageChannel
-
hasExecutorInterceptors
public boolean hasExecutorInterceptors()- Specified by:
hasExecutorInterceptors
in interfaceExecutorChannelInterceptorAware
-
doReceive
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.- Parameters:
timeout
- The timeout.- Returns:
- The message, or null.
-