It easy to start a SonicMQ container by means of "bin/startcontainer.sh", but how do one stop the container in a similar way? For automation purposes it would have been nice to be able to do this. Anyone who har suggestions?
:-) Eirik
The easiest way is to find the process number of the processes you want to stop and send it the TERM signal, you can do this using the command 'kill -TERM $PID' By sending the TERM signal it will cause a gracefull shutdown, but if for some reason that doesn't stop the container you can kill -9 the process which will stop it right away.
The kill -9 is not a right way because of the memory sync to disk you can loose data.
Use kill -12 if you wants, but the right way to shut down a container is to use the management api.
take a look to this file located on (MQ7.6/samples/Management/runtimeAPI/javaProxy/):
// Copyright 2001-2008 Progress Software Corporation - All Rights Reserved
/**
* Management Sample code
*
* This class demonstrates how to shutdown a container.
*
* See ./readme.txt for usage.
*/
import com.sonicsw.mf.jmx.client.*;
import com.sonicsw.mf.mgmtapi.runtime.*;
public final class Shutdown
{
public static void main(String[] args)
{
JMSConnectorClient connector = null;
try
{
// get a JMX connector
connector = Common.getConnector("tcp://localhost:2506", "Administrator", "Administrator");
// create a proxy to the broker component
IAgentProxy agent = Common.getAgentProxy(connector, "Domain1", "DomainManager");
// shutdown the container
agent.shutdown();
}
catch(Throwable t)
{
t.printStackTrace();
if (t instanceof ProxyRuntimeException)
{
System.err.println("Caused by:");
((ProxyRuntimeException)t).getTargetException().printStackTrace();
}
}
finally
{
if (connector != null)
connector.disconnect();
}
}
}
Eclips was unable to find the Common.
Could you explain or help me out, I don't have the examples
Take a look to MQ7.6/samples/ you have a file SonicMQ.bat or SonicMQ.sh to configure your classpath.
You don't neet Eclipse, just modify the host/port/user/password/Domain name in the Shutdown.java and
compile it:
@echo off
rem
rem Start a SonicMQ JMS client.
rem
set SONICMQ_HOME=..
call "%SONICMQ_HOME%\bin\setenv"
set SONICMQ_SSL_SAMPLES_CLIENT="-DSSL_CA_CERTIFICATES_DIR=%SONICMQ_HOME%/certs/CA"
set SOAP_CLASSPATH=%SONICMQ_LIB%\xmlParserAPIs.jar;%SONICMQ_LIB%\axis.jar;%SONICMQ_LIB%\saaj.jar;%SONICMQ_LIB%\jaxrpc.jar;%SONICMQ_LIB%\wsdl4j.jar;%SONICMQ_LIB%\commons-discovery.jar;%SONICMQ_LIB%\commons-logging.jar
set SONICMQ_CLASSPATH=%SONICMQ_LIB%\sonic_Client.jar;%SONICMQ_LIB%\mfcontext.jar;%SONICMQ_LIB%\gnu-regexp-1.0.6.jar;%SONICMQ_SSL_LIB%
javac -cp ".;%SONICMQ_CLASSPATH" Shutdown.java
Hello
If you want a simple way stop your container I suggest to use esbadmin.sh command line utility.
take a look at the esb management documentation (page 39).
You have to install the sonic ESB to use this command line tool.
regards
Chan Jeremy
SonicMQ v.7.6:
you have a script shell example in
[SonicMQ Home]/bin/shutdownDomainManager.sh