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.
This commit is contained in:
John Imison 2019-09-12 04:29:05 +10:00 committed by Felix Fontein
parent 2064fc3fc5
commit 1b2fd2cb5f
2 changed files with 8 additions and 1 deletions

View file

@ -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)

View file

@ -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