Skip to content

Externalization of authExceptionRetryInterval for listeners and other improvements #44425

Closed as duplicate of#44199
@leonardowestphal

Description

@leonardowestphal

Expected Behavior

I would like to suggest externalizing the authExceptionRetryInterval property used in the org.springframework.kafka.listener.ConsumerProperties class, allowing its configuration through application.properties.

Something like: spring.kafka.listener.auth-exception-retry-interval=5000

It would also be interesting if there were an option to configure a backoff policy or even allow the implementation of a custom handler for fatal exceptions like AuthenticationException.

Current Behavior

Currently, this configuration must be implemented manually in ConcurrentKafkaListenerContainerFactory and only supports a fixed retry interval.

Example:

@Bean
	public ConcurrentKafkaListenerContainerFactory<String, String> kafkaListenerContainerFactory(ConsumerFactory<String, String> consumerFactory) {
		ConcurrentKafkaListenerContainerFactory<String, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
		factory.setConsumerFactory(consumerFactory);		
		factory.getContainerProperties().setAuthExceptionRetryInterval(Duration.ofMillis(4000L));		

		return factory;
	}

Context

This way, we would avoid the need to implement code to activate this mechanism, which provides resilience for consumer applications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions