rabbitmq – Retrieve messages from an AMQP/AMQPS RabbitMQ queue¶
New in version 2.8.
Synopsis¶
This lookup uses a basic get to retrieve all, or a limited number
count
, messages from a RabbitMQ queue.
Requirements¶
The below requirements are needed on the local master node that executes this lookup.
The python pika package https://pypi.org/project/pika/.
Parameters¶
Parameter | Choices/Defaults | Configuration | Comments |
---|---|---|---|
count
-
|
How many messages to collect from the queue.
If not set, defaults to retrieving all the messages from the queue.
|
||
queue
-
/ required
|
The queue to get messages from.
|
||
url
-
/ required
|
An URI connection string to connect to the AMQP/AMQPS RabbitMQ server.
For more information refer to the URI spec
Notes¶Note
Examples¶- name: Get all messages off a queue
debug:
msg: "{{ lookup('rabbitmq', url='amqp://guest:guest@192.168.0.10:5672/%2F', queue='hello') }}"
# If you are intending on using the returned messages as a variable in more than
# one task (eg. debug, template), it is recommended to set_fact.
- name: Get 2 messages off a queue and set a fact for re-use
set_fact:
messages: "{{ lookup('rabbitmq', url='amqp://guest:guest@192.168.0.10:5672/%2F', queue='hello', count=2) }}"
- name: Dump out contents of the messages
debug:
var: messages
Return Values¶Common return values are documented here, the following are the fields unique to this lookup: Status¶
Authors¶
Hint If you notice any issues in this documentation, you can edit this document to improve it. Hint Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. |