Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support headers in queue_declare function #174

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions changelogs/fragments/174-support-headers-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- rabbitmq_publish - fix support for publishing headers as a part of a message (https://github.com/ansible-collections/community.rabbitmq/pull/174/)
6 changes: 4 additions & 2 deletions plugins/module_utils/rabbitmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,16 @@ def basic_publish(self):
result = self.conn_channel.queue_declare(queue='',
durable=self.params.get("durable"),
exclusive=self.params.get("exclusive"),
auto_delete=self.params.get("auto_delete"))
auto_delete=self.params.get("auto_delete"),
arguments=self.params.get("headers"))
self.conn_channel.confirm_delivery()
self.queue = result.method.queue
elif self.queue is not None and self.exchange is None:
self.conn_channel.queue_declare(queue=self.queue,
durable=self.params.get("durable"),
exclusive=self.params.get("exclusive"),
auto_delete=self.params.get("auto_delete"))
auto_delete=self.params.get("auto_delete"),
arguments=self.params.get("headers"))
self.conn_channel.confirm_delivery()
except Exception as e:
self.module.fail_json(msg="Queue declare issue: %s" % to_native(e))
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/rabbitmq_publish/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@
- "'image/gif' in messages[1]['content_type']"
- "'image.gif' in messages[1]['headers']['filename']"
- "'Testing with proto/host/port/username/password/vhost' in messages[2]['msg']"
# - messages[3]['headers']['myHeader'] is defined
# - messages[4]['headers']['filename'] is defined
# - messages[4]['headers']['secondHeader'] is defined
#
- messages[4]['headers']['myHeader'] is defined
- messages[4]['headers']['secondHeader'] is defined
- "'Value2' in messages[4]['headers']['secondHeader']"


- name: Check that queue and exchange are mutually exclusive
rabbitmq_publish:
Expand Down
Loading