Search in sources :

Example 1 with BrokerEvent

use of com.sun.messaging.jmq.jmsservice.BrokerEvent in project openmq by eclipse-ee4j.

the class Broker method exitBroker.

/**
 * @param exitVM whether to exit VM If false, System.exit() is performed.
 */
private void exitBroker(int status, String reason, BrokerEvent.Type type, Throwable thr, boolean triggerFailover, boolean exitVM) {
    Globals.getLogger().log(Logger.DEBUG, "Broker exiting with status=" + status + " because " + reason);
    BridgeServiceManager bridgeManager = Globals.getBridgeServiceManager();
    if (bridgeManager != null && !Globals.isNucleusManagedBroker()) {
        try {
            Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().I_STOP_BRIDGE_SERVICE_MANAGER);
            bridgeManager.stop();
            Globals.setBridgeServiceManager(null);
            Globals.getLogger().log(Logger.INFO, Globals.getBrokerResources().I_STOPPED_BRIDGE_SERVICE_MANAGER);
        } catch (Throwable t) {
            logger.logStack(Logger.WARNING, Globals.getBrokerResources().W_STOP_BRIDGE_SERVICE_MANAGER_FAILED, t);
        }
    }
    // take a copy of bkrEvtListener as we may null it during the course of this method
    BrokerEventListener tempListener = bkrEvtListener;
    if (bkrEvtListener != null) {
        BrokerEvent event = new BrokerEvent(this, type, reason);
        bkrEvtListener.exitRequested(event, thr);
    }
    // Perform an orderly broker shutdown unless we're in-process,
    // or are going to halt, in which case we want to exit as quickly as possible
    destroyBroker(!exitVM, triggerFailover);
    if (exitVM) {
        if (shutdownHook != null) {
            shutdownHook.setTriggerFailover(triggerFailover);
        }
        System.exit(status);
    }
    // if we're still here we didn't exit the broker
    if (type == BrokerEvent.Type.RESTART) {
        // don't attempt to restart an embedded broker
        if (!runningInProcess) {
            // we want to restart, so tell the listener
            if (tempListener != null) {
                BrokerEvent event = new BrokerEvent(this, type, "Broker restart");
                tempListener.brokerEvent(event);
            }
        }
    }
}
Also used : BrokerEvent(com.sun.messaging.jmq.jmsservice.BrokerEvent) BridgeServiceManager(com.sun.messaging.bridge.api.BridgeServiceManager) BrokerEventListener(com.sun.messaging.jmq.jmsservice.BrokerEventListener)

Example 2 with BrokerEvent

use of com.sun.messaging.jmq.jmsservice.BrokerEvent in project openmq by eclipse-ee4j.

the class Broker method destroyBroker.

/**
 * Shutdown the broker but don't exit the JVM
 *
 * @param cleanup Set to true if unused resources should be freed. Should be set to true if the JVM will be left
 * running. May be set to false if we intend to exit the JVM later
 */
public static void destroyBroker(boolean cleanup, boolean triggerFailover) {
    // we want to cleanup all the statics
    if (broker == null) {
        return;
    }
    Object tmp = broker;
    if (Globals.getBrokerStateHandler() != null) {
        Globals.getBrokerStateHandler().initiateShutdown("BrokerProcess", 0, triggerFailover, 0, false, false, true);
    }
    if (cleanup) {
        BrokerMonitor.shutdownMonitor();
        Globals.getCoreLifecycle().cleanup();
        LockFile.clearLock();
        TLSProtocol.destroy();
        // stop JMX connectors
        Agent agent = Globals.getAgent();
        if (agent != null) {
            agent.stop();
            agent.unloadMBeans();
        }
        PortMapper pm = Globals.getPortMapper();
        if (pm != null) {
            pm.destroy();
        }
        Globals.cleanup();
        synchronized (Broker.class) {
            broker = null;
        }
    }
    if (bkrEvtListener != null) {
        // L10N-XXX
        BrokerEvent event = new BrokerEvent(tmp, BrokerEvent.Type.SHUTDOWN, "Broker has been shutdown");
        bkrEvtListener.brokerEvent(event);
        setBrokerEventListener(null);
    }
}
Also used : Agent(com.sun.messaging.jmq.jmsserver.management.agent.Agent) CommBroker(com.sun.messaging.jmq.jmsserver.comm.CommBroker) BrokerEvent(com.sun.messaging.jmq.jmsservice.BrokerEvent)

Example 3 with BrokerEvent

use of com.sun.messaging.jmq.jmsservice.BrokerEvent in project openmq by eclipse-ee4j.

the class Broker method start.

int start(boolean inProcess, Properties params, BrokerEventListener bel, boolean initOnly, Throwable failStartThrowable) throws OutOfMemoryError, IllegalStateException, IllegalArgumentException {
    setBrokerEventListener(bel);
    int startCode = _start(inProcess, params, initOnly, failStartThrowable);
    if (bkrEvtListener != null) {
        // L10N-XXX
        BrokerEvent event = new BrokerEvent(this, BrokerEvent.Type.READY, "Broker has been started");
        bkrEvtListener.brokerEvent(event);
    }
    return startCode;
}
Also used : BrokerEvent(com.sun.messaging.jmq.jmsservice.BrokerEvent)

Aggregations

BrokerEvent (com.sun.messaging.jmq.jmsservice.BrokerEvent)3 BridgeServiceManager (com.sun.messaging.bridge.api.BridgeServiceManager)1 CommBroker (com.sun.messaging.jmq.jmsserver.comm.CommBroker)1 Agent (com.sun.messaging.jmq.jmsserver.management.agent.Agent)1 BrokerEventListener (com.sun.messaging.jmq.jmsservice.BrokerEventListener)1