Universal Messaging 9.12 | Developer Guide | Web Client APIs | Web Developer's Guide for Javascript | Web Client Development in JavaScript | Message Queue Tasks | Using a Queue
 
Using a Queue
This JavaScript code snippet demonstrates how to create a queue object, which allows you to publish or subscribe to a Universal Messaging queue:

var myQueue = mySession.getQueue("/demo/prices");
Note that unlike the Enterprise APIs, the JavaScript API does not support programmatic creation of queues; instead, you can use the Enterprise Manager GUI to create a Universal Messaging Queue.
A queue object offers several methods. Three of the more important ones are:
*myQueue.subscribe()
*myQueue.unsubscribe()
*myQueue.publish(Event event)
Please see JavaScript API Documentation for Queues for information on all available methods on a queue.
Each of the above methods can invoke one or more optional user-specified callback functions which you can (and probably should) implement and assign as follows:

var myQueue = mySession.getQueue("/demo/prices");

// Assign a handler function for Universal Messaging Events received on the Queue,
// then subscribe:
function myEventHandler(event) {
var dictionary = event.getDictionary();
console.log(dictionary.get("name") + " " + dictionary.get("bid"));
}

myQueue.on(Nirvana.Observe.DATA, myEventHandler);

myQueue.subscribe();

See Subscribing to a Queue and Publishing Events to a Queue.

Copyright © 2013-2019 | 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.