Separation of consumer and producer of celery

I want my mail service that I wrote to be completely separate from my flash application. I use celery with a rabbit. Therefore, I am wondering if there is a way to configure celery so that in one project I have a Flask application that sends a message to the queue (of the producer). And in another project, I have a celery instance that listens to the message and performs the (consumer) task. Am I still confused about how the message will work that way? Am I putting an API (which sends an email) in my flash app or celery project? Ultimately, I would like to have a Flask application and a Celery instance in different EC2 instances - with rabbitmq acting as a message broker.

Thank you for your help!

+7
python flask celery rabbitmq
source share
1 answer

You can use the Celery send_task function to send a task via RabbitMQ to a worker using the task name. You still need to import a module that has a celery application:

If the task is not registered in the current process, you can use send_task () to call the task by name.

Example:

from yourmodule.yourapp import celery celery.send_task("yourtasksmodule.yourtask", args=["Hello World"]) 
+5
source share

All Articles