I am using Spring Kafka first time and I am not able to use Acknowledgement.acknowledge() method for manual commit in my consumer code as mentioned here https://docs.spring.io/s
You really should follow documentation:
When using manual
AckMode
, the listener can also be provided with theAcknowledgment
; this example also shows how to use a different container factory.
@KafkaListener(id = "baz", topics = "myTopic",
containerFactory = "kafkaManualAckListenerContainerFactory")
public void listen(String data, Acknowledgment ack) {
...
ack.acknowledge();
}
There is really nowhere noted that Acknowledgment
is a bean. So, change your receive()
@KafkaListener
method signature appropriately and remove that @Autowired
for suspicious Acknowledgment
bean - it just doesn't exists because this object is a part (header) of each received message.