Class ListenerContainerFactoryConfigurer
java.lang.Object
org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer
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 Summary
ConstructorDescriptionListenerContainerFactoryConfigurer
(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionprotected DefaultErrorHandler
createDefaultErrorHandlerInstance
(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer) protected CommonErrorHandler
createErrorHandler
(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) decorateFactory
(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Decorates the providedConcurrentKafkaListenerContainerFactory
.decorateFactoryWithoutSettingContainerProperties
(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Decorates the providedConcurrentKafkaListenerContainerFactory
.void
setBlockingRetriesBackOff
(BackOff blockingBackOff) Set aBackOff
to be used with blocking retries.final void
setBlockingRetryableExceptions
(Class<? extends Exception>... exceptionTypes) Specify the exceptions to be retried via blocking.void
setContainerCustomizer
(Consumer<ConcurrentMessageListenerContainer<?, ?>> containerCustomizer) void
setErrorHandlerCustomizer
(Consumer<DefaultErrorHandler> errorHandlerCustomizer) void
setRetainStandardFatal
(boolean retainStandardFatal) Set to true to retain standard fatal exceptions as not retryable when configuring blocking retries.protected void
setupBackoffAwareMessageListenerAdapter
(ConcurrentMessageListenerContainer<?, ?> container, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration, boolean isSetContainerProperties)
-
Constructor Details
-
ListenerContainerFactoryConfigurer
public ListenerContainerFactoryConfigurer(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, Clock clock)
-
-
Method Details
-
decorateFactory
public KafkaListenerContainerFactory<?> decorateFactory(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Decorates the providedConcurrentKafkaListenerContainerFactory
.- Parameters:
factory
- the factory instance to be decorated.configuration
- the configuration provided by theRetryTopicConfiguration
.- Returns:
- the decorated factory instance.
-
decorateFactoryWithoutSettingContainerProperties
public KafkaListenerContainerFactory<?> decorateFactoryWithoutSettingContainerProperties(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Decorates the providedConcurrentKafkaListenerContainerFactory
. 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 theRetryTopicConfiguration
.- Returns:
- the decorated factory instance.
-
setBlockingRetriesBackOff
Set aBackOff
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
-
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)
-