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, Wang Zhiyang
-
Constructor Summary
ConstructorDescriptionListenerContainerFactoryConfigurer
(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionprotected DefaultErrorHandler
createDefaultErrorHandlerInstance
(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer) protected CommonErrorHandler
createErrorHandler
(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer) decorateFactory
(ConcurrentKafkaListenerContainerFactory<?, ?> factory) Decorates the providedConcurrentKafkaListenerContainerFactory
.decorateFactory
(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated, for removal: This API element is subject to removal in a future version.decorateFactoryWithoutSettingContainerProperties
(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated, for removal: This API element is subject to removal in a future version.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
-
Constructor Details
-
ListenerContainerFactoryConfigurer
public ListenerContainerFactoryConfigurer(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, Clock clock)
-
-
Method Details
-
decorateFactory
@Deprecated(since="3.2", forRemoval=true) public KafkaListenerContainerFactory<?> decorateFactory(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated, for removal: This API element is subject to removal in a future version.Decorates the providedConcurrentKafkaListenerContainerFactory
.- Parameters:
factory
- the factory instance to be decorated.configuration
- the configuration provided by theRetryTopicConfiguration
.- Returns:
- the decorated factory instance.
-
decorateFactoryWithoutSettingContainerProperties
@Deprecated(since="3.2", forRemoval=true) public KafkaListenerContainerFactory<?> decorateFactoryWithoutSettingContainerProperties(ConcurrentKafkaListenerContainerFactory<?, ?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated, for removal: This API element is subject to removal in a future version.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.
-
decorateFactory
public KafkaListenerContainerFactory<?> decorateFactory(ConcurrentKafkaListenerContainerFactory<?, ?> factory) Decorates the providedConcurrentKafkaListenerContainerFactory
.- Parameters:
factory
- the factory instance to be decorated.- Returns:
- the decorated factory instance.
- Since:
- 3.2
-
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) -
createDefaultErrorHandlerInstance
protected DefaultErrorHandler createDefaultErrorHandlerInstance(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer) -
setupBackoffAwareMessageListenerAdapter
protected void setupBackoffAwareMessageListenerAdapter(ConcurrentMessageListenerContainer<?, ?> container)
-