I am using spring-cloud-stream-binder-kafka
and have implemented stateful retry using DefaultErrorHandler
, I found that by enabling deliveryAttemptHeader
of container properties I can access the retry count or deliveryAttempt
count from message header but I am not able to enable it.
I tried to set the value to true
as below
@Bean
public ContainerCustomizer<String, Message, ConcurrentMessageListenerContainer<String, Message>> containerCustomizer(
ConcurrentKafkaListenerContainerFactory<String, Message> factory) {
ContainerCustomizer<String, Message, ConcurrentMessageListenerContainer<String, Message>> custCustomizer = container -> {
container.getContainerProperties().setDeliveryAttemptHeader(true);
};
factory.setContainerCustomizer(custCustomizer);
return custCustomizer;
}
With this configuration when I start the application and debug KafkaMessageListenerContainer.java#L1078 I still see that deliveryAttemptHeader
is disabled, and also the ContainerCustomizer
instance that I have created is also not getting called.