confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

Prioritizing poll between topics in single consumer

Open YechielFino opened this issue 2 years ago • 2 comments

Description

Hi , General guidance / question we couldn't find good source online:

we have a consumer who is working on 2 topics, internal_events and external_events. We want to prioritize the external_events as they are important for our state maintenance, however we can't find any way to prioritize between 2 topics, to make sure that while there are messages in the external_events topic, we try to get X messages first from it and if not enough msgs get also from "internal_events" topic.

The bucket assign approach make sense if its within the same topic, but if we separate between topics, is there a way to achieve this within a single consumer?

How to reproduce

consumer.subscribe(topics) consumer.poll(1) - it gets a msg from either topics... so if "internal_events" is flooded with events, the important external_events are not being processed.

YechielFino avatar Nov 19 '23 19:11 YechielFino

You should use two separate threads for this, with unique consumers that you can pause/resume rather than one subscribed to both topics.

OneCricketeer avatar Nov 20 '23 20:11 OneCricketeer

@YechielFino wanted to follow up to see if this issue should remain open. Did the previous suggestion help or are you still looking for guidance on the single consumer case?

nhaq-confluent avatar Feb 12 '24 17:02 nhaq-confluent