Last active
May 24, 2018 13:34
-
-
Save sincejune/c3d9e583e47bbbcf05ee6aca8cb4ffe3 to your computer and use it in GitHub Desktop.
simple kafka producer
This file contains hidden or 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 kafka import KafkaProducer | |
import time | |
import json | |
producer = KafkaProducer(value_serializer=lambda m: json.dumps(m).encode('utf-8'), bootstrap_servers=['localhost:9092']) | |
while True: | |
time.sleep(0.001) | |
producer.send(topic, {'message': time.time()}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment