activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ron55test <rkn...@gmail.com>
Subject Stopping ActiveMQ programmatically
Date Mon, 11 Dec 2006 01:24:52 GMT

Hi,

I've been trying to start and stop ActiveMQ service programmatically...I
wrote some code to start and stop activemq. It works fine on my windows
machine. However, if I run the same program on a linux machine...it works
fine starting but does not stop the activemq service. As a result, the
tomcat process does not stop.

Here are the details:
--We are building a web application and want to start ActiveMQ service when
the app is deployed and tomcat is started.  We want to stop the activemq
service when we stop tomcat.  So, my start/stop code is deployed with the
war file and want to run the activemq service within the tomcat jvm. On our
linux machine, we are using JRockit as the JVM.
--Here are my start and stop methods:

    public void start()
    {
        BrokerService brokerService = new BrokerService();
        try
        {
            File file = new File(_activemqDataDir);
            brokerService.setDataDirectory(file);
            brokerService.setBrokerName(_brokerName);
            brokerService.addConnector(_brokerURL);
            brokerService.start();
        }
        catch (Exception e)
        {
            e.printStackTrace(System.out);
        }
    }

    public void stop()
    {
        BrokerService brokerService =
BrokerRegistry.getInstance().lookup(_brokerName);
        try
        {
            if (brokerService != null)
            {
                brokerService.stop();
            }
            else
            {
                _log.info("Could not stop ActiveMQ broker.  It was never
started");
            }
        }
        catch (Exception e)
        {
            e.printStackTrace(System.out);
        }
    }

--Any help will be highly appreciated. If I cannot stop the activemq service
programmatically, is there any other way I can stop it on our linux machine. 
The only way we have been killing the activemq service is by manually
killing the tomcat process.

Thanks


-- 
View this message in context: http://www.nabble.com/Stopping-ActiveMQ-programmatically-tf2791601.html#a7788543
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message