Universal Messaging Developer Guide : Universal Messaging Web Client APIs : Adobe Flex : Message Queues : Universal Messaging Flex - Asynchronous Queue Consuming
Universal Messaging Flex - 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:


public class myAsyncQueueReader implements nEventListener {

var myQueue:nQueue = null;
var reader:nQueueAsynchronousReader = null;

// construct your session and queue objects here

public function myAsyncQueueReader(queueIn:*):void{
if(queueIn is nQueue){
myQueue = nQueue(myQueue);
}else{
return;
}
// begin consuming events from the queue

var ctx:nQueueReaderContext = new nQueueReaderContext(this);
myQueue.createAsynchronousReader(ctx, readerCB);
}

public function readerCB(readerIn:*):void {
if(reader is nQueueAsynchronousReader){
reader = readerIn
}
}

public function go(event:*):void {
if(event is nConsumeEvent){
//Process events
}else{
//deal with error
}
}
}

Asynchronous queue consumers can also be created using a selector, which defines a set of event properties and their values that a subscriber is interested in. For example if events are being published with the following event properties:
var props:nEventProperteis =new nEventProperties();
props.put(“BONDNAME”,”bond1”);
If you then provide a message selector string in the form of:

var selector:String = "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.
Copyright © 2013-2014 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback