imo, it is invaluable to also know about this issue that makes things far more interesting and slightly more complicated.
When you enable enable.idempotence=true
, every time you send a message to the broker, you also send a sequence number
, starting from zero. Brokers store that sequence number too on their side. When you make a next request to the broker, let’s say with sequence_id=3
, the broker can look at its currently stored sequence number and say :
- if its 4 - good, its a new batch of records
- if its 3 - its a duplicate
- if its 5 (or higher), it means messages were lost
And now max.inflight.requests.per.connection
. A producer can send as many as this value concurrent requests without actually waiting for an answer from the broker. When we reach 3 (let’s say max.inflight.requests.per.connection=3
) , we start to ask the broker for the previous results (at the same time we can’t process any batches now even if they are ready).
Now, for the sake of the example, let’s say the broker says this : “1 was OK, I stored it”, “2 has failed” and now the important part: because 2 failed, the only possible thing you can get for 3 is “out of order”, which means it did not store it. The client now knows that it needs to reprocess 2
and 3
and it creates a List and resends them - in that exact order; if retry is enabled.
This explanation is probably over simplified, but this is my basic understanding after reading the source code a bit.
max.in.flight.requests.per.connection
tomax.in.flight.requests.per.session
– Shepherd