Class ListenerContainerFactoryConfigurer

java.lang.Object
org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer

public class ListenerContainerFactoryConfigurer extends Object
Decorates the provided ConcurrentKafkaListenerContainerFactory to add a DefaultErrorHandler and the DeadLetterPublishingRecoverer created by the DeadLetterPublishingRecovererFactory. Since 2.8.3 these configurations don't interfere with the provided factory instance itself, so the same factory instance can be shared among retryable and non-retryable endpoints.
Since:
2.7
Author:
Tomaz Fernandes, Gary Russell
  • Constructor Details

  • Method Details

    • decorateFactory

      public KafkaListenerContainerFactory<?> decorateFactory(ConcurrentKafkaListenerContainerFactory<?,?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
      Parameters:
      factory - the factory instance to be decorated.
      configuration - the configuration provided by the RetryTopicConfiguration.
      Returns:
      the decorated factory instance.
    • decorateFactoryWithoutSettingContainerProperties

      public KafkaListenerContainerFactory<?> decorateFactoryWithoutSettingContainerProperties(ConcurrentKafkaListenerContainerFactory<?,?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
      Decorates the provided ConcurrentKafkaListenerContainerFactory. Meant to be used for the main endpoint, this method ignores the provided backOff values.
      Parameters:
      factory - the factory instance to be decorated.
      configuration - the configuration provided by the RetryTopicConfiguration.
      Returns:
      the decorated factory instance.
    • setBlockingRetriesBackOff

      public void setBlockingRetriesBackOff(BackOff blockingBackOff)
      Set a BackOff to be used with blocking retries. If the BackOff execution returns STOP, the record will be forwarded to the next retry topic or to the DLT, depending on how the non-blocking retries are configured.
      Parameters:
      blockingBackOff - the BackOff policy to be used by blocking retries.
      Since:
      2.8.4
      See Also:
    • setBlockingRetryableExceptions

      @SafeVarargs public final void setBlockingRetryableExceptions(Class<? extends Exception>... exceptionTypes)
      Specify the exceptions to be retried via blocking.
      Parameters:
      exceptionTypes - the exceptions that should be retried.
      Since:
      2.8.4
      See Also:
    • setRetainStandardFatal

      public void setRetainStandardFatal(boolean retainStandardFatal)
      Set to true to retain standard fatal exceptions as not retryable when configuring blocking retries.
      Parameters:
      retainStandardFatal - true to retain standard fatal exceptions.
      Since:
      3.0
    • setContainerCustomizer

      public void setContainerCustomizer(Consumer<ConcurrentMessageListenerContainer<?,?>> containerCustomizer)
    • setErrorHandlerCustomizer

      public void setErrorHandlerCustomizer(Consumer<DefaultErrorHandler> errorHandlerCustomizer)
    • createErrorHandler

      protected CommonErrorHandler createErrorHandler(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
    • createDefaultErrorHandlerInstance

      protected DefaultErrorHandler createDefaultErrorHandlerInstance(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer)
    • setupBackoffAwareMessageListenerAdapter

      protected void setupBackoffAwareMessageListenerAdapter(ConcurrentMessageListenerContainer<?,?> container, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration, boolean isSetContainerProperties)