diff --git a/oslo/messaging/_drivers/amqpdriver.py b/oslo/messaging/_drivers/amqpdriver.py index 8c361627c..1c51ab076 100644 --- a/oslo/messaging/_drivers/amqpdriver.py +++ b/oslo/messaging/_drivers/amqpdriver.py @@ -346,14 +346,15 @@ class AMQPDriverBase(base.BaseDriver): context = Context(ctxt) msg = message - msg_id = uuid.uuid4().hex - msg.update({'_msg_id': msg_id}) - LOG.debug('MSG_ID is %s' % (msg_id)) + if wait_for_reply: + msg_id = uuid.uuid4().hex + msg.update({'_msg_id': msg_id}) + LOG.debug('MSG_ID is %s' % (msg_id)) + msg.update({'_reply_q': self._get_reply_q()}) + rpc_amqp._add_unique_id(msg) rpc_amqp.pack_context(msg, context) - msg.update({'_reply_q': self._get_reply_q()}) - if envelope: msg = rpc_common.serialize_msg(msg) diff --git a/tests/test_rabbit.py b/tests/test_rabbit.py index 3ee243ef2..48f11dc9c 100644 --- a/tests/test_rabbit.py +++ b/tests/test_rabbit.py @@ -98,7 +98,7 @@ class TestRabbitTransportURL(test_utils.BaseTestCase): target = messaging.Target(topic='testtopic') - driver.send(target, {}, {}) + driver.listen(target) self.assertEquals(passed_params[0], self.expected) @@ -449,10 +449,9 @@ class TestRequestWireFormat(test_utils.BaseTestCase): received = msgs[0] received['oslo.message'] = jsonutils.loads(received['oslo.message']) + # FIXME(markmc): add _msg_id and _reply_q check expected_msg = { - '_msg_id': self.uuids[0].hex, - '_unique_id': self.uuids[1].hex, - '_reply_q': 'reply_' + self.uuids[2].hex, + '_unique_id': self.uuids[0].hex, } expected_msg.update(self.expected) expected_msg.update(self.expected_ctxt)