title: How does Kafka guarantee message ordering as processed by consumers across partitions?
body: <p>Source: <a href="https://kafka.apache.org/intro" rel="nofollow noreferrer">https://kafka.apache.org/intro</a></p>
  
  <blockquote>
    <p>"By having a notion of parallelism—the partition—within the topics,
    Kafka is able to provide both ordering guarantees and load balancing
    over a pool of consumer processes. This is achieved by assigning the
    partitions in the topic to the consumers in the consumer group so that
    each partition is consumed by exactly one consumer in the group. By
    doing this we ensure that the consumer is the only reader of that
    partition and consumes the data in order. "</p>
  </blockquote>
  
  <p>This only means each consumer will process messages in order, but across consumers in the same consumer group, it may still be out of order.
   Eg: 3 Partitions. Subscriber via round robin sends M1 to P1, M2 to P2, M3 to P3, then M4 to P1, M5 to P2, and M6 to P3. </p>
  
  <p>Now we have:
  P1: M1 and M4
  P2: M2 and M5
  P3: M3 and M6</p>
  
  <p>If each consuemr is tied to a single Partition, then C1 will process M1 and M4 in that order, C2 process M2 and M5, etc. How can we guarantee that M2 is processed (by C2) BEFORE M4 is processed (by C1)?</p>
  
  <p>Or am I misunderstanding something ?</p>