Create a new AMQP connection by default.

This commit is contained in:
Soren Hansen
2011-02-11 12:27:50 +01:00
parent 43028043d4
commit 5c034ffc24

View File

@@ -46,7 +46,7 @@ LOG = logging.getLogger('nova.rpc')
class Connection(carrot_connection.BrokerConnection): class Connection(carrot_connection.BrokerConnection):
"""Connection instance object""" """Connection instance object"""
@classmethod @classmethod
def instance(cls, new=False): def instance(cls, new=True):
"""Returns the instance""" """Returns the instance"""
if new or not hasattr(cls, '_instance'): if new or not hasattr(cls, '_instance'):
params = dict(hostname=FLAGS.rabbit_host, params = dict(hostname=FLAGS.rabbit_host,
@@ -246,7 +246,7 @@ def msg_reply(msg_id, reply=None, failure=None):
LOG.error(_("Returning exception %s to caller"), message) LOG.error(_("Returning exception %s to caller"), message)
LOG.error(tb) LOG.error(tb)
failure = (failure[0].__name__, str(failure[1]), tb) failure = (failure[0].__name__, str(failure[1]), tb)
conn = Connection.instance(True) conn = Connection.instance()
publisher = DirectPublisher(connection=conn, msg_id=msg_id) publisher = DirectPublisher(connection=conn, msg_id=msg_id)
try: try:
publisher.send({'result': reply, 'failure': failure}) publisher.send({'result': reply, 'failure': failure})
@@ -319,7 +319,7 @@ def call(context, topic, msg):
self.result = data['result'] self.result = data['result']
wait_msg = WaitMessage() wait_msg = WaitMessage()
conn = Connection.instance(True) conn = Connection.instance()
consumer = DirectConsumer(connection=conn, msg_id=msg_id) consumer = DirectConsumer(connection=conn, msg_id=msg_id)
consumer.register_callback(wait_msg) consumer.register_callback(wait_msg)
@@ -346,7 +346,7 @@ def cast(context, topic, msg):
"""Sends a message on a topic without waiting for a response""" """Sends a message on a topic without waiting for a response"""
LOG.debug(_("Making asynchronous cast...")) LOG.debug(_("Making asynchronous cast..."))
_pack_context(msg, context) _pack_context(msg, context)
conn = Connection.instance(True) conn = Connection.instance()
publisher = TopicPublisher(connection=conn, topic=topic) publisher = TopicPublisher(connection=conn, topic=topic)
publisher.send(msg) publisher.send(msg)
publisher.close() publisher.close()