Class RedisQueueInboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.redis.inbound.RedisQueueInboundGateway
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
@ManagedResource
@IntegrationManagedResource
public class RedisQueueInboundGateway
extends MessagingGatewaySupport
implements ApplicationEventPublisherAware, BeanClassLoaderAware
- Since:
- 4.1
- Author:
- David Liu, Artem Bilan, Gary Russell, Matthias Jeschke
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
MessagingGatewaySupport.ConvertingMessagingTemplate
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
static final long
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplate
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
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.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionRedisQueueInboundGateway
(String queueName, RedisConnectionFactory connectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear the Redis Queue specified byboundListOperations
.protected void
doStart()
Subclasses must implement this method with the start behavior.protected void
doStop()
Subclasses must implement this method with the stop behavior.protected void
Stop the component and invoke callback.Subclasses may implement this method to provide component type information.long
Returns the size of the Queue specified byboundListOperations
.boolean
protected void
onInit()
Subclasses may implement this for initialization logic.void
setApplicationEventPublisher
(ApplicationEventPublisher applicationEventPublisher) void
setBeanClassLoader
(ClassLoader beanClassLoader) void
setExtractPayload
(boolean extractPayload) void
setReceiveTimeout
(long receiveTimeout) This timeout (milliseconds) is used when retrieving elements from the queue specified byboundListOperations
.void
setRecoveryInterval
(long recoveryInterval) void
setSerializer
(RedisSerializer<?> serializer) void
setTaskExecutor
(Executor taskExecutor) Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, isObserved, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerObservationRegistry, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setObservationConvention, setReceiverObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrack
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, 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
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECEIVE_TIMEOUT- See Also:
-
DEFAULT_RECOVERY_INTERVAL
public static final long DEFAULT_RECOVERY_INTERVAL- See Also:
-
-
Constructor Details
-
RedisQueueInboundGateway
- Parameters:
queueName
- Must not be an empty StringconnectionFactory
- Must not be null
-
-
Method Details
-
setExtractPayload
public void setExtractPayload(boolean extractPayload) -
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
setSerializer
-
setReceiveTimeout
public 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
1000
See also: https://redis.io/commands/brpop
- Parameters:
receiveTimeout
- Must be non-negative. Specified in milliseconds.
-
setTaskExecutor
-
setRecoveryInterval
public void setRecoveryInterval(long recoveryInterval) -
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classMessagingGatewaySupport
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessagingGatewaySupport
-
doStart
protected void doStart()Description copied from class:AbstractEndpoint
Subclasses must implement this method with the start behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock
.- Overrides:
doStart
in classMessagingGatewaySupport
-
doStop
Description copied from class:AbstractEndpoint
Stop the component and invoke callback.- Overrides:
doStop
in classAbstractEndpoint
- Parameters:
callback
- the Runnable to invoke.
-
doStop
protected void doStop()Description copied from class:AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding theAbstractEndpoint.lifecycleLock
.- Overrides:
doStop
in classMessagingGatewaySupport
-
isListening
public boolean isListening() -
getQueueSize
Returns the size of the Queue specified byboundListOperations
. The queue is represented by a Redis list. If the queue does not exist0
is returned. See also https://redis.io/commands/llen- Returns:
- Size of the queue. Never negative.
-
clearQueue
Clear the Redis Queue specified byboundListOperations
.
-