How do I recover from UnroutableError after RabbitMQ is restarted? #2026
Replies: 2 comments
-
|
Both pika/pika#1543 and this issue are missing important information - specifically, the RabbitMQ and Erlang version you're using, as well as details about your RabbitMQ topology and application code Again, your symptoms point to something specific in your application code or environment. What happens when you run your application against a single-node RabbitMQ running outside of k8s? I suspect you don't see this issue. Here are some assumptions I've made (please correct them if wrong):
|
Beta Was this translation helpful? Give feedback.
-
|
OK, so here’s the sequence of method call in my topic consumer (which is essentially a copy of the reference example): -
My def on_channel_closed(self, channel, reason):
"""Invoked by pika when RabbitMQ unexpectedly closes the channel.
Channels are usually closed if you attempt to do something that
violates the protocol, such as re-declare an exchange or queue with
different parameters. In this case, we'll close the connection
to shutdown the object.
:param pika.channel.Channel: The closed channel
:param Exception reason: why the channel was closed
"""
_LOGGER.warning('Channel %i was closed: %s', channel, reason)
self.close_connection()and def close_connection(self):
self._consuming = False
if self._connection.is_closing or self._connection.is_closed: # type: ignore
_LOGGER.info('Connection is closing or already closed')
else:
_LOGGER.info('Closing connection')
self._connection.close() # type: ignoreand def on_connection_closed(self, _unused_connection, reason):
"""This method is invoked by pika when the connection to RabbitMQ is
closed unexpectedly. Since it is unexpected, we will reconnect to
RabbitMQ if it disconnects.
:param pika.connection.Connection connection: The closed connection obj
:param Exception reason: exception representing reason for loss of
connection.
"""
self._channel = None
if self._closing:
self._connection.ioloop.stop() # type: ignore
else:
_LOGGER.warning('Connection closed, reconnect necessary: %s', reason)
self.reconnect()and, finally, def reconnect(self):
"""Will be invoked if the connection can't be opened or is
closed. Indicates that a reconnect is necessary then stops the
ioloop.
"""
self.should_reconnect = True
self.stop()I guess the damage is done in
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I restart RabbitMQ otehr Pods in my cluster (specifically Python Pods) that had connected to the service encounter NO ROUTE errors. No matter what I do I do not seem to be able to recover from the problem without restarting the client (Python) Pod. But, surely, I should be able to recover from the problem without restarting the client Pod?
I've used
pikaand the official rabbit ampq driver, both behave the same. In the discussion there (pika/pika#1543) the concern was why I don't get a connection failure: -Beta Was this translation helpful? Give feedback.
All reactions