actumn / celery.node

Celery task queue client/worker for nodejs
https://celery-node.js.org
MIT License
278 stars 73 forks source link

Support manual routing. #94

Open comfuture opened 1 year ago

comfuture commented 1 year ago

Description

Celery can specify the queue name and routing_key manually at the task message.

https://docs.celeryq.dev/en/stable/userguide/routing.html#manual-routing

from my.tasks import add
add.apply_async(args=[1, 2], queue='math_tasks', routing_key='math.queue')

I hope that celery.node can also receive the queue name as a variable argument of the client.createTask() method.


// suggestion 1. pass the queue name as 2nd argument of `createTask` method.
const task = client.createTask('add', {queue: 'math_tasks'})
const answer = await task.applyAsync([1, 2]).get()

// or

// suggestion 2. pass the queue name as 3rd argument of `task.applyAsync` method.
// This is a little more Python-like, but requires passing an empty argument when no kwargs are present.
const task = client.createTask('add')
const answer = await task.applyAsync([1, 2], {}, {queue: 'math_tasks'}).get()