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.
Also sets ContainerProperties.setIdlePartitionEventInterval(Long)
and ConsumerProperties.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
ConstructorsConstructorDescriptionListenerContainerFactoryConfigurer(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionconfigure(ConcurrentKafkaListenerContainerFactory<?, ?> containerFactory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated.protected voidconfigurePollTimeoutAndIdlePartitionInterval(ConcurrentMessageListenerContainer<?, ?> container, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) configureWithoutBackOffValues(ConcurrentKafkaListenerContainerFactory<?, ?> containerFactory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) protected DefaultErrorHandlercreateDefaultErrorHandlerInstance(DeadLetterPublishingRecoverer deadLetterPublishingRecoverer) protected CommonErrorHandlercreateErrorHandler(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.protected longgetIdlePartitionInterval(ContainerProperties containerProperties, long pollTimeoutValue) protected longgetPollTimeoutValue(ContainerProperties containerProperties, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) voidsetBlockingRetriesBackOff(org.springframework.util.backoff.BackOff blockingBackOff) Set aBackOffto be used with blocking retries.final voidsetBlockingRetryableExceptions(Class<? extends Exception>... exceptionTypes) Specify the exceptions to be retried via blocking.voidsetContainerCustomizer(Consumer<ConcurrentMessageListenerContainer<?, ?>> containerCustomizer) voidsetErrorHandlerCustomizer(Consumer<CommonErrorHandler> errorHandlerCustomizer) protected voidsetupBackoffAwareMessageListenerAdapter(ConcurrentMessageListenerContainer<?, ?> container, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration, boolean isSetContainerProperties)
-
Constructor Details
-
ListenerContainerFactoryConfigurer
public ListenerContainerFactoryConfigurer(KafkaConsumerBackoffManager kafkaConsumerBackoffManager, DeadLetterPublishingRecovererFactory deadLetterPublishingRecovererFactory, @Qualifier("internalBackOffClock") Clock clock)
-
-
Method Details
-
configure
@Deprecated public ConcurrentKafkaListenerContainerFactory<?,?> configure(ConcurrentKafkaListenerContainerFactory<?, ?> containerFactory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated.Configures the providedConcurrentKafkaListenerContainerFactory.- Parameters:
containerFactory- the factory instance to be configured.configuration- the configuration provided by theRetryTopicConfiguration.- Returns:
- the configured factory instance.
-
configureWithoutBackOffValues
@Deprecated public ConcurrentKafkaListenerContainerFactory<?,?> configureWithoutBackOffValues(ConcurrentKafkaListenerContainerFactory<?, ?> containerFactory, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) Deprecated.Configures the providedConcurrentKafkaListenerContainerFactory. Meant to be used for the main endpoint, this method ignores the provided backOff values.- Parameters:
containerFactory- the factory instance to be configured.configuration- the configuration provided by theRetryTopicConfiguration.- Returns:
- the configured factory instance.
-
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 aBackOffto 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:
-
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) -
configurePollTimeoutAndIdlePartitionInterval
protected void configurePollTimeoutAndIdlePartitionInterval(ConcurrentMessageListenerContainer<?, ?> container, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration) -
getIdlePartitionInterval
protected long getIdlePartitionInterval(ContainerProperties containerProperties, long pollTimeoutValue) -
getPollTimeoutValue
protected long getPollTimeoutValue(ContainerProperties containerProperties, org.springframework.kafka.retrytopic.ListenerContainerFactoryConfigurer.Configuration configuration)
-
decorateFactory(ConcurrentKafkaListenerContainerFactory, Configuration).