Universal Messaging Developer Guide : The Enterprise Client APIs : The Universal Messaging Java Enterprise Developer's Guide : Universal Messaging Java - Publish / Subscribe Using Channels/Topics : Universal Messaging Java - Batched Find
Universal Messaging Java - 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){
result.getException().printStackTrace();
}
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.
Copyright © 2013-2014 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback