Class ListenerContainerFactoryConfigurer
- java.lang.Object
-
- org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer
-
public class ListenerContainerFactoryConfigurer extends java.lang.Object
Decorates the providedConcurrentKafkaListenerContainerFactory
to add aDefaultErrorHandler
and theDeadLetterPublishingRecoverer
created by theDeadLetterPublishingRecovererFactory
. Also setsContainerProperties.setIdlePartitionEventInterval(Long)
andConsumerProperties.setPollTimeout(long)
if its defaults haven't been overridden by the user. 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
-
-
Constructor Summary
Constructors Constructor Description ListenerContainerFactoryConfigurer(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, java.time.Clock clock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DefaultErrorHandler
createDefaultErrorHandlerInstance(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer)
protected CommonErrorHandler
createErrorHandler(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
KafkaListenerContainerFactory<?>
decorateFactory(ConcurrentKafkaListenerContainerFactory<?,?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
Decorates the providedConcurrentKafkaListenerContainerFactory
.KafkaListenerContainerFactory<?>
decorateFactoryWithoutSettingContainerProperties(ConcurrentKafkaListenerContainerFactory<?,?> factory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
Decorates the providedConcurrentKafkaListenerContainerFactory
.void
setBlockingRetriesBackOff(org.springframework.util.backoff.BackOff blockingBackOff)
Set aBackOff
to be used with blocking retries.void
setBlockingRetryableExceptions(java.lang.Class<? extends java.lang.Exception>... exceptionTypes)
Specify the exceptions to be retried via blocking.void
setContainerCustomizer(java.util.function.Consumer<ConcurrentMessageListenerContainer<?,?>> containerCustomizer)
void
setErrorHandlerCustomizer(java.util.function.Consumer<DefaultErrorHandler> errorHandlerCustomizer)
protected void
setupBackoffAwareMessageListenerAdapter(ConcurrentMessageListenerContainer<?,?> container, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration, boolean isSetContainerProperties)
-
-
-
Constructor Detail
-
ListenerContainerFactoryConfigurer
public ListenerContainerFactoryConfigurer(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, java.time.Clock clock)
-
-
Method Detail
-
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
public void setBlockingRetriesBackOff(org.springframework.util.backoff.BackOff blockingBackOff)
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:
DefaultErrorHandler
-
setBlockingRetryableExceptions
@SafeVarargs public final void setBlockingRetryableExceptions(java.lang.Class<? extends java.lang.Exception>... exceptionTypes)
Specify the exceptions to be retried via blocking.- Parameters:
exceptionTypes
- the exceptions that should be retried.- Since:
- 2.8.4
- See Also:
DefaultErrorHandler
-
setContainerCustomizer
public void setContainerCustomizer(java.util.function.Consumer<ConcurrentMessageListenerContainer<?,?>> containerCustomizer)
-
setErrorHandlerCustomizer
public void setErrorHandlerCustomizer(java.util.function.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)
-
-