【发布时间】:2017-03-01 20:43:30
【问题描述】:
当我手动删除我的 PikaClient 使用的队列时,什么也没有发生。我可以重新创建具有相同名称的队列,但通道已停止使用队列(正常,因为我已将其删除)。但是我想在消费队列被删除时收到一个事件。
我预计频道会自动关闭,但从未调用过 «on_channel_close_callback»。 «basic_consume» 在关闭时不提供任何回调。 还有一点很重要,我必须使用 TornadoConnection。
鼠兔:0.10.0 蟒蛇:2.7 龙卷风:4.3
谢谢你的帮助。
class PikaClient(object):
def __init__(self):
# init everything here
def connect(self):
pika.adapters.tornado_connection.TornadoConnection(connection_param, on_open_callback=self.on_connected)
def on_connected(self, connection):
self.logger.info('PikaClient: connected to RabbitMQ')
self.connected = True
self.connection = connection
self.connection.channel(self.on_channel_open)
def on_open_error_callback(self, *args):
self.logger.error("on_open_error_callback")
def on_channel_open(self, channel):
channel.add_on_close_callback(self.on_channel_close_callback)
channel.basic_consume(self.on_message, queue=self.queue_name, no_ack=True)
def on_channel_close_callback(self, reply_code, reply_text):
self.logger.error("Consumer was cancelled remotely, shutting down", reply_code=reply_code, reply_text=reply_text)
【问题讨论】:
标签: python rabbitmq tornado pika