Class PollingConsumer
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.AbstractPollingEndpoint
org.springframework.integration.endpoint.PollingConsumer
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,ExpressionCapable,IntegrationConsumer,NamedComponent,ManageableLifecycle,ManageableSmartLifecycle
Message Endpoint that connects any
MessageHandler implementation
to a PollableChannel.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longA default receive timeout as 1000L milliseconds.Fields inherited from class org.springframework.integration.endpoint.AbstractPollingEndpoint
DEFAULT_POLLING_PERIODFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionPollingConsumer(org.springframework.messaging.PollableChannel inputChannel, org.springframework.messaging.MessageHandler handler) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()Subclasses must implement this method with the start behavior.protected voiddoStop()Subclasses must implement this method with the stop behavior.org.springframework.messaging.MessageHandlerReturn the consumer's handler.org.springframework.messaging.MessageChannelReturn the input channel.org.springframework.messaging.MessageChannelReturn the output channel (may be null).protected Objectprotected StringReturn the key under which the resource will be made available as an attribute on theIntegrationResourceHolder.protected ObjectReturn a resource (MessageSource etc.) to bind when using transaction synchronization.protected voidhandleMessage(org.springframework.messaging.Message<?> message) Handle a message.protected booleanprotected org.springframework.messaging.Message<?>Obtain the next message (if one is available).protected voidsetReceiveMessageSource(Object source) voidsetReceiveTimeout(long receiveTimeout) Methods inherited from class org.springframework.integration.endpoint.AbstractPollingEndpoint
applyReceiveOnlyAdviceChain, getBeanClassLoader, getDefaultErrorChannel, getMaxMessagesPerPoll, getPollingFlux, getTaskExecutor, isReceiveOnlyAdvice, isSyncExecutor, onInit, setAdviceChain, setBeanClassLoader, setErrorHandler, setMaxMessagesPerPoll, setTaskExecutor, setTransactionSynchronizationFactory, setTriggerMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, 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.context.NamedComponent
getBeanName, getComponentName, getComponentType
-
Field Details
-
DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECEIVE_TIMEOUTA default receive timeout as 1000L milliseconds.- See Also:
-
-
Constructor Details
-
PollingConsumer
public PollingConsumer(org.springframework.messaging.PollableChannel inputChannel, org.springframework.messaging.MessageHandler handler)
-
-
Method Details
-
setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout) -
getInputChannel
public org.springframework.messaging.MessageChannel getInputChannel()Description copied from interface:IntegrationConsumerReturn the input channel.- Specified by:
getInputChannelin interfaceIntegrationConsumer- Returns:
- the input channel.
-
getOutputChannel
public org.springframework.messaging.MessageChannel getOutputChannel()Description copied from interface:IntegrationConsumerReturn the output channel (may be null).- Specified by:
getOutputChannelin interfaceIntegrationConsumer- Returns:
- the output channel.
-
getHandler
public org.springframework.messaging.MessageHandler getHandler()Description copied from interface:IntegrationConsumerReturn the consumer's handler.- Specified by:
getHandlerin interfaceIntegrationConsumer- Returns:
- the handler.
-
getReceiveMessageSource
- Overrides:
getReceiveMessageSourcein classAbstractPollingEndpoint
-
setReceiveMessageSource
- Overrides:
setReceiveMessageSourcein classAbstractPollingEndpoint
-
isReactive
protected boolean isReactive()- Overrides:
isReactivein classAbstractPollingEndpoint
-
doStart
protected void doStart()Description copied from class:AbstractEndpointSubclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Overrides:
doStartin classAbstractPollingEndpoint
-
doStop
protected void doStop()Description copied from class:AbstractEndpointSubclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock.- Overrides:
doStopin classAbstractPollingEndpoint
-
handleMessage
protected void handleMessage(org.springframework.messaging.Message<?> message) Description copied from class:AbstractPollingEndpointHandle a message.- Specified by:
handleMessagein classAbstractPollingEndpoint- Parameters:
message- The message.
-
receiveMessage
protected org.springframework.messaging.Message<?> receiveMessage()Description copied from class:AbstractPollingEndpointObtain the next message (if one is available). MAY return null if no message is immediately available.- Specified by:
receiveMessagein classAbstractPollingEndpoint- Returns:
- The message or null.
-
getResourceToBind
Description copied from class:AbstractPollingEndpointReturn a resource (MessageSource etc.) to bind when using transaction synchronization.- Overrides:
getResourceToBindin classAbstractPollingEndpoint- Returns:
- The resource, or null if transaction synchronization is not required.
-
getResourceKey
Description copied from class:AbstractPollingEndpointReturn the key under which the resource will be made available as an attribute on theIntegrationResourceHolder. The defaultExpressionEvaluatingTransactionSynchronizationProcessormakes this attribute available as a variable in SpEL expressions.- Overrides:
getResourceKeyin classAbstractPollingEndpoint- Returns:
- The key, or null (default) if the resource shouldn't be made available as a attribute.
-