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:
void demo(){
int numchans = 2;
nChannelAttributes** arr = new nChannelAttributes*[numchans];
nChannel** channels = new nChannels*[numchans];
arr[0] = new nChannelAttributes("myChan1");
arr[1] = new nChannelAttributes("myChan2");
fSortedList<std::string, nFindResult*> *pArr = mySession->find(arr, numchans);
int i =0;
for (fSortedList<std::string, nFindResult*>::iterator iterator = pArr->begin();
iterator != pArr->end(); iterator++)
{
if (!iterator->second->wasSuccessful())
{
handleSubscriptionFailure(iterator->second);
}
else if (iterator->second->isChannel())
{
channels[i] = iterator->second->getChannel();
}
i++;
}
public void handleSubscriptionFailure(nFindResult* result){
// do something
}
}
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.