使用node.js创建Celery worker [英] Creating a Celery worker using node.js
本文介绍了使用node.js创建Celery worker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 node-celery ,我们可以启用节点将Celery作业推送到任务队列。我们如何允许节点成为Celery工作者并使用队列?
Using node-celery, we can enable node to push Celery jobs to the task queue. How can we allow node to be a Celery worker and consume the queue?
推荐答案
对于Celery,如果终点是amqp。结帐 Celery.js Github 任何以amqp消费者身份启动的节点流程工作得很好。对于每个其他 self.conf.backend_type
类型,您可以拥有不同的消费者。以下示例仅适用于amqp。
For Celery if the end point is amqp. Checkout Celery.js Github any node process started as amqp consumer would work fine. For every other self.conf.backend_type
types you can have varied consumer. Following example is merely for amqp.
一个这样的例子。下面的消息
可能是Celery任务对象。
One such example. The message
below may be the Celery task object.
var amqp = require('amqp');
var connection = amqp.createConnection({ host: "localhost", port: 5672 });
connection.on('ready', function () {
connection.queue("my_celery_queue", function(queue){
queue.bind('#');
queue.subscribe(function (message) {
//eat your Celery work here
})
})
})
这篇关于使用node.js创建Celery worker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文