I'm using Qpid Proton Python for an AMQP consumer that runs jobs which can last for +1 minute.
After the job is done, I'm getting a connection_closed
with Condition('amqp:resource-limit-exceeded', 'local-idle-timeout expired')
.
I understand this happens because my blocking job is preventing the heartbeat.
The thing that puzzles me is why I'm not getting reconnected. Debugging proton, I get to this line of code, where self.connection.state
has a value of 36, so self.connection.state & Endpoint.LOCAL_ACTIVE
returns 0.
- Why is that? Can I do something to enable reconnection?
- Is there anything I can do client-side to avoid disconnection in the first place?
here's a working code to reproduce the scenario:
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