@ManagedResource @IntegrationManagedResource public class RedisQueueMessageDrivenEndpoint extends MessageProducerSupport implements ApplicationEventPublisherAware, BeanClassLoaderAware
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_RECEIVE_TIMEOUT |
static long |
DEFAULT_RECOVERY_INTERVAL |
lifecycleCondition, lifecycleLock
EXPRESSION_PARSER, logger
DEFAULT_PHASE
Constructor and Description |
---|
RedisQueueMessageDrivenEndpoint(String queueName,
RedisConnectionFactory connectionFactory) |
Modifier and Type | Method and Description |
---|---|
void |
clearQueue()
Clear the Redis Queue specified by
boundListOperations . |
protected void |
doStart()
Take no action by default.
|
protected void |
doStop()
Take no action by default.
|
protected void |
doStop(Runnable callback)
Stop the component and invoke callback.
|
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
long |
getQueueSize()
Returns the size of the Queue specified by
boundListOperations . |
boolean |
isListening() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setBeanClassLoader(ClassLoader beanClassLoader) |
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 serialized
Message ?. |
void |
setReceiveTimeout(long receiveTimeout)
This timeout (milliseconds) is used when retrieving elements from the queue
specified by
boundListOperations . |
void |
setRecoveryInterval(long recoveryInterval) |
void |
setRightPop(boolean rightPop)
Specify if
POP operation from Redis List should be BRPOP or BLPOP . |
void |
setSerializer(RedisSerializer<?> serializer) |
void |
setTaskExecutor(Executor taskExecutor) |
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher
destroy, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBeanName, getComponentName
public static final long DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECOVERY_INTERVAL
public RedisQueueMessageDrivenEndpoint(String queueName, RedisConnectionFactory connectionFactory)
queueName
- Must not be an empty StringconnectionFactory
- Must not be nullpublic void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
public void setBeanClassLoader(ClassLoader beanClassLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
public void setSerializer(RedisSerializer<?> serializer)
public void setExpectMessage(boolean expectMessage)
Message
?. expectMessage
defaults 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.expectMessage
- Defaults to falsepublic void setReceiveTimeout(long receiveTimeout)
boundListOperations
.
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
receiveTimeout
- Must be non-negative. Specified in milliseconds.public void setTaskExecutor(Executor taskExecutor)
public void setRecoveryInterval(long recoveryInterval)
public void setRightPop(boolean rightPop)
POP
operation from Redis List should be BRPOP
or BLPOP
.rightPop
- the BRPOP
flag. Defaults to true
.protected void onInit()
IntegrationObjectSupport
onInit
in class MessageProducerSupport
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
protected void doStart()
MessageProducerSupport
doStart
in class MessageProducerSupport
protected void doStop(Runnable callback)
AbstractEndpoint
doStop
in class AbstractEndpoint
callback
- the Runnable to invoke.protected void doStop()
MessageProducerSupport
doStop
in class MessageProducerSupport
public boolean isListening()
@ManagedMetric public long getQueueSize()
boundListOperations
. The queue is
represented by a Redis list. If the queue does not exist 0
is returned. See also https://redis.io/commands/llen@ManagedOperation public void clearQueue()
boundListOperations
.