summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2010-06-23 23:24:38 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2010-06-23 23:24:38 -0700
commit6242413372d5b4540bfdeb33eaaa852fa689fd6f (patch)
tree12bcd1967ef1be61691afb8c854df8bc1281d164
parent4ba6802ae5d6fb4e0d8ed7bbbaf2cca94a6d1118 (diff)
downloadnova-6242413372d5b4540bfdeb33eaaa852fa689fd6f.tar.gz
nova-6242413372d5b4540bfdeb33eaaa852fa689fd6f.tar.xz
nova-6242413372d5b4540bfdeb33eaaa852fa689fd6f.zip
Fix queue connection bugs
Fix logging if queue disconnects Reconnect if queue comes back
-rw-r--r--nova/rpc.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/nova/rpc.py b/nova/rpc.py
index 54843973a..3019beba0 100644
--- a/nova/rpc.py
+++ b/nova/rpc.py
@@ -63,6 +63,10 @@ class Connection(connection.BrokerConnection):
cls._instance = cls(**params)
return cls._instance
+ @classmethod
+ def recreate(cls):
+ del cls._instance
+ return cls.instance()
class Consumer(messaging.Consumer):
# TODO(termie): it would be nice to give these some way of automatically
@@ -79,9 +83,20 @@ class Consumer(messaging.Consumer):
attachToTornado = attach_to_tornado
- @exception.wrap_exception
def fetch(self, *args, **kwargs):
- super(Consumer, self).fetch(*args, **kwargs)
+ try:
+ if getattr(self, 'failed_connection', False):
+ # attempt to reconnect
+ self.conn = Connection.recreate()
+ self.backend = self.conn.create_backend()
+ super(Consumer, self).fetch(*args, **kwargs)
+ if getattr(self, 'failed_connection', False):
+ logging.error("Reconnected to queue")
+ self.failed_connection = False
+ except Exception, ex:
+ if not getattr(self, 'failed_connection', False):
+ logging.exception("Failed to fetch message from queue")
+ self.failed_connection = True
def attach_to_twisted(self):
loop = task.LoopingCall(self.fetch, enable_callbacks=True)