@ManagedResource
public class RedisQueueMessageDrivenEndpoint
extends org.springframework.integration.endpoint.MessageProducerSupport
implements org.springframework.context.ApplicationEventPublisherAware
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_RECEIVE_TIMEOUT |
static long |
DEFAULT_RECOVERY_INTERVAL |
Constructor and Description |
---|
RedisQueueMessageDrivenEndpoint(java.lang.String queueName,
org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory) |
Modifier and Type | Method and Description |
---|---|
void |
clearQueue()
Clear the Redis Queue specified by
boundListOperations . |
protected void |
doStart() |
protected void |
doStop() |
java.lang.String |
getComponentType() |
long |
getQueueSize()
Returns the size of the Queue specified by
boundListOperations . |
boolean |
isListening() |
protected void |
onInit() |
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setErrorChannel(org.springframework.messaging.MessageChannel errorChannel) |
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 |
setSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> serializer) |
void |
setStopTimeout(long stopTimeout) |
void |
setTaskExecutor(java.util.concurrent.Executor taskExecutor) |
sendMessage, setOutputChannel, setSendTimeout, setShouldTrack
doStop, getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
afterPropertiesSet, getApplicationContext, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setMessageBuilderFactory, toString
public static final long DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECOVERY_INTERVAL
public RedisQueueMessageDrivenEndpoint(java.lang.String queueName, org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
queueName
- Must not be an empty StringconnectionFactory
- Must not be nullpublic void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface org.springframework.context.ApplicationEventPublisherAware
public void setSerializer(org.springframework.data.redis.serializer.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: http://redis.io/commands/brpop
receiveTimeout
- Must be non-negative. Specified in milliseconds.public void setStopTimeout(long stopTimeout)
stopTimeout
- the timeout to block doStop()
until the last message will be processed
or this timeout is reached. Should be less then or equal to receiveTimeout
public void setTaskExecutor(java.util.concurrent.Executor taskExecutor)
public void setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
setErrorChannel
in class org.springframework.integration.endpoint.MessageProducerSupport
public void setRecoveryInterval(long recoveryInterval)
protected void onInit()
onInit
in class org.springframework.integration.endpoint.MessageProducerSupport
public java.lang.String getComponentType()
getComponentType
in interface org.springframework.integration.support.context.NamedComponent
getComponentType
in class org.springframework.integration.context.IntegrationObjectSupport
protected void doStart()
doStart
in class org.springframework.integration.endpoint.MessageProducerSupport
protected void doStop()
doStop
in class org.springframework.integration.endpoint.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 http://redis.io/commands/llen@ManagedOperation public void clearQueue()
boundListOperations
.