Example usage for org.springframework.jms.listener AbstractMessageListenerContainer start

List of usage examples for org.springframework.jms.listener AbstractMessageListenerContainer start

Introduction

In this page you can find the example usage for org.springframework.jms.listener AbstractMessageListenerContainer start.

Prototype

@Override
public void start() throws JmsException 

Source Link

Document

Start this container.

Usage

From source file:org.rotarysource.standalone.ServerShellMain.java

public ServerShellMain() throws Exception {
    log.info("CEP System version: 1.1.2.RELEASE");
    log.info("Starting server shell");

    // Initialize engine
    log.info("Getting Esper engine instance");
    ApplicationContext springAppContext = new ClassPathXmlApplicationContext("AppContext.xml");

    CepEngine statementEngine = (CepEngine) springAppContext.getBean("cepEngine");

    // Connect to JMS
    log.info("Connecting to JMS server through a Listener Container");
    AbstractMessageListenerContainer jmsListenerContainer = (AbstractMessageListenerContainer) springAppContext
            .getBean("listenerContainer");

    jmsListenerContainer.start();

    // Register shutdown hook
    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            /*                      ApplicationContext springAppContext = new ClassPathXmlApplicationContext("AppContext.xml");
                    /*  w  ww.java 2  s .com*/
             ShutdownEvent event = new ShutdownEvent(this, "Shutdown Event triggered by main shutdownHook");
             springAppContext.publishEvent( event);
            */
        }
    });

    log.info("Statements Processor started.");
    ShutdownEventListener shutdownEventListener = (ShutdownEventListener) springAppContext
            .getBean("shutdownEventListener");

    do {
        // sleep
        Thread.sleep(1000);

    } while (!shutdownEventListener.isShudownExecuted());

    ((ConfigurableApplicationContext) springAppContext).close();
    log.info("EVENT DRIVEN CONTROL SYSTEM: Finished");

    System.exit(-1);
}