Universal Messaging 10.3 | 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 {

nQueue *myQueue = null;

// 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();
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".