pika channel.basic_consume错误

环境为1.2.0的pika版本,参考官方demo提示channel.basic_consume获得的参数错误got multiple values for keyword argument ‘queue’ 或者别的错误。

有查询过很多方法,比如版本回退,或者由于版本不同需要修改参数位置都是都不太奏效。

把官方文档1.2.0的版本翻出来检查了一下

basic_consume(queue, on_message_callback, auto_ack=False, exclusive=False,        
              consumer_tag=None, arguments=None, callback=None)[source]


Sends the AMQP 0-9-1 command Basic.Consume to the broker and binds messages for the consumer_tag to the consumer callback. If you do not pass in a consumer_tag, one will be automatically generated for you. Returns the consumer tag.

Parameters:	
queue (str) – The queue to consume from. Use the empty string to specify the most recent server-named queue for this channel
on_message_callback (callable) –
The function to call when consuming with the signature on_message_callback(channel, method, properties, body), where

channel: pika.channel.Channel
method: pika.spec.Basic.Deliver
properties: pika.spec.BasicProperties
body: bytes

参考这个接口的介绍,加进去之后会提示未知的参数 on_message_callback或者参数位置不正确。

然后测试了许久才发现这是一个坑

实际上的顺序应该是

basic_consume(on_message_callback,queue,****)

 最后代码

channel.basic_consume(on_message_callback=callback,queue='hello',autoack=True)

 可用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值