Class DefaultPollableMessageSource

  • All Implemented Interfaces:
    PollableMessageSource, PollableSource<org.springframework.messaging.MessageHandler>, org.springframework.context.Lifecycle, org.springframework.retry.RetryListener

    public class DefaultPollableMessageSource
    extends Object
    implements PollableMessageSource, org.springframework.context.Lifecycle, org.springframework.retry.RetryListener
    The default implementation of a PollableMessageSource.
    Since:
    2.0
    Author:
    Gary Russell, Oleg Zhurakousky, David Turanski
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static ThreadLocal<org.springframework.core.AttributeAccessor> attributesHolder  
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultPollableMessageSource​(org.springframework.messaging.converter.SmartMessageConverter messageConverter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addInterceptor​(int index, org.springframework.messaging.support.ChannelInterceptor interceptor)  
      void addInterceptor​(org.springframework.messaging.support.ChannelInterceptor interceptor)  
      <T,​E extends Throwable>
      void
      close​(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,​E> callback, Throwable throwable)  
      boolean isRunning()  
      <T,​E extends Throwable>
      void
      onError​(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,​E> callback, Throwable throwable)  
      <T,​E extends Throwable>
      boolean
      open​(org.springframework.retry.RetryContext context, org.springframework.retry.RetryCallback<T,​E> callback)  
      boolean poll​(org.springframework.messaging.MessageHandler handler)
      Poll the consumer.
      boolean poll​(org.springframework.messaging.MessageHandler handler, org.springframework.core.ParameterizedTypeReference<?> type)
      Poll the consumer and convert the payload to the type.
      void setAttributesProvider​(BiConsumer<org.springframework.core.AttributeAccessor,​org.springframework.messaging.Message<?>> attributesProvider)  
      void setErrorChannel​(org.springframework.messaging.MessageChannel errorChannel)  
      void setErrorMessageStrategy​(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)  
      void setRecoveryCallback​(org.springframework.retry.RecoveryCallback<Object> recoveryCallback)  
      void setRetryTemplate​(org.springframework.retry.support.RetryTemplate retryTemplate)  
      void setSource​(org.springframework.integration.core.MessageSource<?> source)  
      protected boolean shouldRequeue​(Exception e)  
      void start()  
      void stop()  
    • Field Detail

      • attributesHolder

        protected static final ThreadLocal<org.springframework.core.AttributeAccessor> attributesHolder
    • Constructor Detail

      • DefaultPollableMessageSource

        public DefaultPollableMessageSource​(@Nullable
                                            org.springframework.messaging.converter.SmartMessageConverter messageConverter)
        Parameters:
        messageConverter - instance of SmartMessageConverter. Can be null.
    • Method Detail

      • setSource

        public void setSource​(org.springframework.integration.core.MessageSource<?> source)
      • setRetryTemplate

        public void setRetryTemplate​(org.springframework.retry.support.RetryTemplate retryTemplate)
      • setRecoveryCallback

        public void setRecoveryCallback​(org.springframework.retry.RecoveryCallback<Object> recoveryCallback)
      • setErrorChannel

        public void setErrorChannel​(org.springframework.messaging.MessageChannel errorChannel)
      • setErrorMessageStrategy

        public void setErrorMessageStrategy​(org.springframework.integration.support.ErrorMessageStrategy errorMessageStrategy)
      • setAttributesProvider

        public void setAttributesProvider​(BiConsumer<org.springframework.core.AttributeAccessor,​org.springframework.messaging.Message<?>> attributesProvider)
      • addInterceptor

        public void addInterceptor​(org.springframework.messaging.support.ChannelInterceptor interceptor)
      • addInterceptor

        public void addInterceptor​(int index,
                                   org.springframework.messaging.support.ChannelInterceptor interceptor)
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface org.springframework.context.Lifecycle
      • start

        public void start()
        Specified by:
        start in interface org.springframework.context.Lifecycle
      • stop

        public void stop()
        Specified by:
        stop in interface org.springframework.context.Lifecycle
      • poll

        public boolean poll​(org.springframework.messaging.MessageHandler handler)
        Description copied from interface: PollableSource
        Poll the consumer.
        Specified by:
        poll in interface PollableSource<org.springframework.messaging.MessageHandler>
        Parameters:
        handler - the handler.
        Returns:
        true if a message was handled.
      • poll

        public boolean poll​(org.springframework.messaging.MessageHandler handler,
                            org.springframework.core.ParameterizedTypeReference<?> type)
        Description copied from interface: PollableSource
        Poll the consumer and convert the payload to the type. Throw a RequeueCurrentMessageException to force the current message to be requeued in the broker (after retries are exhausted, if configured).
        Specified by:
        poll in interface PollableSource<org.springframework.messaging.MessageHandler>
        Parameters:
        handler - the handler.
        type - the type.
        Returns:
        true if a message was handled.
      • shouldRequeue

        protected boolean shouldRequeue​(Exception e)
      • open

        public <T,​E extends Throwable> boolean open​(org.springframework.retry.RetryContext context,
                                                          org.springframework.retry.RetryCallback<T,​E> callback)
        Specified by:
        open in interface org.springframework.retry.RetryListener
      • close

        public <T,​E extends Throwable> void close​(org.springframework.retry.RetryContext context,
                                                        org.springframework.retry.RetryCallback<T,​E> callback,
                                                        Throwable throwable)
        Specified by:
        close in interface org.springframework.retry.RetryListener
      • onError

        public <T,​E extends Throwable> void onError​(org.springframework.retry.RetryContext context,
                                                          org.springframework.retry.RetryCallback<T,​E> callback,
                                                          Throwable throwable)
        Specified by:
        onError in interface org.springframework.retry.RetryListener