Class BaseRabbitListenerContainerFactory<C extends org.springframework.amqp.core.MessageListenerContainer>

java.lang.Object
org.springframework.amqp.rabbit.config.BaseRabbitListenerContainerFactory<C>
Type Parameters:
C - the container type that the factory creates.
All Implemented Interfaces:
RabbitListenerContainerFactory<C>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
AbstractRabbitListenerContainerFactory

public abstract class BaseRabbitListenerContainerFactory<C extends org.springframework.amqp.core.MessageListenerContainer> extends Object implements RabbitListenerContainerFactory<C>, org.springframework.context.ApplicationContextAware
Base abstract class for listener container factories.
Since:
2.4
  • Constructor Details

    • BaseRabbitListenerContainerFactory

      public BaseRabbitListenerContainerFactory()
  • Method Details

    • createListenerContainer

      public abstract C createListenerContainer(@Nullable RabbitListenerEndpoint endpoint)
      Description copied from interface: RabbitListenerContainerFactory
      Create a MessageListenerContainer for the given RabbitListenerEndpoint.
      Specified by:
      createListenerContainer in interface RabbitListenerContainerFactory<C extends org.springframework.amqp.core.MessageListenerContainer>
      Parameters:
      endpoint - the endpoint to configure.
      Returns:
      the created container.
    • setDefaultRequeueRejected

      public void setDefaultRequeueRejected(Boolean requeueRejected)
      Parameters:
      requeueRejected - true to reject by default.
      See Also:
    • getDefaultRequeueRejected

      protected @Nullable Boolean getDefaultRequeueRejected()
      Return the defaultRequeueRejected.
      Returns:
      the defaultRequeueRejected.
    • setBeforeSendReplyPostProcessors

      public void setBeforeSendReplyPostProcessors(org.springframework.amqp.core.MessagePostProcessor... postProcessors)
      Set post-processors that will be applied before sending replies; added to each message listener adapter.
      Parameters:
      postProcessors - the post-processors.
      See Also:
    • setRetryTemplate

      public void setRetryTemplate(org.springframework.core.retry.RetryTemplate retryTemplate)
      Set a RetryTemplate to use when sending replies; added to each message listener adapter.
      Parameters:
      retryTemplate - the template.
      See Also:
    • setReplyRecoveryCallback

      public void setReplyRecoveryCallback(MessageRecoverer recoveryCallback)
      Set a MessageRecoverer to invoke when retries are exhausted. Added to each message listener adapter. Only used if a retryTemplate is provided.
      Parameters:
      recoveryCallback - the recovery callback.
      See Also:
    • setReplyPostProcessorProvider

      public void setReplyPostProcessorProvider(Function<@Nullable String, @Nullable org.springframework.amqp.listener.adapter.ReplyPostProcessor> replyPostProcessorProvider)
      Set a function to provide a reply post-processor; it will be used if there is no replyPostProcessor on the rabbit listener annotation. The input parameter is the listener id.
      Parameters:
      replyPostProcessorProvider - the post-processor.
      Since:
      3.0
    • applyCommonOverrides

      protected void applyCommonOverrides(@Nullable RabbitListenerEndpoint endpoint, C instance)
    • getAdviceChain

      public org.aopalliance.aop.Advice @Nullable [] getAdviceChain()
      Returns:
      the advice chain that was set. Defaults to null.
      Since:
      1.7.4
    • setAdviceChain

      public void setAdviceChain(org.aopalliance.aop.Advice @Nullable ... adviceChain)
      Parameters:
      adviceChain - the advice chain to set.
      See Also:
    • setMicrometerEnabled

      public void setMicrometerEnabled(boolean micrometerEnabled)
      Set to false to disable micrometer listener timers. When true, ignored if setObservationEnabled(boolean) is set to true.
      Parameters:
      micrometerEnabled - false to disable.
      Since:
      3.0
      See Also:
    • getMicrometerEnabled

      protected @Nullable Boolean getMicrometerEnabled()
    • setObservationEnabled

      public void setObservationEnabled(boolean observationEnabled)
      Enable observation via micrometer; disables basic Micrometer timers enabled by setMicrometerEnabled(boolean).
      Parameters:
      observationEnabled - true to enable.
      Since:
      3.0
      See Also:
    • getObservationEnabled

      protected @Nullable Boolean getObservationEnabled()
    • setAcknowledgeOnError

      public void setAcknowledgeOnError(boolean acknowledgeOnError)
      Set to false to prevent auto-acknowledgment of messages when a RabbitListenerErrorHandler returns null in MANUAL ack mode. This lets the error handler manage acknowledgment itself (e.g. via channel.basicReject()) without causing a duplicate-ack error. Default is true.
      Parameters:
      acknowledgeOnError - false to skip auto-ack on null return from error handler.
      Since:
      3.2.11
      See Also:
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getApplicationContext

      protected org.springframework.context.ApplicationContext getApplicationContext()
    • setBeanName

      public void setBeanName(String name)
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
      Specified by:
      setBeanName in interface RabbitListenerContainerFactory<C extends org.springframework.amqp.core.MessageListenerContainer>
    • getBeanName

      public @Nullable String getBeanName()
      Description copied from interface: RabbitListenerContainerFactory
      Return a bean name of the component or null if not a bean.
      Specified by:
      getBeanName in interface RabbitListenerContainerFactory<C extends org.springframework.amqp.core.MessageListenerContainer>
      Returns:
      the bean name.