4.6.6 Using the Jolt API to Receive Oracle Tuxedo Notifications

The “Asynchronous Notification” listing shows how to use the Jolt Class Library for receiving notifications and includes the use of the JoltSession, JoltReply, JoltMessage and JoltUserEvent classes.

Listing 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);
  ...
  // Unsubscribe the HELLO event and unsolicited notification.
  helloEvent.unsubscribe();  
  unsolEvent.unsubscribe();
  }
}