title: Ordering guarantees when using idempotent Kafka Producer
body: <p>I am using Kafka 1.0.1 in my application and I have started using the Idempotent Producer feature that was introduced in 0.11, and I've having trouble understanding the ordering guarantees when using the Idempontent feature.</p>
  
  <p>My producer's configuration is:</p>
  
  <p><code>enable.idempotence = true</code></p>
  
  <p><code>max.in.flight.requests.per.connection = 5</code></p>
  
  <p><code>retries = 50</code></p>
  
  <p><code>acks = all</code></p>
  
  <p><em>According to the documentation:</em></p>
  
  <p><strong>retries</strong></p>
  
  <blockquote>
    <p>Setting a value greater than zero will cause the client to resend any record whose send fails with a potentially transient error. Note that this retry is no different than if the client resent the record upon receiving the error. Allowing retries without setting max.in.flight.requests.per.connection to 1 will potentially change the ordering of records because if two batches are sent to a single partition, and the first fails and is retried but the second succeeds, then the records in the second batch may appear first.</p>
  </blockquote>
  
  <p><strong>enable.idempotence</strong>  </p>
  
  <blockquote>
    <p>When set to 'true', the producer will ensure that exactly one copy of each message is written in the stream. If 'false', producer retries due to broker failures, etc., may write duplicates of the retried message in the stream. Note that enabling idempotence requires max.in.flight.requests.per.connection to be less than or equal to 5, retries to be greater than 0 and acks must be 'all'. If these values are not explicitly set by the user, suitable values will be chosen. If incompatible values are set, a ConfigException will be thrown.    </p>
  </blockquote>
  
  <p>My configuration seems to be according to the requirements, but they don't seem to align.</p>
  
  <p>Another question I have has to do with the <a href="https://kafka.apache.org/10/javadoc/org/apache/kafka/common/errors/OutOfOrderSequenceException.html" rel="noreferrer">OutOfOrderSequenceException</a>:
  According to the documentation, if I get this exception it means that the producer is in risk of becoming out of order. But if my producer is configured with <code>max.in.flight.requests.per.connection = 5</code> and let's say that the second request got the out of order exception, what happens to all of the following requests that are already in flight? will this mean that I am for sure out of order?</p>