queues properly reconnect if rabbitmq is restarted
This commit is contained in:
13
nova/rpc.py
13
nova/rpc.py
@@ -74,7 +74,12 @@ class Connection(carrot_connection.BrokerConnection):
|
||||
"""Recreates the connection instance
|
||||
|
||||
This is necessary to recover from some network errors/disconnects"""
|
||||
del cls._instance
|
||||
try:
|
||||
del cls._instance
|
||||
except AttributeError, e:
|
||||
# The _instance stuff is for testing purposes. Usually we don't use
|
||||
# it. So don't freak out if it doesn't exist.
|
||||
pass
|
||||
return cls.instance()
|
||||
|
||||
|
||||
@@ -125,10 +130,12 @@ class Consumer(messaging.Consumer):
|
||||
# NOTE(vish): This is catching all errors because we really don't
|
||||
# want exceptions to be logged 10 times a second if some
|
||||
# persistent failure occurs.
|
||||
except Exception: # pylint: disable=W0703
|
||||
except Exception, e: # pylint: disable=W0703
|
||||
if not self.failed_connection:
|
||||
LOG.exception(_("Failed to fetch message from queue"))
|
||||
LOG.exception(_("Failed to fetch message from queue: %s" % e))
|
||||
self.failed_connection = True
|
||||
else:
|
||||
LOG.exception(_("Unhandled exception %s" % e))
|
||||
|
||||
def attach_to_eventlet(self):
|
||||
"""Only needed for unit tests!"""
|
||||
|
||||
Reference in New Issue
Block a user