Created
November 23, 2020 17:10
-
-
Save nithyadurai87/089138a14b0bca8024833fd3af03e54d to your computer and use it in GitHub Desktop.
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
from pykafka import KafkaClient | |
import json | |
import time | |
client = KafkaClient(hosts='localhost:9092') | |
topic = client.topics['dataets'] | |
producer = topic.get_sync_producer() | |
producer.produce(b'test message') | |
for e in range(1000): | |
data = {'number' : e} | |
print(data) | |
info_as_json = json.dumps(data) | |
producer.produce(info_as_json.encode('ascii')) | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment