Universal Messaging Developer Guide : Web Client APIs : Web Developer's Guide for Adobe Flex : Publish / Subscribe using Channels / Topics : Publishing Events to a Channel
Publishing Events to a Channel
There are 2 types of publish available in Universal Messaging for channels:
Reliable Publish is simply a one way push to the Universal Messaging Server. This means that the server does not send a response to the client to indicate whether the event was successfully received by the server from the publish call.
Transactional Publish involves creating a transaction object to which events are published, and then committing the transaction. The server responds to the transaction commit call indicating if it was successful. There are also means for transactions to be checked for status after application crashes or disconnects.
Reliable Publish
Once the session has been established with the Universal Messaging realm server, and the channel has been located, a new Universal Messaging Event object (nConsumeEvent) must be constructed prior to use in the publish call being made to the channel.
Note that in this example code, we also create a Universal Messaging Event Dictionary object (nEventProperties) for our Universal Messaging Event before publishing it:

var event : nConsumeEvent = new nConsumeEvent();
var dictionary : nEventProperties = new nEventProperties();
dictionary.put("exampleKey", "Hello World");
event.properties=dictionary;
channel.publish(evt);
The final item to note is that the publish call is asynchronous; it returns immediately, allowing single-threaded Flex clients to continue processing.
Transactional Publish
Transactional publishing provides a means of verifying that the server received the events from the publisher, and therefore provides guaranteed delivery.
There are similar prototypes available to the developer for transactional publishing. Once the session is established and the channel located, we then need to construct the events for the transaction and publish these events to the transaction. Only when the transaction has been committed will the events become available to subscribers on the channel.
Below is a code snippet for transactional publishing:

var event : nConsumeEvent = new nConsumeEvent();
var dictionary : nEventProperties = new nEventProperties();
dictionary.put("exampleKey", "Hello World");
event.properties=dictionary;
var tattrib:nTransactionAttributes = new nTransasctionAttributes(myChannel);
var myTransaction:nTransaction =
nTransactionFactory.create(tattrib, transactionCallBack);
myTransaction.publish(event);
myTransaction.commit();
If during the transaction commit your Universal Messaging session becomes disconnected, and the commit call throws an exception, the state of the transaction may be unclear. To verify that a transaction has been committed or aborted, a call can be made on the transaction that will determine if the events within the transaction were successfully received by the Universal Messaging Realm Server. This call can be made regardless of whether the connection was lost and a new connection was created.
The following code snippet demonstrates how to query the Universal Messaging Realm Server to see if the transaction was committed:

var committed:Boolean = myTransaction.isCommitted(isCommittedCallBack);
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback