kafka-php icon indicating copy to clipboard operation
kafka-php copied to clipboard

How to set consumerId

Open khizarsonu opened this issue 7 years ago • 8 comments

Hello,

I have explored this module and it's difficult for me to set consumerId, I have seen there is an option to set clientid, but I guess clientid is different consumerid is different.

Looking for help

khizarsonu avatar Apr 04 '18 06:04 khizarsonu

@khizarsonu I think your consumerId is the memberID generated by join group, not allowed to set up

nmred avatar Apr 04 '18 06:04 nmred

You can refer to

http://kafka.apache.org/protocol.html#The_Messages_JoinGroup

nmred avatar Apr 04 '18 06:04 nmred

isn't there any way to manually & explicitly set consumer id while creating a single consumer? Kafka's API in other languages do provide such options.

ashishnetworks avatar Apr 04 '18 06:04 ashishnetworks

It is not supported at present

nmred avatar Apr 04 '18 07:04 nmred

@khizarsonu can you please describe the reason why you need to set the consumer.id? Aren't you confusing it with group.id?

isn't there any way to manually & explicitly set consumer id while creating a single consumer? Kafka's API in other languages do provide such options.

Not in the new (well, not so new) consumer configuration: http://kafka.apache.org/documentation.html#newconsumerconfigs

There was an option in the past but it was removed because it didn't make sense to have it available.


Expanding what @nmred said: the consumer.id is an option used by the group manager to track which consumers are in the ACTIVE state within a group, it must be generated automatically to avoid clashes and potentially mess up with that verification.

lcobucci avatar Apr 04 '18 08:04 lcobucci

Actually, I was using single consumer, NOT consumer group. And in my use case, I need to change my machine every few weeks. But when my machine is changed, somehow my consumer ID is changed too and so I start receiving messages from earliest available offset since Kafka considers me to be a different consumer which I'm not. So I was looking for a way to somehow set the consumer.id explicitly so that even if my machines gets changed Kafka should remember me as old consumer and should give me messages after last committed offset and not from earliest available offset

ashishnetworks avatar Apr 04 '18 10:04 ashishnetworks

@ashishnetworks in Kafka every consumer is part of a group, like always. You can have a single consumer in a group but it's the group who is responsible for controlling the offset of the consumers related to it. So what you need is to indeed set the group.id and that will do what you want.

lcobucci avatar Apr 04 '18 12:04 lcobucci

okay thank you @lcobucci , I will try with group Id.

ashishnetworks avatar Apr 05 '18 06:04 ashishnetworks