from kafka import KafkaProducer producer = KafkaProducer(bootstrap_servers='localhost:9092') for i inrange(1000): producer.send('fast-messages', key=str.encode('key_{}'.format(i)), value=b'some_message_bytes')
consumer.py
1 2 3 4
from kafka import KafkaConsumer consumer = KafkaConsumer('fast-messages', bootstrap_servers='localhost:9092') for message in consumer: print(message)
The code is much shorter and simpler than written in Java for the same purpose.