2014-01-06 28 views

回答

2

這是固定帶拉出請求#346。只是等待一個新的版本:)

0

這發生在我在RabbitMQ 3.3.3如果我關閉我的BlockingConnection之前,通道是完全關閉。解決方案是在通道關閉回調中關閉連接。此外,請使用context manager自動關閉頻道。

params = pika.ConnectionParameters(host=self._host, port=self._port) 
connection = pika.BlockingConnection(params) 
with contextlib.closing(connection.channel()) as channel: 
    # Close connection once channel is closed 
    def closeConnection(channel, replyCode, replyText): 
     connection.close() 
    channel.add_on_close_callback(closeConnection) 

    # Declare a durable queue; we will use the default exchange for 
    # simple key-based routing 
    channel.queue_declare(queue=self._queueName, durable=True) 
    ... 
    ... 
相關問題