Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 885 Bytes

README.md

File metadata and controls

53 lines (45 loc) · 885 Bytes

xq

A distributed queue system built on top of Redis

install

pip3 install -r requirements.txt

Use

Producer

import redis
from xq.queue import Queue

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# enqueue
q.enqueue("this is a message")

Consumer

import redis
from xq.queue import Queue

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
# poll
messages = q.poll()
for message in messages:
    print(message.body)

Use Worker

import redis
from xq.queue import Queue
from xq.worker import Worker

# connect to Redis
r = redis.Redis(host='localhost', port=6379)
# create queue
q = Queue(r, "test_queue")
worker = Worker(q, process_message)
worker.run()

def process_message(message):
    print(message)