Created
December 29, 2022 20:59
-
-
Save amalgjose/bae43867217e880c58c61278293c2fe0 to your computer and use it in GitHub Desktop.
Code snippet to create kafka topics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Topics = ["test1","test2"] | |
class createTopics: | |
def __init__(self): | |
self.a = AdminClient({'bootstrap.servers': 'localhost:9092', | |
'debug':'broker,admin,protocol', | |
'compression.type':'none', | |
'group.id':'mygroup'}) | |
new_topics = [NewTopic(topic, num_partitions=1, replication_factor=1) | |
for topic in Topics] | |
self.a.create_topics(new_topics) | |
def main(): | |
s = createTopics() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment