Class RedisQueueMessageDrivenEndpoint
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint
- All Implemented Interfaces:
- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- SmartInitializingSingleton,- ApplicationContextAware,- ApplicationEventPublisherAware,- Lifecycle,- Phased,- SmartLifecycle,- ExpressionCapable,- MessageProducer,- IntegrationPattern,- NamedComponent,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
@ManagedResource @IntegrationManagedResource public class RedisQueueMessageDrivenEndpoint extends MessageProducerSupport implements ApplicationEventPublisherAware, BeanClassLoaderAware
- Since:
- 3.0
- Author:
- Mark Fisher, Gunnar Hillert, Artem Bilan, Gary Russell, Rainer Frey, Matthias Jeschke
- 
Field SummaryFields Modifier and Type Field Description static longDEFAULT_RECEIVE_TIMEOUTstatic longDEFAULT_RECOVERY_INTERVALFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructors Constructor Description RedisQueueMessageDrivenEndpoint(String queueName, RedisConnectionFactory connectionFactory)
- 
Method SummaryModifier and Type Method Description voidclearQueue()Clear the Redis Queue specified byboundListOperations.protected voiddoStart()Take no action by default.protected voiddoStop()Take no action by default.protected voiddoStop(Runnable callback)Stop the component and invoke callback.StringgetComponentType()Subclasses may implement this method to provide component type information.longgetQueueSize()Returns the size of the Queue specified byboundListOperations.booleanisListening()protected voidonInit()Subclasses may implement this for initialization logic.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)voidsetBeanClassLoader(ClassLoader beanClassLoader)voidsetExpectMessage(boolean expectMessage)When data is retrieved from the Redis queue, does the returned data represent just the payload for a Message, or does the data represent a serializedMessage?.voidsetReceiveTimeout(long receiveTimeout)This timeout (milliseconds) is used when retrieving elements from the queue specified byboundListOperations.voidsetRecoveryInterval(long recoveryInterval)voidsetRightPop(boolean rightPop)Specify ifPOPoperation from Redis List should beBRPOPorBLPOP.voidsetSerializer(RedisSerializer<?> serializer)voidsetTaskExecutor(Executor taskExecutor)Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupportafterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpointdestroy, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, 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.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Field Details- 
DEFAULT_RECEIVE_TIMEOUTpublic static final long DEFAULT_RECEIVE_TIMEOUT- See Also:
- Constant Field Values
 
- 
DEFAULT_RECOVERY_INTERVALpublic static final long DEFAULT_RECOVERY_INTERVAL- See Also:
- Constant Field Values
 
 
- 
- 
Constructor Details- 
RedisQueueMessageDrivenEndpoint- Parameters:
- queueName- Must not be an empty String
- connectionFactory- Must not be null
 
 
- 
- 
Method Details- 
setApplicationEventPublisher- Specified by:
- setApplicationEventPublisherin interface- ApplicationEventPublisherAware
 
- 
setBeanClassLoader- Specified by:
- setBeanClassLoaderin interface- BeanClassLoaderAware
 
- 
setSerializer
- 
setExpectMessagepublic void setExpectMessage(boolean expectMessage)When data is retrieved from the Redis queue, does the returned data represent just the payload for a Message, or does the data represent a serializedMessage?.expectMessagedefaults to false. This means the retrieved data will be used as the payload for a new Spring Integration Message. Otherwise, the data is deserialized as Spring Integration Message.- Parameters:
- expectMessage- Defaults to false
 
- 
setReceiveTimeoutpublic void setReceiveTimeout(long receiveTimeout)This timeout (milliseconds) is used when retrieving elements from the queue specified byboundListOperations.If the queue does contain elements, the data is retrieved immediately. However, if the queue is empty, the Redis connection is blocked until either an element can be retrieved from the queue or until the specified timeout passes. A timeout of zero can be used to block indefinitely. If not set explicitly the timeout value will default to 1000See also: https://redis.io/commands/brpop - Parameters:
- receiveTimeout- Must be non-negative. Specified in milliseconds.
 
- 
setTaskExecutor
- 
setRecoveryIntervalpublic void setRecoveryInterval(long recoveryInterval)
- 
setRightPoppublic void setRightPop(boolean rightPop)Specify ifPOPoperation from Redis List should beBRPOPorBLPOP.- Parameters:
- rightPop- the- BRPOPflag. Defaults to- true.
- Since:
- 4.3
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- MessageProducerSupport
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- IntegrationObjectSupport
 
- 
doStartprotected void doStart()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.- Overrides:
- doStartin class- MessageProducerSupport
 
- 
doStopDescription copied from class:AbstractEndpointStop the component and invoke callback.- Overrides:
- doStopin class- AbstractEndpoint
- Parameters:
- callback- the Runnable to invoke.
 
- 
doStopprotected void doStop()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
- doStopin class- MessageProducerSupport
 
- 
isListeningpublic boolean isListening()
- 
getQueueSizeReturns the size of the Queue specified byboundListOperations. The queue is represented by a Redis list. If the queue does not exist0is returned. See also https://redis.io/commands/llen- Returns:
- Size of the queue. Never negative.
 
- 
clearQueueClear the Redis Queue specified byboundListOperations.
 
-