...
Method | Arguments | Invoked when... |
---|---|---|
brokerConnected | broker | a connection to a broker is established |
brokerDisconnected | broker | a connection to a broker is lost |
newPackage | name | a new package is seen on the QMF bus |
newClass | kind, classKey | a new class (event or object) is seen on the QMF bus |
newAgent | agent | a new agent appears on the QMF bus |
delAgent | agent | an agent disconnects from the QMF bus |
objectProps | broker, object | the properties of an object are published |
objectStats | broker, object | the statistics of an object are published |
event | broker, event | an event is published |
heartbeat | agent, timestamp | a heartbeat is published by an agent |
brokerInfo | broker | information about a connected broker is available to be queried |
methodResponse | broker, seq, response | the result of an asynchronous method call is received |
Supplied with the API is a class called DebugConsole. This is a test Console instance that overrides all of the methods such that arriving asynchronous data is printed to the screen. This can be used to see all of the arriving asynchronous data.
...
The above code is illustrative of the way a console application can tune its use of the QMF bus. Note that rcvEvents is set to False. This prevents the reception of events. Note also the use of userBindings=True and the call to sess.bindClass. If userBindings is set to False (its default), the session will receive object updates for all classes of object. In the case above, the application is only interested in broker:queue objects and reduces its bus bandwidth usage by requesting updates to only that class. bindClass may be called as many times as desired to add classes to the list of subscribed classes.
Asynchronous Method Calls and Method Timeouts
Method calls can also be invoked asynchronously. This is useful if a large number of calls needs to be made in a short time because the console application will not need to wait for the complete round-trip delay for each call.
Method calls are synchronous by default. They can be made asynchronous by adding the keyword-argument _async=True to the method call.
In a synchronous method call, the return value is the method result. When a method is called asynchronously, the return value is a sequence number that can be used to correlate the eventual result to the request. This sequence number is passed as an argument to the methodResponse function in the Console interface.