Skip to content

Instantly share code, notes, and snippets.

@sincejune
Last active May 24, 2018 13:34
Show Gist options
  • Save sincejune/c3d9e583e47bbbcf05ee6aca8cb4ffe3 to your computer and use it in GitHub Desktop.
Save sincejune/c3d9e583e47bbbcf05ee6aca8cb4ffe3 to your computer and use it in GitHub Desktop.
simple kafka producer
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