Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list of topics/consumers method to get consumers with the specific topic #2411

Open
kennycontreras opened this issue Nov 9, 2023 · 0 comments

Comments

@kennycontreras
Copy link

kennycontreras commented Nov 9, 2023

Description

Similar to the behavior of list_consumer_groups in KafkaAdminClient, adding a new method that returns the list of topics with the corresponding consumers would be a good feature.

Suggested Solution

This method could be implemented using the KafkaAdminClient class.

admin_client = KafkaAdminClient(bootstrap_servers=['broker-1',
                                                   'broker-2',
                                                   'broker-3'],)

print(admin_client.list_topics_consumers()

[('topic_1_test', ['consumer_test_1', 'consumer_test_2']), ('topic_2_test', ['consumer_test_3', 'consumer_test_4'])]

Alternative

Inside the Kafka Consumer. A similar method can work for a specific topic, which receives a topic as a parameter and returns the consumer list.

consumer = KafkaConsumer(bootstrap_servers=['broker-1',
                                            'broker-2',
                                            'broker-3'],)

print(consumer.get_consumer('topic_1_test')

['consumer_test_1', 'consumer_test_2']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant