Server event notification to external server

  1. Make sure WebSphere® Application Server instance on server and external server point to the same message queue and have the same message queue and queue connection factory. Create a BTT Notifier in an external server.
    public class SampleNotifier extends BTTNotifier { 
      public DSEEventObject printerEvent; 
    } 
    
    public SampleNotifier () { 
      super(); 
    } 
    
    public SampleNotifier(String aName) { 
      super(aName); 
    } 
    
    public void printerError(String aPrt, String aDocName, String message) { 
      Hashtable eventAttributes = new Hashtable(); 
      eventAttributes.put ("printerAddress", aPrt); 
      eventAttributes.put ("document", aDocName); 
      printerEvent = new DSEEventObject("printerEvent",this,eventAttributes); 
      signalEvent(printerEvent); 
    } 
    
  2. Create a BTT Handler in BTT server for the event and implement a dispatchEvent to provide the behavior to process the event. For example, the SampleNotifier uses the PrinterEventsHandler:
    public class PrinterEventsHandler extends BTTHandler { 
    } 
    
    public Handler dispatchEvent(DSEEventObject anEvent) { 
      // The dispatch method displays a string in the system standard
    output 
      // containing the event information 
      System.out.println("The event"+ anEvent.getName()+ "has been
    signaled. Printer:"+
            anEvent.getParameters().get("printerAddress")+" Document:"
            +anEvent.getParamenters().get("document")); 
      // The handler enables further event propagation by returning
    this
      // return this; 
    }  
  3. Implement the signalEvent method for each event that the notifier can fire.
  4. Add the BTT Handler registration to server side single action EJB that requires event notification as shown in the following example:
    public class CustomerSearchBean
    
    extends StatelessSingleAction
    
    implements javax.ejb.SessionBean {
    
    
      public PrinterEventsHandler eventsHandler; 
     
    
      ......
      public Hashtable execute(String uid) throws BTTSAEException,Exception { 
    
      ..... 
    
      // Start to handle external server event;
     
       eventsHandler= new PrinterEventsHandler; 
       eventsHandler.handleEvent("printerEvent ", "SampleNotifier");
    
       ......  
    } }
    When the SampleNotifier instance fires an event, it calls the dispatchEvent method of the PrinterEventsHandler. In the handler displays a message in the system standard output.