Sun GlassFish Message Queue 4.4 Developer's Guide for Java Clients

Creating a Broker Event Listener

When initializing an embedded broker, you must provide a broker event listener. This listener is an instance of a class that implements the BrokerEventListener interface. This interface specifies two methods:

The following listing shows an example class that implements the BrokerEventListener interface.

class EmbeddedBrokerEventListener implements BrokerEventListener {

    public void brokerEvent(BrokerEvent brokerEvent) {
        System.out.println ("Received broker event:"+brokerEvent);
    }

    public boolean exitRequested(BrokerEvent event, Throwable thr) {
        System.out.println ("Broker is requesting a shutdown because of:"+event+" with "+thr);
        // return true to allow the broker to shutdown
        return true;
    }
}