Sobes.tech
Junior — Middle

Which message broker was used in Celery for task processing?

sobes.tech AI

Answer from AI

In Celery, the message broker most commonly used for task processing is RabbitMQ or Redis.

RabbitMQ is a full-featured message broker supporting complex routing and delivery guarantees. Redis is a simpler and faster option, often used for small projects or when high performance is required.

Example of setting up Celery with RabbitMQ:

from celery import Celery

app = Celery('tasks', broker='pyamqp://guest@localhost//')

@app.task
def add(x, y):
    return x + y

Here, pyamqp://guest@localhost// is the connection URL to RabbitMQ.

Thus, the message broker in Celery is responsible for transmitting and routing tasks between producers and workers.