使用节点芹菜(MeteorJS)和ampq后端时,Celery不会返回结果

我刚开始使用Celery,一个芹菜工作人员用Python编写,并且使用node-celery从node / Meteor发送任务。

为什么没有从client.call()返回result ? Python工作控制台显示任务已经发送并成功处理。 但没有任何事情ready ,似乎正在开火!

使用Celery 3.1.7,RabbitMQ 3.2.2,node-celery 0.1.1,Meteor 0.7.0.1

节点

 var celery = Meteor.require('node-celery'), client = celery.createClient({ CELERY_BROKER_URL: 'amqp://guest:guest@localhost:5672//', CELERY_RESULT_BACKEND: 'amqp://', CELERY_TASK_SERIALIZER: 'json', CELERY_RESULT_SERIALIZER: 'json' }); client.on('error', function(err) { console.log(err); }); client.on('connect', function() { console.log('Connected') var results = client.call('tasks.echo', ['Hello world'], function(result) { console.log('results:' + result); }); results.on('pending', function(result) { console.log('pending: ' + result) }); results.on('ready', function(result) { console.log(result) }); }); 

产量

 Connected 

编辑:

你现在可以find我的芹菜包装的气氛,或者只需安装mrt install celery


我已经经历了设置这个的痛苦,但已经出现在另一边。

我不得不分支node-celeryhttps://github.com/nathan-muir/node-celery )和node-amqphttps://github.com/nathan-muir/node-amqp )来创build可行的版本。

我已经把所有这一切都装入了meteor包中,但是我还没有把所有东西都清理干净。 ( https://github.com/nathan-muir/meteor-celery )。 我想用Fibers / Futures包装它,而不是留下它的callback风格(pull requests welcome。

该包从Meteor.settings.celery读取,所以创build一个设置文件,如:

 { "celery": { "CELERY_BROKER_URL": "amqp://guest@localhost:5672//", "CELERY_RESULT_BACKEND": "amqp", "CELERY_SEND_TASK_SENT_EVENT": true } } 

然后用meteor --settings path/to/settings.json启动meteor

我也运行我的客户端和工作人员的事件启用( celery worker -E --config=xx ),所以我可以使用芹菜监测工具(和我自己的自定义cloudwatch统计监测https://github.com/nathan-muir/芹菜-watchwatch

如果您还有其他问题,请随时在评论中提问。

我不使用meteor,但是我有一个类似的问题, node-celery 。 希望这会帮助别人在这个问题上绊倒。

在我的情况下,我能通过在celeryconfig.py文件中添加以下内容来解决它

 CELERY_TASK_SERIALIZER = 'json' CELERY_ACCEPT_CONTENT = ['json'] CELERY_RESULT_BACKEND = 'amqp' CELERY_RESULT_SERIALIZER = 'json' 

来自nodejs的我的节点 – 芹菜调用看起来像这样:

 var client = celery.createClient({ CELERY_BROKER_URL: photobutikConfig.tracer.brokerURL, CELERY_RESULT_BACKEND: 'amqp', CELERY_RESULT_SERIALIZER: 'json'}), tracerRequestType = ['tracer.tasks', requestType].join('.'); client.on('connect', function() { var result = client.call(tracerRequestType, [payload]); result.on('ready', function (result) { client.broker.destroy(); }); });