Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
M4
-
None
Description
This new feature lets users of the Python QMF API easily follow references in objects.
For example:
Start a QMF console session and connect to the broker on the local host:
>>> s = Session()
>>> b = s.addBroker()
Get the first in the list of queue objects:
>>> queue = s.getObjects(_class="queue")[0]
Look at the queue's properties:
>>> queue.getProperties()
[(vhostRef, 0-0-1-0-1152921504606846979), (name, 'reply-kids-pc.localdomain.19302'), (durable, False), (autoDelete, True), (exclusive, True), (arguments, {})]
Note that the vhostRef is an objectId. Now there's a very easy way to get the referenced vhost object:
>>> vhost = queue.vhostRef
>>> vhost.getProperties()
[(brokerRef, 0-0-1-0-1152921504606846978), (name, '/')]
Note the "_" added before and after the property name. Without the underscores, the value returned will be simply the objectId. With the underscores, the reference will be followed and the referenced object returned.
Likewise, we can get the broker object:
>>> queue.vhostRef.brokerRef.getProperties()
[(systemRef, 0-0-1-0-1152921504606846977), (port, 5672), (workerThreads, 5), (maxConns, 500), (connBacklog, 10), (stagingThreshold, 5000000), (mgmtPubInterval, 10), (version, '0.3'), (dataDir, '/home/ross/.qpidd')]
Or even invoke a method on the broker:
>>> queue.vhostRef.brokerRef.echo(1,"text")
OK (0) -