beautypg.com

Using the jolt api to receive tuxedo notifications – HP NonStop G-Series User Manual

Page 89

background image

If a client is subscribed to only a single event, unsubscribing disables both the event notification and unsolicited messages.

If a client has multiple subscriptions, then unsubscribing from any single subscription disables just that single subscription.
Unsolicited notifications continue. Only the last subscription to be unsubscribed causes unsolicited notification to stop.

If a client subscribes to both an unsolicited and an event notifications, then unsubscribing to just the unsolicited notification will not
stop either type of notifications from continuing. In addition, this unsubscribe does not throw an Exception. However, the Jolt API
will remember that an unsubscribe has taken place and a subsequent unsubscribe to the remaining event will disable both event
notification and unsolicited messages.

If you want to stop unsolicited messages in your client application, you need to make sure that you have unsubscribed to all events.

Note

Jolt 1.1 does not support the wildcard unsubscribe semantics of tpunsubscribe(-1,..). Jolt
clients wishing to unsubscribe to all subscriptions will do so by invoking the unsubscribe()
method in each event subscription object.

Using the Jolt API to Receive TUXEDO Notifications

Example 6-11

shows how to use the Jolt Class Library for receiving notifications and includes the use of the JoltSession, JoltReply,

JoltMessage and JoltUserEvent classes.

Example 6-11. Asynchronous Notification

class EventSession extends JoltSession
{
public EventSession( JoltSessionAttributes attr, String user,
String role, String upass, String apass )
{
super(attr, user, role, upass, apass);
}

/*
* Override the default unsolicited message handler.
* @param reply a place holder for the unsolicited message
* @see bea.jolt.JoltReply
*/
public void onReply( JoltReply reply )
{
// Print out the STRING buffer type message which contains
// only one field; the field name must be "STRING". If the
// message uses CARRAY buffer type, the field name must be
// "CARRAY". Otherwise, the field names must conform to the
// elements in FML or VIEW.

JoltMessage msg = (JoltMessage) reply.getMessage();
System.out.println(msg.getStringDef("STRING", "No Msg"));
}

public static void main( Strings args[] )
{
JoltUserEvent unsolEvent;
JoltUserEvent helloEvent;
EventSession session;
...

// Instantiate my session object which can print out the
// unsolicited messages. Then subscribe to HELLO event
// and Unsolicited Notification which both use STRING
// buffer type for the unsolicited messages.

session = new EventSession(...);

helloEvent = new JoltUserEvent("HELLO", null, session);
unsolEvent = new JoltUserEvent(JoltUserEvent.UNSOLMSG, null,
session);