我想获取队列中所有待处理的任务以保存在数据库中。 并从队列中删除这些任务。
我知道channel.purgeQueue
,但只会删除它们。
我需要知道队列中的待处理任务。
如何获取它们
答案 0 :(得分:0)
这是RabbitMQ的基本功能,请阅读:
https://www.rabbitmq.com/tutorials/tutorial-two-python.html
您要查找的代码是:
Array
(
[0] => Array
(
[user_id] => 10
[directors_count] => 6
)
[1] => Array
(
[user_id] => 12
[directors_count] => 5
)
[2] => Array
(
[user_id] => 15
[directors_count] => 2
)
[3] => Array
(
[user_id] => 16
[directors_count] => 1
)
[4] => Array
(
[user_id] => 17
[directors_count] => 0
)
)
执行def callback(ch, method, properties, body):
print " [x] Received %r" % (body,)
### PUT_YOUR_CODE_HERE
print " [x] Done"
ch.basic_ack(delivery_tag = method.delivery_tag)
channel.basic_consume(callback,
queue='hello')
时,消息将从队列中删除
答案 1 :(得分:0)