The scenario i want to implement is consume a message from Kafka , process it, if some condition fails i do not wish to acknowledge the message. For this i found in the spring cloud stream reference documentation,
autoCommitOffset Whether to autocommit offsets when a message has been processed. If set to false, an Acknowledgment header will be available in the message headers for late acknowledgment.
Default: true.
My question is after setting autoCommitOffset to false, how can i acknowledge a message? A Code example would be hugely appreciated.
I've provided an answer to the question here https://github.com/spring-cloud/spring-cloud-stream/issues/575
Essentially it comes down to setting
spring.cloud.stream.kafka.bindings.input.consumer.autoCommitOffset=false
and then handling the acknowledgment header: