Class AbstractPollableChannel

All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, ExecutorChannelInterceptorAware, ExpressionCapable, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, org.springframework.messaging.MessageChannel, org.springframework.messaging.PollableChannel, org.springframework.messaging.support.InterceptableChannel
Direct Known Subclasses:
QueueChannel

public abstract class AbstractPollableChannel
extends AbstractMessageChannel
implements org.springframework.messaging.PollableChannel, ExecutorChannelInterceptorAware
Base class for all pollable channels.
  • Constructor Details

  • Method Details

    • getIntegrationPatternType

      public IntegrationPatternType getIntegrationPatternType()
      Description copied from interface: IntegrationPattern
      Return a pattern type this component implements.
      Specified by:
      getIntegrationPatternType in interface IntegrationPattern
      Overrides:
      getIntegrationPatternType in class AbstractMessageChannel
      Returns:
      the IntegrationPatternType this component implements.
    • receive

      @Nullable public org.springframework.messaging.Message<?> receive()
      Receive the first available message from this channel. If the channel contains no messages, this method will block.
      Specified by:
      receive in interface org.springframework.messaging.PollableChannel
      Returns:
      the first available message or null if the receiving thread is interrupted.
    • receive

      @Nullable public org.springframework.messaging.Message<?> receive​(long timeout)
      Receive the first available message from this channel. If the channel contains no messages, this method will block until the allotted timeout elapses. If the specified timeout is 0, the method will return immediately. If less than zero, it will block indefinitely (see receive()).
      Specified by:
      receive in interface org.springframework.messaging.PollableChannel
      Parameters:
      timeout - the timeout in milliseconds
      Returns:
      the first available message or null if no message is available within the allotted time or the receiving thread is interrupted.
    • setInterceptors

      public void setInterceptors​(java.util.List<org.springframework.messaging.support.ChannelInterceptor> interceptors)
      Description copied from class: AbstractMessageChannel
      Set the list of channel interceptors. This will clear any existing interceptors.
      Specified by:
      setInterceptors in interface org.springframework.messaging.support.InterceptableChannel
      Overrides:
      setInterceptors in class AbstractMessageChannel
      Parameters:
      interceptors - The list of interceptors.
    • addInterceptor

      public void addInterceptor​(org.springframework.messaging.support.ChannelInterceptor interceptor)
      Description copied from class: AbstractMessageChannel
      Add a channel interceptor to the end of the list.
      Specified by:
      addInterceptor in interface org.springframework.messaging.support.InterceptableChannel
      Overrides:
      addInterceptor in class AbstractMessageChannel
      Parameters:
      interceptor - The interceptor.
    • addInterceptor

      public void addInterceptor​(int index, org.springframework.messaging.support.ChannelInterceptor interceptor)
      Description copied from class: AbstractMessageChannel
      Add a channel interceptor to the specified index of the list.
      Specified by:
      addInterceptor in interface org.springframework.messaging.support.InterceptableChannel
      Overrides:
      addInterceptor in class AbstractMessageChannel
      Parameters:
      index - The index to add interceptor.
      interceptor - The interceptor.
    • removeInterceptor

      public boolean removeInterceptor​(org.springframework.messaging.support.ChannelInterceptor interceptor)
      Specified by:
      removeInterceptor in interface org.springframework.messaging.support.InterceptableChannel
      Overrides:
      removeInterceptor in class AbstractMessageChannel
    • removeInterceptor

      @Nullable public org.springframework.messaging.support.ChannelInterceptor removeInterceptor​(int index)
      Specified by:
      removeInterceptor in interface org.springframework.messaging.support.InterceptableChannel
      Overrides:
      removeInterceptor in class AbstractMessageChannel
    • hasExecutorInterceptors

      public boolean hasExecutorInterceptors()
      Specified by:
      hasExecutorInterceptors in interface ExecutorChannelInterceptorAware
    • doReceive

      @Nullable protected abstract org.springframework.messaging.Message<?> doReceive​(long timeout)
      Subclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is empty (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either a message is available or the blocking thread is interrupted.
      Parameters:
      timeout - The timeout.
      Returns:
      The message, or null.