Package org.codehaus.activemq.spring

Source Code of org.codehaus.activemq.spring.Main

/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
package org.codehaus.activemq.spring;

import org.codehaus.activemq.broker.BrokerContainer;
import org.springframework.core.io.FileSystemResource;

import javax.jms.JMSException;

/**
* A simple command line tool which runs a JMS Message Broker on the command line
* using a Spring XML deployment descriptor
*
* @version $Revision: 1.2 $
*/
public class Main {

    /**
     * run the Message Broker as a standalone application
     *
     * @param args
     */
    public static void main(String args[]) {
        try {
            SpringBrokerContainerFactory factory = new SpringBrokerContainerFactory();
            if (args.length <= 0) {
                System.out.println("Usage: Main <xmlConfigFile>");
                System.out.println("You must specify a deployment descriptor to run the ActiveMQ Message Broker");
                return;
            }
            String file = args[0];

            System.out.println("Loading Message Broker from file: " + file);
            factory.setResource(new FileSystemResource(file));

            BrokerContainer container = factory.createBrokerContainer("DefaultBroker");
            container.start();

            // lets wait until we're killed.
            Object lock = new Object();
            synchronized (lock) {
                lock.wait();
            }
        }
        catch (JMSException e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
            Exception le = e.getLinkedException();
            System.out.println("Reason: " + le);
            if (le != null) {
                le.printStackTrace();
            }
        }
        catch (Exception e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
        }
    }
}
TOP

Related Classes of org.codehaus.activemq.spring.Main

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.