rabbitpy使用purge不生效
需要等消费者确认或者指明了不确认才能使用这个命令,而不能直接使用
#! /usr/bin/env python3
# -*- coding:utf-8 -*
import rabbitpy
import sys
url = 'amqp://guest:guest@localhost:5672/%2F'
connecttion = rabbitpy.Connection(url)
channel = connecttion.channel()
queue = rabbitpy.Queue(channel,'example')
# print(message.properties)
# sys.exit(0)
# queue.purge()
# sys.exit(0)
while len(queue) > 0:
message = queue.get(True)
# print(message)
# sys.exit(0)
message.pprint()
# print('message:')
# print('ID: %s' % message.properties['message_id'])
# print('Time: %s' % message.properties['timestamp'].isoformat())
# print("Body:%s" % message.body)
message.ack() #不确认的话purge()是不会生效的
print("hello")
queue.purge()