"""Print Kafka events sent by the webservice. """ import json from kafka import KafkaConsumer from .config import webservice as config topic = config['kafka']['topic'] brokers = config['kafka']['brokers'] print(f"topic: {topic!r}") print(f"brokers: {brokers!r}") kc = KafkaConsumer(topic, bootstrap_servers=brokers) print("Waiting for messages (Ctrl-C to quit)...") try: for record in kc: msg = json.loads(record.value.decode()) print(msg) except KeyboardInterrupt: print("Exiting") kc.close()