Class AmqpInboundChannelAdapter

All Implemented Interfaces:
Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, SmartInitializingSingleton, ApplicationContextAware, Lifecycle, Phased, SmartLifecycle, ExpressionCapable, OrderlyShutdownCapable, MessageProducer, IntegrationPattern, NamedComponent, IntegrationInboundManagement, IntegrationManagement, ManageableLifecycle, ManageableSmartLifecycle, TrackableComponent

public class AmqpInboundChannelAdapter extends MessageProducerSupport implements OrderlyShutdownCapable
Adapter that receives Messages from an AMQP Queue, converts them into Spring Integration Messages, and sends the results to a Message Channel.
Since:
2.1
Author:
Mark Fisher, Gary Russell, Artem Bilan
  • Field Details

  • Constructor Details

    • AmqpInboundChannelAdapter

      public AmqpInboundChannelAdapter(MessageListenerContainer listenerContainer)
      Construct an instance using the provided container.
      Parameters:
      listenerContainer - the container.
  • Method Details

    • setMessageConverter

      public void setMessageConverter(MessageConverter messageConverter)
    • setHeaderMapper

      public void setHeaderMapper(AmqpHeaderMapper headerMapper)
    • setRetryTemplate

      public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
      Set a RetryTemplate to use for retrying a message delivery within the adapter. Unlike adding retry at the container level, this can be used with an ErrorMessageSendingRecoverer RecoveryCallback to publish to the error channel after retries are exhausted. You generally should not configure an error channel when using retry here, use a RecoveryCallback instead.
      Parameters:
      retryTemplate - the template.
      Since:
      4.3.10.
      See Also:
    • setRecoveryCallback

      public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<?> recoveryCallback)
      Set a RecoveryCallback when using retry within the adapter. Mutually exclusive with setMessageRecoverer(MessageRecoverer).
      Parameters:
      recoveryCallback - the callback.
      Since:
      4.3.10
      See Also:
    • setMessageRecoverer

      public void setMessageRecoverer(MessageRecoverer messageRecoverer)
      Configure a MessageRecoverer for retry operations. A more AMQP-specific convenience instead of setRecoveryCallback(RecoveryCallback).
      Parameters:
      messageRecoverer - the MessageRecoverer to use.
      Since:
      5.5
    • setBatchingStrategy

      public void setBatchingStrategy(BatchingStrategy batchingStrategy)
      Set a batching strategy to use when de-batching messages created by a batching producer (such as the BatchingRabbitTemplate). Default is SimpleBatchingStrategy.
      Parameters:
      batchingStrategy - the strategy.
      Since:
      5.2
    • setBindSourceMessage

      public void setBindSourceMessage(boolean bindSourceMessage)
      Set to true to bind the source message in the header named IntegrationMessageHeaderAccessor.SOURCE_DATA.
      Parameters:
      bindSourceMessage - true to bind.
      Since:
      5.1.6
    • setBatchMode

      public void setBatchMode(AmqpInboundChannelAdapter.BatchMode batchMode)
      When the listener container is configured with consumerBatchEnabled, set the payload type for messages generated for the batches. Default is AmqpInboundChannelAdapter.BatchMode.MESSAGES.
      Parameters:
      batchMode - the batch mode.
      Since:
      5.3
    • getComponentType

      public String getComponentType()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this method to provide component type information.
      Specified by:
      getComponentType in interface NamedComponent
      Overrides:
      getComponentType in class IntegrationObjectSupport
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class MessageProducerSupport
    • doStart

      protected void doStart()
      Description copied from class: MessageProducerSupport
      Take no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.
      Overrides:
      doStart in class MessageProducerSupport
    • doStop

      protected void doStop()
      Description copied from class: MessageProducerSupport
      Take no action by default. Subclasses may override this if they need lifecycle-managed behavior.
      Overrides:
      doStop in class MessageProducerSupport
    • beforeShutdown

      public int beforeShutdown()
      Description copied from interface: OrderlyShutdownCapable
      Called before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.
      Specified by:
      beforeShutdown in interface OrderlyShutdownCapable
      Returns:
      The number of active messages if available.
    • afterShutdown

      public int afterShutdown()
      Description copied from interface: OrderlyShutdownCapable
      Called after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.
      Specified by:
      afterShutdown in interface OrderlyShutdownCapable
      Returns:
      The number of active messages if available.
    • getErrorMessageAttributes

      protected AttributeAccessor getErrorMessageAttributes(Message<?> message)
      Description copied from class: MessageProducerSupport
      Populate an AttributeAccessor to be used when building an error message with the errorMessageStrategy.
      Overrides:
      getErrorMessageAttributes in class MessageProducerSupport
      Parameters:
      message - the message.
      Returns:
      the attributes.