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

var myChannel = mySession.getChannel("/fxdemo/prices");
Note that unlike the Enterprise APIs, the JavaScript API does not support programmatic creation of channels; instead, you can use the Enterprise Manager GUI to create a Universal Messaging Channel.
A channel object offers several methods. Three of the more important ones are:
*myChannel.subscribe()
*myChannel.unsubscribe()
*myChannel.publish(Event event)
Please see JavaScript API Documentation for Channels for information on all available methods on a channel.
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 myChannel = mySession.getChannel("/fxdemo/prices");

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

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

myChannel.subscribe();

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

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.