Skip to content
Snippets Groups Projects
Commit 2aec88d4 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Add script to print Kafka events

parent 637a42b5
No related branches found
No related tags found
1 merge request!452Send Kafka notifications when correction is complete
"""Print Kafka events sent by the webservice.
"""
import json
import os.path as osp
import yaml
from kafka import KafkaConsumer
conf_file = osp.join(osp.dirname(__file__), 'webservice.yaml')
with open(conf_file, "r") as f:
config = yaml.safe_load(f)
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)...")
for record in kc:
msg = json.loads(record.value.decode())
print(msg)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment