看看下面的截图
我的队列与名为foo
的交换机绑定,只接收路由键为bar
的消息。我还定义了一对参数{baz: qux}
。现在我有一个如下代码:
credentials = pika.PlainCredentials(...)
parameters = pika.ConnectionParameters(...)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.basic_qos(prefetch_count=1)
channel.basic_consume(callback, queue='this_queue')
回调函数具有以下签名:
def callback(channel, method, properties, body):
....
现在的问题是:如何访问回调函数中的参数({baz: qux}
)。这可能吗?
2条答案
按热度按时间iecba09b1#
您可以使用我的RabbitMQ库amqpstorm来获取这类信息。
结果看起来像这样。
更多示例here。
sulc1iza2#
这是不可能的,因为AMQP不会在对
basic.consume
的响应中提供该信息。只要您启用了rabbitmq_management
插件(如果您拍摄了该屏幕截图,则必须启用),就可以使用HTTP API检索该信息。