Set a parameter
max.in.flight.requests.par.connection=1
Copy the code
This way, no other messages are sent to the broker while the producer tries to send the first message. This affects performance and is only used when ordering is strictly required.