diff --git a/oslo/messaging/_drivers/amqpdriver.py b/oslo/messaging/_drivers/amqpdriver.py index cfbd16108..6a4677ad0 100644 --- a/oslo/messaging/_drivers/amqpdriver.py +++ b/oslo/messaging/_drivers/amqpdriver.py @@ -316,14 +316,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 142252ca9..c2abf2ac9 100644 --- a/tests/test_rabbit.py +++ b/tests/test_rabbit.py @@ -97,7 +97,7 @@ class TestRabbitTransportURL(test_utils.BaseTestCase): target = messaging.Target(topic='testtopic') - driver.send(target, {}, {}) + driver.listen(target) self.assertEquals(passed_params[0], self.expected) @@ -368,10 +368,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)