rabbitmq_publish fix for incorrectly stating message was not published to the queue (#61960)

* Pika v1.0.0 and above were causing issues for publish_message.  Updated
to ensure publish_message works with pika 0.13.1 and 1.0.0 and above.

* Adding changelog fragment for rabbitmq_publish fix.

* Updating return value.

(cherry picked from commit 1b2fd2cb5f)
pull/62378/head
John Imison 5 years ago committed by Toshio Kuratomi
parent 15b3bab5b7
commit 1219d8381f

@ -0,0 +1,2 @@
bugfixes:
- rabbitmq_publish - Fix to ensure the module works correctly for pika v1.0.0 and later. (https://github.com/ansible/ansible/pull/61960)

@ -18,6 +18,7 @@ import traceback
PIKA_IMP_ERR = None
try:
import pika
import pika.exceptions
from pika import spec
HAS_PIKA = True
except ImportError:
@ -193,4 +194,8 @@ class RabbitClient():
if args['exchange'] is None:
args['exchange'] = ''
return self.conn_channel.basic_publish(**args)
try:
self.conn_channel.basic_publish(**args)
return True
except pika.exceptions.UnroutableError:
return False

Loading…
Cancel
Save