Send celery task message to rabbitmq

Viewed 2889

I usually use celery with Django and run shared tasks in Django.

But for specific case, I want to add task queue to rabbitmq manually without running Django or celerybeat.

Is there any simple python script or shell cmd to do that?

1 Answers

You can use the send_task method to queue a task to an arbitrary celery broker. But, you do have to know the app name and broker url so that you can send the task to the right place.


from celery import Celery

app = Celery('app_name', broker='pyamqp://guest@localhost//')
app.send_task('namespace.my_task', kwargs={
    'arg1': 'value1',
    'arg2': 'value2',
})
Related