I’m attempting to use Apache Kafka to create a KafkaConsumer in Python. I’m running the following code in a Text DAT, but when I run the script TD hangs indefinitely.
[code]from kafka import KafkaConsumer
consumer = KafkaConsumer(‘checkout’,bootstrap_servers=[‘SERVER:PORT’],security_protocol=‘SSL’,ssl_cafile=‘/etc/ssl/cert.pem’,ssl_certfile=‘kafka.cert’,ssl_keyfile=‘kafka.key’)
for msg in consumer:
op(‘trigger1’).par.triggerpulse.pulse()
[/code]
When I run the script in an external Python application the Consumer takes 5 seconds to load, then the events start pouring in. I’m thinking this needs to be run in a thread, but in this particular case the thread doesn’t end, it streams events till the script is killed. Is my thinking correct or is there a better way to build this? If threading is the way to go, I’m assuming I need to output to a Queue?