2
votes

I am trying to send a task from celery worker on Machine A to celery worker on Machine B with the help of "task name".

All the tasks are defined on Machine B, and only one task is on Machine A. I'd like to pass a task_name to Machine A worker and execute the task with the same task_name on Machine B.

How do I communicate with one another.

Do we keep the same broker_url in both the workers or what?

I am using Redis as the Broker url and result backend.

1

1 Answers

1
votes

(1) you can do this with separate brokers for Machine A and Machine B. redis, by default, usually gives you sixteen databases, numbered 0-15. So you can very easily assign db 0 to use for the broker for A and assign db 1 for the broker for B. Then to send a task from B to A, you can use send_task:

from celery import Celery
app = Celery('redis://myredis-server:6379/0')
app.send_task('task_name', kwargs={ 'param1': 'value1' })

(2) you can also do this with one broker if you use separate celery queues.