import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.listener.CommonContainerStoppingErrorHandler;
+import org.springframework.kafka.listener.CommonErrorHandler;
import java.util.function.Consumer;
}
@Bean
- public KafkaListenerContainerFactory<?> batchFactory(ConsumerFactory<String, Long> consumerFactory)
+ public KafkaListenerContainerFactory<?> batchFactory(
+ ConsumerFactory<String, Long> consumerFactory,
+ CommonErrorHandler errorHandler)
{
ConcurrentKafkaListenerContainerFactory<String, Long> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory);
+ factory.setCommonErrorHandler(errorHandler);
factory.setBatchListener(true);
return factory;
client-id: ${consumer.client-id}
auto-offset-reset: ${consumer.auto-offset-reset}
group-id: ${consumer.group-id}
- value-deserializer: org.springframework.kafka.support.serializer.ErrorHandlingDeserializer
- properties:
- spring.deserializer.value.delegate.class: org.apache.kafka.common.serialization.LongDeserializer
+ value-deserializer: org.apache.kafka.common.serialization.LongDeserializer
logging:
level:
root: INFO