即使定义了不同的队列和路由键,Celery 两个工作人员也会获得相同的任务
Celery both workers getting same task even if theres different queue and routing key defined
我的芹菜配置中有设置
CELERY_QUEUES = (
Queue('oracle', Exchange('exchange1'), routing_key='bitch'),
Queue('neo', Exchange('exchange2'), routing_key='check'),
Queue('morpheus', Exchange('exchange3'), routing_key='fromlocal'),
Queue('trinity', routing_key='getme.*'),
Queue('xxx', routing_key='showme.#'),
),
CELERY_ROUTES={
'whois.tasks.parsewhois':{
'queue':'trinity',
'routing_key':'getme.*',
},
'whois.tasks.fororacle':{
'queue':'xxx',
'routing_key':'showme.#',
},
},
我 运行 我的 2 名工人
celery -A jarvis worker -l info -Q trinity --hostname=trinity@%h
celery -A jarvis worker -l info -Q xxx --hostname=xxx@%h
现在我向我的工作人员发送任务
parsewhois.apply_async(args['20596696'],queue='trinity',routing_key='getme')
上面的任务只进入三位一体队列,但是作为我运行下面的命令:
fororacle.apply_async(args=[10],queue='xxx',routing_key='showme')
现在这个任务同时进入了trinity队列和xxx队列,都得到相同的任务,操作相同的任务。
是我没有得到主题和直接的差异,还是我的配置错误。谁能帮帮我?
尝试使用不同的工作人员名称执行 celery 命令:
celery -A jarvis worker -l info -Q trinity --hostname=trinity@%h -n worker1.%h
celery -A jarvis worker -l info -Q xxx --hostname=xxx@%h -n worker2.%h
希望对您有所帮助
我的芹菜配置中有设置
CELERY_QUEUES = (
Queue('oracle', Exchange('exchange1'), routing_key='bitch'),
Queue('neo', Exchange('exchange2'), routing_key='check'),
Queue('morpheus', Exchange('exchange3'), routing_key='fromlocal'),
Queue('trinity', routing_key='getme.*'),
Queue('xxx', routing_key='showme.#'),
),
CELERY_ROUTES={
'whois.tasks.parsewhois':{
'queue':'trinity',
'routing_key':'getme.*',
},
'whois.tasks.fororacle':{
'queue':'xxx',
'routing_key':'showme.#',
},
},
我 运行 我的 2 名工人
celery -A jarvis worker -l info -Q trinity --hostname=trinity@%h
celery -A jarvis worker -l info -Q xxx --hostname=xxx@%h
现在我向我的工作人员发送任务
parsewhois.apply_async(args['20596696'],queue='trinity',routing_key='getme')
上面的任务只进入三位一体队列,但是作为我运行下面的命令:
fororacle.apply_async(args=[10],queue='xxx',routing_key='showme')
现在这个任务同时进入了trinity队列和xxx队列,都得到相同的任务,操作相同的任务。 是我没有得到主题和直接的差异,还是我的配置错误。谁能帮帮我?
尝试使用不同的工作人员名称执行 celery 命令:
celery -A jarvis worker -l info -Q trinity --hostname=trinity@%h -n worker1.%h
celery -A jarvis worker -l info -Q xxx --hostname=xxx@%h -n worker2.%h
希望对您有所帮助