I want to introduce multiprocessing in my code using celery. But currently my queue implementation is in Kafka.
Currently celery website mentions of only these 4 brokers: http://docs.celeryproject.org/en/master/getting-started/brokers/index.html#broker-overview
Is it possible to integrate Celery with Kafka something similar to RabbitMQ mentioned below:
from celery import Celery
app = Celery('tasks', broker='pyamqp://guest@localhost//')
@app.task
def add(x, y):
return x + y
Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well. On the other hand, Kafka is detailed as "Distributed, fault tolerant, high throughput pub-sub messaging system".
Confluent develops and maintains confluent-kafka-python on GitHub, a Python Client for Apache Kafka® that provides a high-level Producer, Consumer and AdminClient compatible with all Kafka brokers >= v0. 8, Confluent Cloud and Confluent Platform.
DoorDash heavily relies on the Infrastructure-As-Code principle and most of the resource creation, from Kafka topic to service configurations, involves pull requests to different terraform repositories.
There was discussion on having kafka as broker for celery, And there is a partial implementation of it. I hope this helps you
https://github.com/celery/kombu/issues/301
Looks like it will be available this Oct 31 or so.
https://github.com/celery/kombu/milestone/2
As you are searching for multiprocessing solution for Kafka I would recommend to take a look at Faust library.
Here is an example (very close to yours) in comparison with Celery:
https://faust.readthedocs.io/en/latest/playbooks/vscelery.html
import faust
app = faust.App('myapp', broker='kafka://')
@app.agent()
async def add(stream):
async for op in stream:
yield op.x + op.y
Also one of the creators of Faust is the author of Celery.
I am telling that because at this moment already 7 years have passed since the creation of the ticket mentioned by @user3382968, and still without progress.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With