Qpid Proton Python:长时间工作后不重新连接

Tuk*_*Tuk 5 python activemq-classic amqp qpid

我正在将 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。

  1. 这是为什么?我可以做些什么来启用重新连接吗?
  2. 首先,我可以在客户端做些什么来避免断开连接?

这是重现场景的工作代码:

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 on_message(self, event):
        print('sleeping 60')
        sleep(60)
        print('done sleeping')
        self.accept(event.delivery)

    def on_connection_error(self, event):
        print('connection_error', event.connection.condition, event.connection.remote_condition)


try:
    Container(ExampleConsumer('examples')).run()
except KeyboardInterrupt: pass
Run Code Online (Sandbox Code Playgroud)