Class AbstractMessageListenerContainerSpec<S extends AbstractMessageListenerContainerSpec<S,​C>,​C extends org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer>

java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<T>
org.springframework.integration.dsl.IntegrationComponentSpec<S,​C>
org.springframework.integration.amqp.dsl.AbstractMessageListenerContainerSpec<S,​C>
Type Parameters:
S - the current spec extension type
C - the listener container type
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<C>, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle
Direct Known Subclasses:
DirectMessageListenerContainerSpec, SimpleMessageListenerContainerSpec

public abstract class AbstractMessageListenerContainerSpec<S extends AbstractMessageListenerContainerSpec<S,​C>,​C extends org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer>
extends org.springframework.integration.dsl.IntegrationComponentSpec<S,​C>
Base class for container specs.
Since:
5.0
  • Field Summary

    Fields inherited from class org.springframework.integration.dsl.IntegrationComponentSpec

    PARSER, target

    Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

    logger

    Fields inherited from interface org.springframework.beans.factory.FactoryBean

    OBJECT_TYPE_ATTRIBUTE

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractMessageListenerContainerSpec​(C listenerContainer)  
  • Method Summary

    Modifier and Type Method Description
    S acknowledgeMode​(org.springframework.amqp.core.AcknowledgeMode acknowledgeMode)  
    S addQueueNames​(java.lang.String... queueName)  
    S addQueues​(org.springframework.amqp.core.Queue... queues)  
    S adviceChain​(org.aopalliance.aop.Advice... adviceChain)  
    S afterReceivePostProcessors​(org.springframework.amqp.core.MessagePostProcessor... afterReceivePostProcessors)
    Set MessagePostProcessors that will be applied after message reception, before invoking the MessageListener.
    S alwaysRequeueWithTxManagerRollback​(boolean alwaysRequeueWithTxManagerRollback)
    Set to true to always requeue on transaction rollback with an external TransactionManager.
    S autoDeclare​(boolean autoDeclare)
    Set to true to automatically declare elements (queues, exchanges, bindings) in the application context during container start().
    S channelTransacted​(boolean transactional)  
    S consumerArguments​(java.util.Map<java.lang.String,​java.lang.Object> args)
    Set consumer arguments.
    S consumerTagStrategy​(org.springframework.amqp.support.ConsumerTagStrategy consumerTagStrategy)
    Set the implementation of ConsumerTagStrategy to generate consumer tags.
    S deBatchingEnabled​(boolean deBatchingEnabled)
    Determine whether the container should de-batch batched messages (true) or call the listener with the batch (false).
    S defaultRequeueRejected​(boolean defaultRequeueRejected)  
    S errorHandler​(org.springframework.util.ErrorHandler errorHandler)  
    S exclusive​(boolean exclusive)  
    S exclusiveConsumerExceptionLogger​(org.springframework.amqp.support.ConditionalExceptionLogger exclusiveConsumerExceptionLogger)
    Set a ConditionalExceptionLogger for logging exclusive consumer failures.
    S failedDeclarationRetryInterval​(long failedDeclarationRetryInterval)
    Set the interval between passive queue declaration attempts in milliseconds.
    S id​(java.lang.String id)  
    S idleEventInterval​(long idleEventInterval)
    How often to emit ListenerContainerIdleEvents in milliseconds.
    S lookupKeyQualifier​(java.lang.String lookupKeyQualifier)
    Set a qualifier that will prefix the connection factory lookup key; default none.
    S messagePropertiesConverter​(org.springframework.amqp.rabbit.support.MessagePropertiesConverter messagePropertiesConverter)
    Set the MessagePropertiesConverter for this listener container.
    S mismatchedQueuesFatal​(boolean mismatchedQueuesFatal)
    Prevent the container from starting if any of the queues defined in the context have mismatched arguments (TTL etc.).
    S missingQueuesFatal​(boolean missingQueuesFatal)
    If all the configured queue(s) are not available on the broker, this setting determines whether the condition is fatal.
    S prefetchCount​(int prefetchCount)  
    S recoveryBackOff​(org.springframework.util.backoff.BackOff recoveryBackOff)
    Specify the BackOff for interval between recovery attempts.
    S recoveryInterval​(long recoveryInterval)  
    S shutdownTimeout​(long shutdownTimeout)  
    S statefulRetryFatalWithNullMessageId​(boolean statefulRetryFatalWithNullMessageId)
    Set whether a message with a null messageId is fatal for the consumer when using stateful retry.
    S taskExecutor​(java.util.concurrent.Executor taskExecutor)
    Configure an Executor used to invoke the message listener.
    S transactionAttribute​(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute)
    Set the transaction attribute to use when using an external transaction manager.
    S transactionManager​(org.springframework.transaction.PlatformTransactionManager transactionManager)
    Configure a PlatformTransactionManager; used to synchronize the rabbit transaction with some other transaction(s).

    Methods inherited from class org.springframework.integration.dsl.IntegrationComponentSpec

    _this, createInstance, destroyInstance, doGet, get, getId, getObjectType, getPhase, isAutoStartup, isRunning, start, stop, stop

    Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

    afterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • id

      public S id​(java.lang.String id)
      Overrides:
      id in class org.springframework.integration.dsl.IntegrationComponentSpec<S extends AbstractMessageListenerContainerSpec<S,​C>,​C extends org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer>
    • acknowledgeMode

      public S acknowledgeMode​(org.springframework.amqp.core.AcknowledgeMode acknowledgeMode)
      Parameters:
      acknowledgeMode - the acknowledgeMode.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setAcknowledgeMode(AcknowledgeMode)
    • addQueueNames

      public S addQueueNames​(java.lang.String... queueName)
      Parameters:
      queueName - a vararg list of queue names to add.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.addQueueNames(String...)
    • addQueues

      public S addQueues​(org.springframework.amqp.core.Queue... queues)
      Parameters:
      queues - a vararg list of queues to add.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.addQueueNames(String...)
    • errorHandler

      public S errorHandler​(org.springframework.util.ErrorHandler errorHandler)
      Parameters:
      errorHandler - the errorHandler.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setErrorHandler(ErrorHandler)
    • channelTransacted

      public S channelTransacted​(boolean transactional)
      Parameters:
      transactional - true for transactional channels.
      Returns:
      the spec.
      See Also:
      RabbitAccessor.setChannelTransacted(boolean)
    • adviceChain

      public S adviceChain​(org.aopalliance.aop.Advice... adviceChain)
      Parameters:
      adviceChain - the adviceChain.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setAdviceChain(Advice[])
    • recoveryInterval

      public S recoveryInterval​(long recoveryInterval)
      Parameters:
      recoveryInterval - the recoveryInterval
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setRecoveryInterval(long)
    • exclusive

      public S exclusive​(boolean exclusive)
      Parameters:
      exclusive - true for exclusive.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setExclusive(boolean)
    • shutdownTimeout

      public S shutdownTimeout​(long shutdownTimeout)
      Parameters:
      shutdownTimeout - the shutdownTimeout.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setShutdownTimeout(long)
    • taskExecutor

      public S taskExecutor​(java.util.concurrent.Executor taskExecutor)
      Configure an Executor used to invoke the message listener.
      Parameters:
      taskExecutor - the taskExecutor.
      Returns:
      the spec.
    • prefetchCount

      public S prefetchCount​(int prefetchCount)
      Parameters:
      prefetchCount - the prefetchCount.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setPrefetchCount(int)
    • transactionManager

      public S transactionManager​(org.springframework.transaction.PlatformTransactionManager transactionManager)
      Configure a PlatformTransactionManager; used to synchronize the rabbit transaction with some other transaction(s).
      Parameters:
      transactionManager - the transactionManager.
      Returns:
      the spec.
    • defaultRequeueRejected

      public S defaultRequeueRejected​(boolean defaultRequeueRejected)
      Parameters:
      defaultRequeueRejected - the defaultRequeueRejected.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setDefaultRequeueRejected(boolean)
    • deBatchingEnabled

      public S deBatchingEnabled​(boolean deBatchingEnabled)
      Determine whether the container should de-batch batched messages (true) or call the listener with the batch (false). Default: true.
      Parameters:
      deBatchingEnabled - the deBatchingEnabled to set.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setDeBatchingEnabled(boolean)
    • afterReceivePostProcessors

      public S afterReceivePostProcessors​(org.springframework.amqp.core.MessagePostProcessor... afterReceivePostProcessors)
      Set MessagePostProcessors that will be applied after message reception, before invoking the MessageListener. Often used to decompress data. Processors are invoked in order, depending on PriorityOrder, Order and finally unordered.
      Parameters:
      afterReceivePostProcessors - the post processor.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setAfterReceivePostProcessors(MessagePostProcessor...)
    • lookupKeyQualifier

      public S lookupKeyQualifier​(java.lang.String lookupKeyQualifier)
      Set a qualifier that will prefix the connection factory lookup key; default none.
      Parameters:
      lookupKeyQualifier - the qualifier
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setLookupKeyQualifier(String)
    • consumerTagStrategy

      public S consumerTagStrategy​(org.springframework.amqp.support.ConsumerTagStrategy consumerTagStrategy)
      Set the implementation of ConsumerTagStrategy to generate consumer tags. By default, the RabbitMQ server generates consumer tags.
      Parameters:
      consumerTagStrategy - the consumerTagStrategy to set.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setConsumerTagStrategy(ConsumerTagStrategy)
    • consumerArguments

      public S consumerArguments​(java.util.Map<java.lang.String,​java.lang.Object> args)
      Set consumer arguments.
      Parameters:
      args - the arguments.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setConsumerArguments(Map)
    • idleEventInterval

      public S idleEventInterval​(long idleEventInterval)
      How often to emit ListenerContainerIdleEvents in milliseconds.
      Parameters:
      idleEventInterval - the interval.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setIdleEventInterval(long)
    • transactionAttribute

      public S transactionAttribute​(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute)
      Set the transaction attribute to use when using an external transaction manager.
      Parameters:
      transactionAttribute - the transaction attribute to set
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setTransactionAttribute(TransactionAttribute)
    • recoveryBackOff

      public S recoveryBackOff​(org.springframework.util.backoff.BackOff recoveryBackOff)
      Specify the BackOff for interval between recovery attempts. The default is 5000 ms, that is, 5 seconds. With the BackOff you can supply the maxAttempts for recovery before the stop() will be performed.
      Parameters:
      recoveryBackOff - The BackOff to recover.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setRecoveryBackOff(BackOff)
    • messagePropertiesConverter

      public S messagePropertiesConverter​(org.springframework.amqp.rabbit.support.MessagePropertiesConverter messagePropertiesConverter)
      Set the MessagePropertiesConverter for this listener container.
      Parameters:
      messagePropertiesConverter - The properties converter.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setMessagePropertiesConverter(MessagePropertiesConverter)
    • missingQueuesFatal

      public S missingQueuesFatal​(boolean missingQueuesFatal)
      If all the configured queue(s) are not available on the broker, this setting determines whether the condition is fatal. When true, and the queues are missing during startup, the context refresh() will fail.

      When false, the condition is not considered fatal and the container will continue to attempt to start the consumers.

      Parameters:
      missingQueuesFatal - the missingQueuesFatal to set.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setMissingQueuesFatal(boolean)
    • mismatchedQueuesFatal

      public S mismatchedQueuesFatal​(boolean mismatchedQueuesFatal)
      Prevent the container from starting if any of the queues defined in the context have mismatched arguments (TTL etc.). Default false.
      Parameters:
      mismatchedQueuesFatal - true to fail initialization when this condition occurs.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setMismatchedQueuesFatal(boolean)
    • autoDeclare

      public S autoDeclare​(boolean autoDeclare)
      Set to true to automatically declare elements (queues, exchanges, bindings) in the application context during container start().
      Parameters:
      autoDeclare - the boolean flag to indicate a declaration operation.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setAutoDeclare(boolean)
    • failedDeclarationRetryInterval

      public S failedDeclarationRetryInterval​(long failedDeclarationRetryInterval)
      Set the interval between passive queue declaration attempts in milliseconds.
      Parameters:
      failedDeclarationRetryInterval - the interval, default 5000.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setFailedDeclarationRetryInterval(long)
    • statefulRetryFatalWithNullMessageId

      public S statefulRetryFatalWithNullMessageId​(boolean statefulRetryFatalWithNullMessageId)
      Set whether a message with a null messageId is fatal for the consumer when using stateful retry. When false, instead of stopping the consumer, the message is rejected and not requeued - it will be discarded or routed to the dead letter queue, if so configured. Default true.
      Parameters:
      statefulRetryFatalWithNullMessageId - true for fatal.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setStatefulRetryFatalWithNullMessageId(boolean)
    • exclusiveConsumerExceptionLogger

      public S exclusiveConsumerExceptionLogger​(org.springframework.amqp.support.ConditionalExceptionLogger exclusiveConsumerExceptionLogger)
      Set a ConditionalExceptionLogger for logging exclusive consumer failures. The default is to log such failures at WARN level.
      Parameters:
      exclusiveConsumerExceptionLogger - the conditional exception logger.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setExclusiveConsumerExceptionLogger(ConditionalExceptionLogger)
    • alwaysRequeueWithTxManagerRollback

      public S alwaysRequeueWithTxManagerRollback​(boolean alwaysRequeueWithTxManagerRollback)
      Set to true to always requeue on transaction rollback with an external TransactionManager.
      Parameters:
      alwaysRequeueWithTxManagerRollback - true to always requeue on rollback.
      Returns:
      the spec.
      See Also:
      AbstractMessageListenerContainer.setAlwaysRequeueWithTxManagerRollback(boolean)