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:
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.beans.factory.SmartInitializingSingleton, 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.core.MessageProducer, 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 RedisQueueMessageDrivenEndpoint extends org.springframework.integration.endpoint.MessageProducerSupport implements org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.BeanClassLoaderAware
Since:
3.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
    static final long
     

    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

    Constructors
    Constructor
    Description
    RedisQueueMessageDrivenEndpoint(String queueName, org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the Redis Queue specified by boundListOperations.
    protected void
     
    protected void
     
    protected void
    doStop(Runnable callback)
     
     
    long
    Returns the size of the Queue specified by boundListOperations.
    boolean
     
    protected void
     
    void
    setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
     
    void
     
    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(org.springframework.data.redis.serializer.RedisSerializer<?> serializer)
     
    void
    setTaskExecutor(Executor taskExecutor)
     

    Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport

    afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher

    Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    destroy, 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

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedType

    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

    • RedisQueueMessageDrivenEndpoint

      public RedisQueueMessageDrivenEndpoint(String queueName, org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
      Parameters:
      queueName - Must not be an empty String
      connectionFactory - Must not be null
  • Method Details

    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader beanClassLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • setSerializer

      public void setSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> serializer)
    • setExpectMessage

      public 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?. 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.
      Parameters:
      expectMessage - Defaults to false
    • setReceiveTimeout

      public void setReceiveTimeout(long receiveTimeout)
      This timeout (milliseconds) is used when retrieving elements from the queue specified by 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

      Parameters:
      receiveTimeout - Must be non-negative. Specified in milliseconds.
    • setTaskExecutor

      public void setTaskExecutor(Executor taskExecutor)
    • setRecoveryInterval

      public void setRecoveryInterval(long recoveryInterval)
    • setRightPop

      public void setRightPop(boolean rightPop)
      Specify if POP operation from Redis List should be BRPOP or BLPOP.
      Parameters:
      rightPop - the BRPOP flag. Defaults to true.
      Since:
      4.3
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.endpoint.MessageProducerSupport
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.context.IntegrationObjectSupport
    • doStart

      protected void doStart()
      Overrides:
      doStart in class org.springframework.integration.endpoint.MessageProducerSupport
    • doStop

      protected void doStop(Runnable callback)
      Overrides:
      doStop in class org.springframework.integration.endpoint.AbstractEndpoint
    • doStop

      protected void doStop()
      Overrides:
      doStop in class org.springframework.integration.endpoint.MessageProducerSupport
    • isListening

      public boolean isListening()
    • getQueueSize

      @ManagedMetric public long getQueueSize()
      Returns the size of the Queue specified by 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
      Returns:
      Size of the queue. Never negative.
    • clearQueue

      @ManagedOperation public void clearQueue()
      Clear the Redis Queue specified by boundListOperations.