Open jason19970210 opened 2 years ago
@jason19970210 use .flush() on producer at the end.
if __name__ == '__main__':
producer.send(topic, value=b'message')
producer.flush()
for content KafkaProducer send message in async call, first add message in local buffer and than send it to topic. in first case your script will exit with KafkaProducer instance immediately after adding it to local buffer even before producer get change to send it to topic.
Try to compare these 2 sample below
So once standalone the
producer.send
, the consumer cant get the new data, but if we add the while 1 statement, then messages are run regularly.Please have a look on the way to explain or fix !!! Thanks a lot !!!