0
votes

I have two consumer servers with same group id subscribed the same topic. A kafka server is running with only one partition. As far as I know, the message should be consumed randomly in those two consumer servers. But now it seems to be always the same consumer server A consume messages, another one does not consume messages.If I stop consumer server A, another one will work fine. What I expect that they can consume message randomly.

1
Which factors will affect the consumer server priority? network or something else?fcbflying

1 Answers

3
votes

To be able to use two consumer instances in parallel you need at least two partitions in the topic. A consumer will bind to one or more partitions of a topic and other consumers with the same groupId will not claim partitions which already have consumers bound to them. If a consumer fails/crashes, the partition will be released and then picked up by another consumer instance.