Skip to content

Instantly share code, notes, and snippets.

@wpik
Created November 18, 2019 14:03
Show Gist options
  • Save wpik/3445104400e7eaf108e72a5cb1cb80c2 to your computer and use it in GitHub Desktop.
Save wpik/3445104400e7eaf108e72a5cb1cb80c2 to your computer and use it in GitHub Desktop.
Reprocess kafka events in Spring Kafka
spring:
kafka:
listener:
ack-mode: record
import org.springframework.boot.autoconfigure.kafka.ConcurrentKafkaListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.listener.SeekToCurrentErrorHandler;
@Configuration
public class KafkaConfig {
@Bean
public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory(
ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
ConsumerFactory<Object, Object> kafkaConsumerFactory) {
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
configurer.configure(factory, kafkaConsumerFactory);
factory.setErrorHandler(new SeekToCurrentErrorHandler());
return factory;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment