Example usage for org.springframework.jms.listener DefaultMessageListenerContainer isRunning

List of usage examples for org.springframework.jms.listener DefaultMessageListenerContainer isRunning

Introduction

In this page you can find the example usage for org.springframework.jms.listener DefaultMessageListenerContainer isRunning.

Prototype

@Override
public final boolean isRunning() 

Source Link

Document

Determine whether this container is currently running, that is, whether it has been started and not stopped yet.

Usage

From source file:com.jmstoolkit.pipeline.Main.java

/**
 *
 * @param args//w  w  w. j a  v  a  2s  .  c om
 */
public static void main(final String[] args) {
    try {
        Settings.loadSystemSettings("jndi.properties");
        Settings.loadSystemSettings("app.properties");
    } catch (JTKException ex) {
        System.out.println("Failed to load application settings");
        System.out.println(JTKException.formatException(ex));
        System.exit(1);
    }

    final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {
            "/infrastructure-context.xml", "/mdb-context.xml", "/jmx-context.xml", "/logging-context.xml" });
    applicationContext.start();

    final DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) applicationContext
            .getBean("listenerContainer");
    if (dmlc != null) {
        dmlc.start();
        final Pipeline pipeline = (Pipeline) applicationContext.getBean("pipelineService");
        // enable access to the original application context
        pipeline.setApplicationContext(applicationContext);

        // Insure that the Pipeline loads configuration files AFTER
        // the listenerContainer is running.
        while (!dmlc.isRunning()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
        }
        pipeline.loadPlugins();
        pipeline.sendProperties();
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
        }
    }
}

From source file:com.jmstoolkit.pipeline.Pipeline.java

/**
 *
 * @param args the command line arguments
 *///from w w w  .jav a  2s.c  o m
public static void main(final String[] args) {
    // Have to use System.out as logging is configured by Spring
    // application context.
    try {
        Settings.loadSystemSettings("jndi.properties");
        Settings.loadSystemSettings("app.properties");
    } catch (JTKException ex) {
        System.out.println("Failed to load application settings");
        System.out.println(JTKException.formatException(ex));
        System.exit(1);
    }

    final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] {
            "/logging-context.xml", "/infrastructure-context.xml", "/mdb-context.xml", "/jmx-context.xml" });
    applicationContext.start();

    final DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) applicationContext
            .getBean("listenerContainer");
    if (dmlc != null) {
        dmlc.start();
        final Pipeline pipeline = (Pipeline) applicationContext.getBean("pipelineService");
        // enable access to the original application context
        pipeline.setApplicationContext(applicationContext);

        // Insure that the Pipeline loads configuration files AFTER
        // the listenerContainer is running.
        while (!dmlc.isRunning()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
            }
        }
        pipeline.loadPlugins();
        pipeline.sendProperties();

        // Keep thread alive
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
        }
    }
}