Hi Roger,

> Can anything be said about the order of the messages consumed
by my consumer?

Kafka guarantees that any consumer of a given topic-partition will always
read that partition's events in exactly the same order as they were
written. So, if you create 4 consumers in a group, to consume from these 4
topic-partitions, the records received by 4 consumers are always in order.

But, in your case, your only one consumer consumed from 4 topic-partitions,
will have mixed order in the consumer side, because you don't know which
data in which partition will come first.

> Is there a way to enforce the same order of messages for every restart of
my consumer?

The solution I can think of, is to create only one partition for the topic.
So, you can always consume the data in order for every restart. Or you can
create 4 consumers in one group, to consume from 4 partitions. That works,
too.

Thank you.
Luke


On Thu, Jan 6, 2022 at 1:15 AM Roger Kasinsky <roger.kasin...@gmail.com>
wrote:

> Hi,
>
> I have a topic divided into 4 partitions. I have a consumer that needs to
> consume all messages from the topic (all messages from all 4 partitions).
> So to do that I have this consumer sitting by itself in its own consumer
> group. I'm not committing any offsets, because I want to read all messages
> again on every restart of the consumer.
>
> *Question:* *Can anything be said about the order of the messages consumed
> by my consumer? Is there a way to enforce the same order of messages for
> every restart of my consumer?*
>
> Thanks!
>
> -R
>

Reply via email to