bigchungusdata/kafka/publisher.py

16 lines
314 B
Python

#!/usr/bin/env python3
from kafka import KafkaProducer
producer = KafkaProducer(bootstrap_servers='localhost:9092')
try:
n = 10
string = "\"" + "a" * n + "\""
binstring = string.encode('UTF-8')
while True:
producer.send('test', binstring)
except KeyboardInterrupt:
producer.close()