Message brokers

Presentations

Message brokers

Message brokers and message queues

Why message brokers

Push-pull

Push-pull

Pub-sub

Pub-sub

Push-pull model with exchange

Push-pull

Message queue

Topic

Protocols

Message brokers implementations

Redis Queue

RQ

Redis Queue (RQ) - producer

from redis import Redis
from rq import Queue
  
from worker import do_work
  
q = Queue(connection=Redis())
  
for i in range(10):
    result = q.enqueue(do_work, i)
    print(result)

Redis Queue (RQ) - consumer

from time import sleep
  
def do_work(param):
    print("Working, received parameter {}".format(param))
    # simulace prĂ¡ce :-)
    sleep(2)
    print("Done")

Redis Queue (RQ) - start the worker

$ rq worker

RabbitMQ

Push-pull

Celery

Celery