queueing-consumer.py 541 Bytes
Newer Older
Nane Kratzke's avatar
Nane Kratzke committed
1
2
3
4
5
6
7
8
9
10
import os, time, random, json, socket
import redis
from messaging import MQueue

host = os.environ.get("REDIS_SVC", "redis-svc")
port = int(os.environ.get("REDIS_PORT", "6379"))
channel = os.environ.get("CHANNEL", "xqueue")

queue = MQueue(channel, redis.Redis(host=host, port=port, db=0))

Nane Kratzke's avatar
Nane Kratzke committed
11
for since, msg in queue.listen():
Nane Kratzke's avatar
Nane Kratzke committed
12
    # We would normally process the messages here.
Nane Kratzke's avatar
Nane Kratzke committed
13
    # However, to avoid overflowing the log we skip message processing.
Nane Kratzke's avatar
Nane Kratzke committed
14
15
16
    # You can print the message, if you want.
    # print(f"{ since }: { msg }")
    print()