Nirvana J2ME : Publishing Events to a Channel

Once the session has been established with the Nirvana realm server, and the channel has been located, a new Nirvana Event object (nConsumeEvent) must be constructed prior to use in the publish or transactional publish call being made to the channel.

Note that in this example code, we also create a Nirvana Event Dictionary object for our Nirvana Event before publishing it:

nEventProperties props=new nEventProperties();
String value = "Hello World";
props.put("key1",value);
nObject evt= nObject.createConsumeEvent(props,"".getBytes());
nObject.publish(myRatesChannel,evt);

To publish an event to a channel we first create a consume event nObject passing the nEventProperties and byte[] body, or a tag and byte[] body. The example above demonstrates the nEventProperties method.

Note that the publish method returns immediately and does not ensure that the event has been sent to the Nirvana Realm. In order to ensure that, transactional publishing should be used.