Universal Messaging 10.5 | Administration Guide | Universal Messaging Administration API | Management Information | nLeafNode
 
nLeafNode
Universal Messaging's admin API provides real time asynchronous information on all objects within a realm server. By creating an nRealmNode (see nRealmNode), and connecting to a realm, information is automatically delivered to the realm node from the realm. This information is delivered periodically in summary form, and also as and when the state changes for one or all of the objects managed within a realm.
Before reading this section it may be useful to look at the management information available via the Universal Messaging enterprise manager. A full description of all Realm management screens is available in the enterprise manager guide. All functionality seen in the enterprise manager can be easily added to bespoke admin and monitoring processes as it is written entirely using the Universal Messaging Admin API.
This section will discuss the basic information that can be obtained through the nAdmin API for the nLeafNode object:
Status Events
The nLeafNode extends nNode which is a subclass of Observable, so when the status information is received for a leaf node, (this occurs only when things change on the channel or queue, i.e. acl, connections, events published / consumed etc) the nLeafNode will trigger the update callback on any known Observers. For example, if you write a class that implements the Observer interface, then we can do the following:
Java, C#:
Enumeration children = realm.getNodes();
while (children.hasMoreElements();
nNode child = (nNode)children.nextElement();
if (child instanceof nLeafNode) {
child.addObserver(this);
}
}
C++:
pNode->addObserver(this);
pNode->addConnectionListener(new nRealmWatch(this));
fSortedList nodes = registerNodes(pNode->getNodes());
for (fSortedList::iterator iterator = nodes.begin(); iterator != nodes.end(); iterator++)
{
if (type == fBase::LEAFNODE)
{
((nLeafNode*)pNode)->addListener(new nChannelWatch((nLeafNode*)pNode, this));
}
}
Assuming 'this' is the instance of the class implementing Observer, then the implementation of the update(Observable obs, Object obj) will be notified that the leaf node has changed.
When events occur on a leaf node that you have added an observer to, the Observable/Observer mechanism will notify you of the details of that event. For example, the following implementation of the update method of the Observer interface demonstrates how to detect that a channel or queue acl has been added or deleted:
Java, C#:
public void update(Observable obs, Object obj){
if (obs instanceof nLeafNode) {
if (obj instanceof nACLEntry) {
nLeafNode leaf = (nLeafNode)obs;
nACLEntry entry = (nACLEntry)obj;
if (leaf.isChannel()) {
// acl modified / added / deleted
System.out.println("Channel "+leaf.getName()+" acl event for "+entry.getSubject());
} else {
// acl modified / added / deleted
System.out.println("Queue "+leaf.getName()+" acl event for "+entry.getSubject());
}
}
}
}
C++:
void ObservableMapping::update(Observable *pObs, void *pObj)
{
if (obs->getType() == fBase::LEAFNODE) {
if (obj->getType() == fBase::ACLENTRY) {
nLeafNode leaf = (nLeafNode*)obs;
nACLEntry entry = (nACLEntry*)obj;
if (leaf->isChannel()) {
// acl modified / added / deleted
printf("Channel %s acl event for %s",leaf->getName(),+entry->getSubject());
} else {
// acl modified / added / deleted
printf("Queue %s acl event for %s",leaf->getName(),+entry->getSubject());
}
}
}
}
For more information on Universal Messaging Administration, please see the API documentation, and the Enterprise Manager Guide.