Universal Messaging 9.9 | Universal Messaging Developer Guide | Enterprise APIs | Enterprise Developer's Guide for C++ | Message Queues | Asynchronous Queue Consuming
 
Asynchronous Queue Consuming
Asynchronous queue consumers consume events from a callback on an interface that all asynchronous consumers must implement. We call this interface an nEventListener. The listener interface defines one method called 'go' which when called will pass events to the consumer as they are delivered from the Universal Messaging Realm Server.
An example of an asynchronous queue reader is shown below:

class myAsyncQueueReader : public nEventListener {

private:
nQueue *myQueue = null;

myAsyncQueueReader(){
// construct your session and queue objects here
// begin consuming events from the queue

nQueueReaderContext *ctx = new
nQueueReaderContext(this, 10);
nQueueAsyncReader *reader = myQueue->createAsyncReader(ctx);
}

void go(nConsumeEvent event) {
printf("Consumed event %d",event.getEventID());
}

int main(int argc, char** argv) {
new myAsyncQueueReader();
return 0;
}
}
Asynchronous queue consumers can also be created using a selector, which defines a set of event properties (see Event Dictionaries) and their values that a subscriber is interested in. For example if events are being published with the following event properties:

nEventProperties *props =new nEventProperties();
props->put("BONDNAME","bond1");
If you then provide a message selector string in the form of:

std::string selector = "BONDNAME='bond1'";
And pass this string into the constructor for the nQueueReaderContext object shown in the example code, then your consumer will only consume messages that contain the correct value for the event property BONDNAME.
An example of an asynchronous queue reader can be found on the examples page under "Queue Subscriber".

Copyright © 2013-2015 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release