Skip to content

Instantly share code, notes, and snippets.

@amalgjose
Created December 29, 2022 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalgjose/bae43867217e880c58c61278293c2fe0 to your computer and use it in GitHub Desktop.
Save amalgjose/bae43867217e880c58c61278293c2fe0 to your computer and use it in GitHub Desktop.
Code snippet to create kafka topics
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