bigchungusdata/kafka/publisher.py

16 lines
314 B
Python
Raw Normal View History

2021-04-24 18:43:28 +02:00
#!/usr/bin/env python3
2021-04-24 19:01:26 +02:00
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)
2021-04-25 12:24:41 +02:00
except KeyboardInterrupt:
2021-04-24 19:01:26 +02:00
producer.close()