我正在将 Qpid Proton Python 用于 AMQP 使用者,该使用者运行的作业可以持续 +1 分钟。
工作完成后,我得到了一个connection_closedwith Condition('amqp:resource-limit-exceeded', 'local-idle-timeout expired')。
我了解发生这种情况是因为我的阻塞工作阻止了心跳。
令我困惑的是为什么我没有重新连接。调试质子,我得到了这行代码,其中self.connection.state的值为36,因此self.connection.state & Endpoint.LOCAL_ACTIVE返回 0。
这是重现场景的工作代码:
from __future__ import print_function
from time import sleep
from proton.handlers import MessagingHandler
from proton.reactor import Container
class ExampleConsumer(MessagingHandler):
def __init__(self, queue):
super().__init__(2, False)
self.queue = queue
def on_start(self, event):
self.container = event.container
self.conn = event.container.connect(url='localhost:5672')
self.receiver = event.container.create_receiver(self.conn, self.queue)
print('listening for new messages on /' + self.queue)
def …Run Code Online (Sandbox Code Playgroud)