I've set up an instance of Apache Kafka via the Bitnami Kafka Image, localhost:9092, and created a topic ('testtopic'). I'm trying to write events to the topic from Python by creating a producer. The console producer and console consumer I'm using in the terminal appear to be working (i.e., I can write an event in the terminal with a console terminal and read those events with a console consumer), but I can't get the console consumer to read anything I try to write in via my python-initiated producer. Help is appreciated!
from kafka import KafkaProducer
producer = KafkaProducer(linger_ms=10)
TOPIC = 'testtopic'
msg = "Test message"
b_msg = bytearray(msg.encode("utf-8"))
producer.send(TOPIC, b_msg )
producer.flush()
I've tried editing some of the arguments I pass into the KafkaProducer, but I continue to get no response. I can print the messages I want to send, and if I loop through a series of messages, calling the send and flush methods on the producer class object, I can get all the messages to print, but none of them seem to write to the topic, but also no exceptions are raised.