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:
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.ApplicationEventPublisherAware
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
,org.springframework.integration.context.ExpressionCapable
,org.springframework.integration.IntegrationPattern
,org.springframework.integration.support.context.NamedComponent
,org.springframework.integration.support.management.IntegrationInboundManagement
,org.springframework.integration.support.management.IntegrationManagement
,org.springframework.integration.support.management.ManageableLifecycle
,org.springframework.integration.support.management.ManageableSmartLifecycle
,org.springframework.integration.support.management.TrackableComponent
@ManagedResource
@IntegrationManagedResource
public class RedisQueueInboundGateway
extends org.springframework.integration.gateway.MessagingGatewaySupport
implements org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.BeanClassLoaderAware
- Since:
- 4.1
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_RECEIVE_TIMEOUT
static long
DEFAULT_RECOVERY_INTERVAL
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
-
Constructor Summary
Constructors Constructor Description RedisQueueInboundGateway(java.lang.String queueName, org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
-
Method Summary
Modifier and Type Method Description void
clearQueue()
Clear the Redis Queue specified byboundListOperations
.protected void
doStart()
protected void
doStop()
protected void
doStop(java.lang.Runnable callback)
java.lang.String
getComponentType()
long
getQueueSize()
Returns the size of the Queue specified byboundListOperations
.boolean
isListening()
protected void
onInit()
void
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
void
setBeanClassLoader(java.lang.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(org.springframework.data.redis.serializer.RedisSerializer<?> serializer)
void
setTaskExecutor(java.util.concurrent.Executor taskExecutor)
Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, 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, 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
-
Field Details
-
DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECEIVE_TIMEOUT- See Also:
- Constant Field Values
-
DEFAULT_RECOVERY_INTERVAL
public static final long DEFAULT_RECOVERY_INTERVAL- See Also:
- Constant Field Values
-
-
Constructor Details
-
RedisQueueInboundGateway
public RedisQueueInboundGateway(java.lang.String queueName, org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)- Parameters:
queueName
- Must not be an empty StringconnectionFactory
- Must not be null
-
-
Method Details
-
setExtractPayload
public void setExtractPayload(boolean extractPayload) -
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)- Specified by:
setApplicationEventPublisher
in interfaceorg.springframework.context.ApplicationEventPublisherAware
-
setBeanClassLoader
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)- Specified by:
setBeanClassLoader
in interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setSerializer
public void setSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> serializer) -
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
public void setTaskExecutor(java.util.concurrent.Executor taskExecutor) -
setRecoveryInterval
public void setRecoveryInterval(long recoveryInterval) -
onInit
protected void onInit()- Overrides:
onInit
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentType
in interfaceorg.springframework.integration.support.context.NamedComponent
- Overrides:
getComponentType
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStart
protected void doStart()- Overrides:
doStart
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
doStop
protected void doStop(java.lang.Runnable callback)- Overrides:
doStop
in classorg.springframework.integration.endpoint.AbstractEndpoint
-
doStop
protected void doStop()- Overrides:
doStop
in classorg.springframework.integration.gateway.MessagingGatewaySupport
-
isListening
public boolean isListening() -
getQueueSize
@ManagedMetric public long 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
@ManagedOperation public void clearQueue()Clear the Redis Queue specified byboundListOperations
.
-