我正在尝试使用来自 Alvaro Videla的反向主题交换 rabbitmq 插件创建一个 celery 应用程序。工作人员似乎可以使用此交换很好地与经纪人联系,但是当我对我的任务进行主题反向路由时,不要选择“#”或“*”,就像直接交换一样。
这就是我的队列:
Queue(name='cluster',
exchange = Exchange(name='cluster',
type='x-rtopic',
delivery_mode='persistent',
durable=True),
routing_key='intel.%d.%s' % (n_cores, hostname),
durable = True,)
现在图片 2 个工作人员使用以下 routing_key
- Worker1:intel.8.host1
- Worker2:amd.2.host2
这就是我正在尝试的任务以及我所经历的路由键:
Routing key | Works? | Result | Expected
-------------------------------------------------------------------------
'intel' | OK | Nobody receives |
'intel.*' | OK | Nobody receives |
'intel.#' | WRONG | Everyone receives | just Worker1 receives
'#.host1' | WRONG | Everyone receives | just Worker1 receives
'intel.*.* | WRONG | Everyone receives | just Worker1 receives
'intel.*.host1 | WRONG | Everyone receives | just Worker1 receives
'*.2.*' | WRONG | Everyone receives | just Worker2 receives
'intel.8.host1' | OK | like direct exchange |
为了确定问题出在哪里,我测试了使用 pika 和 kombu 进行简单消息传递的插件,并且两者都运行良好,完全符合预期。所以我认为 Celery 交换(路由)消息的方式一定有问题。也许我应该创建一个自定义路由类!?
提前致谢。