V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ray1888
V2EX  ›  程序员

celery 广播问题

  •  
  •   ray1888 ·
    ray1888 · 2018-07-07 15:10:35 +08:00 · 2418 次点击
    这是一个创建于 2091 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我按官网文档上面的来添加了这段代码在 celery_config 里面

    CELERY_QUEUES = (Broadcast(name='broadcast_tasks',),)
    
    #
    CELERY_ROUTES = {
        'celery_task.method.get_new_method': {
          'queue': 'broadcast_tasks',
          # 'exchange': Exchange(type='fanout')
        }
    }
    

    启动的时候会直接报错

    PreconditionFailed: Exchange.declare: (406) PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'broadcast_tasks' in vhost '/': received 'fanout' but current is 'direct'
    

    环境是 py2.7+ celery4.2 + rabbitmq 3.6 是什么原因导致这个问题,搜了 stackoverflow 也没看到有好的解决方法

    2 条回复    2019-08-26 17:33:30 +08:00
    ray1888
        1
    ray1888  
    OP
       2018-07-07 16:38:21 +08:00
    换了使用在 app 文件中启动前加了如下配置可以启动了,但是现象比较奇怪
    ```
    app.conf.task_queues = (Broadcast('broadcast_tasks'),)
    app.conf.task_routes = {
    'celery_task.method.get_new_method': {
    'queue': 'broadcast_tasks',
    'exchange': 'broadcast_tasks'
    }
    }
    ```
    从 rabbitmq 控制台上面能够看到信息被推进了 broadcast 信道,但是无法被消费
    hustlibraco
        2
    hustlibraco  
       2019-08-26 17:33:30 +08:00
    @ray1888 我也遇到无法被消费的问题,请问解决了吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   981 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:09 · PVG 04:09 · LAX 13:09 · JFK 16:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.