I am using spring-kafka 2.2.8 and writing a simple async producer with the below settings:
linger.ms : 300000,
batch.size: 33554431,
max.block.ms: 60000.
Now i'm creating a KafkaTemplate with autoFlush as false by calling the below constructor
public KafkaTemplate(ProducerFactory<K, V> producerFactory, boolean autoFlush)
Now i've a simple test producing 10 message in the span of 10 sec using the above async producer and then stopped my producer using 'Cntrl+C'. Then surprisingly, i got all the 10 messages published onto the topic and i'm sure the size of these 10 messages combined is way less than my batch.size: 33554431
Now i've two questions
- How the messages are being published instead of waiting for either linger.ms or batch.size before producing the message?
- In this scenario, what is the significance of autoFlush= false?