From d49ddc3b9828f097d5bb39bca0381386a9de7762 Mon Sep 17 00:00:00 2001
From: Javeme <zhangmei.li@easystack.cn>
Date: Tue, 5 Jan 2016 20:05:10 +0800
Subject: [PATCH] rabbit: fix unit conversion error of expiration

kombu has already made a conversion from seconds to milliseconds,
so we do not need to do it again.

Closes-Bug: #1531148
Change-Id: Ia4478f15f1980a93a53f7e1e6570f68aeec75c69
---
 oslo_messaging/_drivers/impl_rabbit.py           | 8 +-------
 oslo_messaging/tests/drivers/test_impl_rabbit.py | 2 +-
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py
index 1f75b3349..26f917377 100644
--- a/oslo_messaging/_drivers/impl_rabbit.py
+++ b/oslo_messaging/_drivers/impl_rabbit.py
@@ -976,12 +976,6 @@ class Connection(object):
                                             channel=self.channel,
                                             routing_key=routing_key)
 
-        expiration = None
-        if timeout:
-            # AMQP TTL is in milliseconds when set in the property.
-            # Details: http://www.rabbitmq.com/ttl.html#per-message-ttl
-            expiration = int(timeout * 1000)
-
         # NOTE(sileht): no need to wait more, caller expects
         # a answer before timeout is reached
         transport_timeout = timeout
@@ -1001,7 +995,7 @@ class Connection(object):
         LOG.trace('Connection._publish: sending message %(msg)s to'
                   ' %(who)s with routing key %(key)s', log_info)
         with self._transport_socket_timeout(transport_timeout):
-            producer.publish(msg, expiration=expiration)
+            producer.publish(msg, expiration=timeout)
 
     # List of notification queue declared on the channel to avoid
     # unnecessary redeclaration. This list is resetted each time
diff --git a/oslo_messaging/tests/drivers/test_impl_rabbit.py b/oslo_messaging/tests/drivers/test_impl_rabbit.py
index c2efb27a4..7d14d2857 100644
--- a/oslo_messaging/tests/drivers/test_impl_rabbit.py
+++ b/oslo_messaging/tests/drivers/test_impl_rabbit.py
@@ -180,7 +180,7 @@ class TestRabbitPublisher(test_utils.BaseTestCase):
             conn = pool_conn.connection
             conn._publish(mock.Mock(), 'msg', routing_key='routing_key',
                           timeout=1)
-        fake_publish.assert_called_with('msg', expiration=1000)
+        fake_publish.assert_called_with('msg', expiration=1)
 
     @mock.patch('kombu.messaging.Producer.publish')
     def test_send_no_timeout(self, fake_publish):