title: How do co-partitioning ensure that partition from 2 different topics end up assigned to the same Kafka Stream Task?
body: <p>while i understand the pre-requisite of having co-partitioning as explained here <a href="https://stackoverflow.com/questions/45545181/why-does-co-partitioning-of-two-kstreams-in-kafka-require-same-number-of-partiti">Why does co-partitioning of two Kstreams in kafka require same number of partitions for both the streams?</a> , I do not understand the mechanism that make sure that the partitions of each topic that have the same key, get assigned to the same KAFKA Stream. I do not see how the consumer group of KAFKA would enable that. </p>
  
  <p>The way i understand it is that, we have 2 independent consumer groups, which actually may have the same name, because it is the same kafka stream application, although the suscription to each topic is independent from each other. </p>
  
  <p>Somehow, the consumers in each consumer group, get assigned to partition that contains the same key. I did not know that consumer assignment to partition could be related to the content of the partitions. So far i though it was random. </p>
  
  <p>Can someone explain that part ? </p>