Suppose, I have one topic with 6 partitions and 2 consumers where P1, P2, P3 processed by C1 and P4, P5, P6 processed by C2. Let us say user data U1 always goes to P1, U2 to P2 and so on.
So,
C1 maintains state of users U1, U2, U3
C2 maintains state of users U4, U5, U6.
Now let us say we add one more consumer C3 so rebalancing happens and now
P1, P2, P3 -> C1
P4, P5 -> C2
P6 -> C3
So my application was maintaining user U6 state in C2 but now U6 data is flowing to C3
Now here somehow U6 state from C2 should flow to C3. So How this is achieved in Kafka knowing that its very common problem
OR
If Kafka does not provide any support, then how this problem is solved generally ... Is there any design pattern for solving it ?