Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | Universal Messaging | Universal Messaging Administration API | Namespace Objects | nLeafNode (Channels and Queues)
 
nLeafNode (Channels and Queues)
Once you are familiar with the concept of the Universal Messaging Namespace, as discussed in the nRealmNode guide (see nRealmNode), you can then begin to use the other administration objects associated with a realm's Namespace.
In this section the nLeafNode is discussed. It is assumed you are aware of how to create an nRealmNode for this section, and have a general understanding of Universal Messaging's publish / subscribe and message queue technologies
nLeafNode
The nLeafNode is either a channel or a queue, and is, as its name suggests, an end point of a branch of the namespace tree. An nLeafNode's parent is always an instance of nContainer. Since nRealmNode is a subclass of nContainer, sometimes an nLeafNode's parent is also an instance of an nRealmNode. For example, consider the following 2 channels within the namespace:
/eur/uk/rates
/rates
The nLeafNode that corresponds to the channel '/eur/uk/rates' will have a parent which is an instance of nContainer, and is called 'uk', whereas the nLeafNode that corresponds to the channel '/rates' has a parent which is also an instance of nContainer, however is is also an instance of an nRealmNode (i.e. the namespace root), since it does not contain any folder information in its name.
As channels and queues are created, they are added to the nRealmNode's tree structure as nLeafNodes. This is all managed for you and does not require you to modify the structure. However it is possible to be notified when changes to the namespace occur so that your application can handle it as you see fit. This is discussed in more detail in the Management Information section of this guide.
To determine if an nLeafNode is a channel or a queue, there are 2 simple methods you can use. The following code snippet search the namespace and print out whether each leaf node it finds is a channel or a queue.
Example : Find channels and queues in the namespace
Java:
public void searchNodes(nContainer container)

Enumeration children = container.getNodes();
while (children.hasMoreElements()) {
nNode child = (nNode)children.nextElement();
if (child instanceof nContainer) {
searchNodes((nContainer)child);
} else if (child instanceof nLeafNode) {
nLeafNode leaf = (nLeafNode)child;
if (leaf.isChannel) {
System.out.println("Leaf Node "+leaf.getName()+" is a channel");
} else if (leaf.isQueue()) {
System.out.println("Leaf Node "+leaf.getName()+" is a queue");
}
}
}

}
C#:
public void searchNodes(nContainer container)

System.Collections.IEnumerator children = realm.getNodes();
while (children.MoveNext()){
nNode child = (nNode)children.Current;
if (child is nContainer) {
searchNodes((nContainer)child);
} else if (child is nLeafNode) {
nLeafNode leaf = (nLeafNode)child;
if (leaf.isChannel) {
Console.WriteLine("Leaf Node "+leaf.getName()+" is a channel");
} else if (leaf.isQueue()) {
Console.WriteLine("Leaf Node "+leaf.getName()+" is a queue");
}
}
}

}
C++:
void searchNodes(fSortedList nodes)
for (fSortedList::iterator iterator = nodes.begin(); iterator != nodes.end(); iterator++)
{
nNode *pNode = iterator->second;
int type = pNode->getType ();

if (type == fBase::LEAFNODE)
{
if(iterator->second->isChannel()){
printf("Leaf Node %s is a Channel");
} else if(iterator->second->isQueue()){
printf("Leaf Node %s is a Queue");
}
}

else if (type == fBase::CONTAINER)
{
searchNodes(((nContainer*)pNode)->getNodes());
}
}
}
In the above code example, by the searchNodes(realm) method searches the namespace from the realm node, and this isChannel() and isQueue() methods are used to determine whether each leaf node is a queue or a channel.
Associated with each leaf node, is the nChannelAttributes for the queue or channel, this is obtained by using the getAttributes() method, so it is possible to determine the characteristics of each leaf node.
Each leaf node also has an associated nACL object that can be modified to change security permissions for users. This is discussed in more detail in the security section of this guide.
For more information on Universal Messaging Administration, please see the API documentation, and the Enterprise Manager Guide.