Package org.codehaus.activemq.broker.impl

Source Code of org.codehaus.activemq.broker.impl.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.broker.impl;

import org.codehaus.activemq.ActiveMQConnection;
import org.codehaus.activemq.broker.BrokerConnector;
import org.codehaus.activemq.message.DefaultWireFormat;

import javax.jms.JMSException;

/**
* A simple command line tool which runs a JMS Message Broker on the command line
*
* @version $Revision: 1.8 $
*/
public class Main {

    /**
     * run the Message Broker as a standalone application
     *
     * @param args
     */
    public static void main(String args[]) {
        try {
            String url = ActiveMQConnection.DEFAULT_URL;
            if (args.length > 0) {
                url = args[0];
            }

            BrokerContainerImpl container = new BrokerContainerImpl(url);
            BrokerConnector brokerConnector = new BrokerConnectorImpl(container, url, new DefaultWireFormat());
            container.start();
            brokerConnector.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.broker.impl.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.