[Satellite6] How to purge a qpid queue content?
Environment
- Red Hat Satellite 6
Issue
- there is a need to clean content of some
qpidbroker queue (i.e. to remove old obsolete tasks to clean some backlog) - how to purge a queue content, what SSL certificates to use?
Resolution
Do NOT use this resolution until recommended by Red Hat support. Removing a message might have severe consequences in communication loss and loss of Satellite functionality.
Before the queue purge
Both below options to purge a queue might not need to delete messages acquired (but not yet consumed) by a consumer of the queue. Therefore it is recommended to shut down any consumer of the queue. Use qpid-stat -u | grep <queueName> (per this solution) to see consumers of the queue - that usually means either pulp or candlepin or qdrouterd service(s) need to be stopped first.
Using python's drain example
First option is to use drain example python script. The script needs to be enhanced to pass SSL certificates first:
- modify in
/usr/share/doc/python-qpid-0.30/examples/api/drain(version0-30might differ for newer python-qpid package versions):
conn = Connection(opts.broker,
reconnect=opts.reconnect,
reconnect_interval=opts.reconnect_interval,
reconnect_limit=opts.reconnect_limit,
ssl_certfile='/etc/pki/katello/certs/java-client.crt',
ssl_keyfile='/etc/pki/katello/private/java-client.key')
(add the two lines there with ssl_* parameters)
- now, consume the queue content:
/usr/share/doc/python-qpid-0.30/examples/api/drain -b "amqps://localhost:5671" "queueToBePurged; { node:{type:queue}}"
(optionally redirect output to a file)
- revert back the change i.g. by reinstalling
python-qpidpackage
Calling qpid-tool management tool
An alternative is calling a qpid management tool qpid-tool:
For Satellite 6.5 and older:
qpid-tool --ssl-certificate=/etc/pki/katello/qpid_client_striped.crt -b amqps://localhost:5671
For Satellite 6.6 and newer:
qpid-tool --ssl-certificate=/etc/pki/pulp/qpid/client.crt -b amqps://localhost:5671
- wait 10 seconds and then type
list queue:
qpid: list queue
- find the queue's ID in the first column of the output:
..
1545 07:45:46 - org.apache.qpid.broker:queue:pulp.agent.c84103b8-74f9-452f-8556-175c9834e309
..
- now call
purgemethod with below arguments to the object:
qpid: call 1545 purge 0 {}
- notice that due to the
qpidbroker setting,qpid-toolis supposed to get disconnected from the broker. If so, stop the tool and re-run it again.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.