Batched Find
In client applications, it is quite common to have multiple Channels or Queues that one is trying to find. In these scenarios, the batched find call built into nSession is extremely useful.
The following code snippet demonstrates how to find 2 Universal Messaging Channels in one server call:
public void demo(){
nChannelAttributes[] arr = new nChannelAttributes[2];
nChannel[] channels = new nChannels[2];
arr[0] = new nChannelAttributes("myChan1");
arr[1] = new nChannelAttributes("myChan2");
nFindResult[] results = mySession.find(arr);
for (int i = 0; i < results.length; i++) {
if (!results[i].wasSuccessful()) {
handleSubscriptionFailure(results[i]);
} else if (results[i].isChannel) {
channels[i] = results[i].getChannel();
}
}
}
public void handleSubscriptionFailure(nFindResult result){
Console.WriteLine(result.getException().StackTrace);
}
To perform the same operation for Queues, simply use the example above and exchange nChannel for nQueue, and check each result returned to see if the isQueue() flag is set.