Kafka - Producer Acknowledgement

I think you should understand the acks property what has actually done and look at the also behind scenes. If that is ok, you will see this property is configured by the producer.

For example, you mustn't lose any message like an audit log. The following code how we would start our producer config:

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092,localhost:9093");
props.put("acks", "all"); //We are using acks=all in order to get the strongest guarantee we can.
props.put("retries", "3");
props.put("max.in.flight.requests.per.connection", "5");

This is a small but powerful change that has a major impact on if a message is going to arrive or not.

This images that from Kafka In Action book which represents more clear for acks property:

enter image description here

enter image description here

enter image description here


It's a producer property and is set similar to other properties you have in your code:

properties.put("acks","all");

The list of all configurable producer properties can be found here.

You might want to also look at the broker (or topic) property min.insync.replicas that is related to this producer config.