I'm entirely new to kafka. I got to work with simple consumer, and it was ok. Now i've got work with balanced consumer, the problem is i have only a vague idea of kafka in general.
topic = client.topics["topic_name"]
consumer_a = topic.get_balanced_consumer(consumer_group=b"group_code", zookeeper_connect="localhost:2181")
consumer_b = topic.get_balanced_consumer(consumer_group=b"group_code", zookeeper_connect="localhost:2181")
for message in consumer_a:
if message is not None:
pool.apply_async(self._handle_message, (message,))
for message in consumer_b:
if message is not None:
pool.apply_async(self._handle_message, (message,))
This is my initial idea of approach. However the loop is just staying in consumer_a. I'm not sure how to handle the loop exit. I thought of having the loops also handled my another async call, but i'm not sure if its the right way to go.
Can any one advise on the same or point to some better layman understandable docs? Or am i missing some other concept?
My requirement is to have both consumers being processed simultaneously. Thanks
edit If anyone can explain the concept of partitions it will be useful as well.