Author: aco
Date: Mon Dec 19 23:15:13 2005
New Revision: 357932
URL: http://svn.apache.org/viewcvs?rev=357932&view=rev
Log:
Added broker shutdown mechanism. Some exceptions are being thrown during
shutdown, but doesn't seem to cause any problem. Printing of exceptions are
currently disabled.
Added:
incubator/activemq/trunk/assembly/src/release/bin/shutdown
incubator/activemq/trunk/assembly/src/release/bin/shutdown.bat
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/Main.java
incubator/activemq/trunk/assembly/src/release/bin/activemq
incubator/activemq/trunk/assembly/src/release/bin/activemq.bat
Modified:
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/Main.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/Main.java?rev=357932&r1=357931&r2=357932&view=diff
==============================================================================
---
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/Main.java
(original)
+++
incubator/activemq/trunk/activemq-core/src/main/java/org/activemq/broker/Main.java
Mon Dec 19 23:15:13 2005
@@ -18,122 +18,545 @@
**/
package org.activemq.broker;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.ObjectInstance;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
import java.io.File;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.JarURLConnection;
import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.JarURLConnection;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
/**
* Main class that can bootstrap a ActiveMQ Broker. Handles command line
* argument parsing to set up the broker classpath and System properties.
- *
+ *
* @version $Revision$
*/
public class Main {
+ public static final int HELP_MAIN_APP = 0;
+ public static final int HELP_START_BROKER = 1;
+ public static final int HELP_STOP_BROKER = 2;
+ public static final int HELP_LIST_BROKER = 3;
+ public static final int HELP_STAT_BROKER = 4;
+
+ public static final int TASK_NONE = -1;
+ public static final int TASK_START_BROKER = 0;
+ public static final int TASK_STOP_BROKER = 1;
+ public static final int TASK_LIST_BROKER = 2;
+ public static final int TASK_STAT_BROKER = 3;
+ public static final int TASK_PRINT_MAIN_HELP = 4;
+ public static final int TASK_PRINT_START_HELP = 5;
+ public static final int TASK_PRINT_STOP_HELP = 6;
+ public static final int TASK_PRINT_LIST_HELP = 7;
+ public static final int TASK_PRINT_STAT_HELP = 8;
+ public static final int TASK_PRINT_ALL_HELP = 9;
+ public static final int TASK_PRINT_VER = 10;
private static final String BROKER_FACTORY_CLASS =
"org.activemq.broker.BrokerFactory";
- private static File activeMQHome;
+ private static final String DEFAULT_CONFIG_URI = "xbean:activemq.xml";
+ private static final String DEFAULT_JMX_URL =
"service:jmx:rmi:///jndi/rmi://localhost:1099/jmxconnector";
+ private static final String DEFAULT_JMX_DOMAIN = "org.activemq";
+
+ private static final String DEFAULT_KEY_BROKER_NAME = "BrokerName";
+ private static final String DEFAULT_METHOD_BROKER_STOP = "terminateJVM";
+ private static final Object[] DEFAULT_PARAM_BROKER_STOP = new Object[]
{new Integer(0)};
+ private static final String[] DEFAULT_SIGN_BROKER_STOP = new String[]
{"int"};
+
+ // Stat retrieve flags
+ private static final int STAT_BROKER = Integer.parseInt("0001", 2);
+ private static final int STAT_ALL = Integer.parseInt("1111", 2);
+
+ private static final String[] STAT_BROKER_MAP = new String[] {
+ "TotalEnqueueCount", "TotalDequeueCount", "TotalConsumerCount",
"TotalMessages",
+ "TotalMessagesCached", "MemoryPercentageUsed", "MemoryLimit"
+ };
+
+ // Stat display flags
+ private static final int STAT_DISP_BROKER = Integer.parseInt("0001", 2);
+ private static final int STAT_DISP_ALL = Integer.parseInt("1111", 2);
+
private final ArrayList extensions = new ArrayList();
- private URI uri;
- private ClassLoader classLoader;
- public static void main(String[] args) throws Throwable {
- Main main = new Main();
-
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("-D")) {
- String key = args[i].substring(2);
- String value = "";
- int pos = key.indexOf("=");
- if (pos >= 0) {
- value = key.substring(pos + 1);
- key = key.substring(0, pos);
- }
- System.setProperty(key, value);
- } else if (args[i].equals("--extdir")) {
- if( !canUseExtdir() ) {
- System.out.println("Extension directory feature not
available due to the system classpath being able to load:
"+BROKER_FACTORY_CLASS);
- printUsage();
- return;
+ private int taskType = TASK_NONE;
+ private boolean stopAll = false;
+ private JMXServiceURL jmxUrl;
+ private URI configURI;
+ private File activeMQHome;
+ private ClassLoader classLoader;
+
+ public static void main(String[] args) {
+ Main app = new Main();
+
+ // Convert arguments to collection for easier management
+ ArrayList tokens = new ArrayList(Arrays.asList(args));
+
+ // First token should be task type
(start|stop|list|-h|-?|--help|--version)
+ app.setTaskType(app.parseTask(tokens));
+
+ // Succeeding tokens should be task specific options identified by "-"
at the start
+ app.parseOptions(tokens);
+
+ // Succeeding tokens should be the task data
+ switch (app.getTaskType()) {
+ case TASK_START_BROKER:
+ try {
+ app.taskStartBrokers(tokens);
+ } catch (Throwable e) {
+ System.out.println("Failed to start broker. Reason: " +
e.getMessage());
}
- i++;
- if (i >= args.length) {
- System.out.println("Extension directory not specified.");
- printUsage();
- return;
+ break;
+
+ case TASK_STOP_BROKER:
+ try {
+ app.taskStopBrokers(tokens);
+ } catch (Throwable e) {
+ System.out.println("Failed to stop broker(s). Reason: " +
e.getMessage());
}
+ break;
+
+ case TASK_LIST_BROKER:
+ try {
+ app.taskListBrokers();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.out.println("Failed to list broker(s). Reason: " +
e.getMessage());
+ }
+ break;
+
+ case TASK_STAT_BROKER:
+ try {
+ app.taskStatBrokers(tokens);
+ } catch (Throwable e) {
+ System.out.println("Failed to print broker statistics.
Reason: " + e.getMessage());
+ }
+ break;
+
+ case TASK_PRINT_MAIN_HELP:
+ app.printHelp(HELP_MAIN_APP);
+ break;
+
+ case TASK_PRINT_START_HELP:
+ app.printHelp(HELP_START_BROKER);
+ break;
+
+ case TASK_PRINT_STOP_HELP:
+ app.printHelp(HELP_STOP_BROKER);
+ break;
- File directory = new File(args[i]);
- if (!directory.isDirectory()) {
- System.out.println("Extension directory specified is not
valid directory: " + directory);
- printUsage();
+ case TASK_PRINT_LIST_HELP:
+ app.printHelp(HELP_LIST_BROKER);
+ break;
+
+ case TASK_PRINT_STAT_HELP:
+ app.printHelp(HELP_STAT_BROKER);
+ break;
+
+ case TASK_PRINT_VER:
+ app.printVersion();
+ break;
+
+ case TASK_PRINT_ALL_HELP:
+ app.printAllHelp();
+ break;
+
+ case TASK_NONE:
+ default:
+ break;
+ }
+ }
+
+ protected void taskStartBrokers(List brokerURIs) throws Throwable {
+
+ // Flag an error if there are multiple configuration uris
+ if (brokerURIs.size() > 1) {
+ printError("Multiple configuration uris or broker names cannot be
specified.");
+ brokerURIs.clear();
+ return;
+ }
+
+ // Add the default directories.
+ if(canUseExtdir()) {
+ this.addExtensionDirectory(new File(this.getActiveMQHome(),
"conf"));
+ this.addExtensionDirectory(new File(this.getActiveMQHome(),
"lib"));
+ this.addExtensionDirectory(new File(new
File(this.getActiveMQHome(), "lib"), "optional"));
+ }
+
+ // If no config uri, use default setting
+ if (brokerURIs.isEmpty()) {
+ this.setConfigUri(this.getDefaultUri());
+ this.startBroker(this.getConfigUri());
+
+ // Set configuration data, if available, which in this case would be
the config URI
+ } else {
+ String strConfigURI;
+// while (!brokerURIs.isEmpty()) {
+ strConfigURI = (String)brokerURIs.remove(0);
+
+ try {
+ this.setConfigUri(new URI(strConfigURI));
+ } catch (URISyntaxException e) {
+ printError("Invalid broker configuration URI: " +
strConfigURI + ", reason: " + e.getMessage());
return;
}
- main.addExtensionDirectory(directory);
- } else if (args[i].equals("--version")) {
- System.out.println();
- System.out.println("ActiveMQ " + main.getVersion());
- System.out.println("For help or more information please see:
http://www.logicblaze.com");
+ this.startBroker(this.getConfigUri());
+// }
+ }
+ }
+
+ protected void taskStopBrokers(List brokerNames) throws Throwable {
+ // Check if there is a user-specified JMX URL
+ if (this.getJmxUrl() == null) {
+ this.setJmxUrl(this.getDefaultJmxUrl());
+ }
+
+ // Stop all brokers
+ if (this.isStopAllBrokers()) {
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl);
+ MBeanServerConnection server =
jmxConnector.getMBeanServerConnection();
+
+ ObjectName brokerObjName = new ObjectName(DEFAULT_JMX_DOMAIN +
":Type=Broker,*");
+
+ this.stopBroker(server, brokerObjName);
+
+ jmxConnector.close();
+ brokerNames.clear();
+
+ return;
+ }
+
+ // Stop the default broker
+ if (brokerNames.isEmpty()) {
+ Set brokerList = this.getBrokerList(this.getJmxUrl());
+
+ // If there is no broker to stop
+ if (brokerList.isEmpty()) {
+ System.out.println("There are no brokers to stop.");
+ return;
+
+ // There should only be one broker to stop
+ } else if (brokerList.size() > 1) {
+ System.out.println("There are multiple brokers to stop. Please
select the broker(s) to stop or use --all to stop all brokers.");
System.out.println();
+ printHelp(HELP_STOP_BROKER);
+ printBrokerList(brokerList);
+ return;
+
+ // Stop the only running broker
+ } else {
+ Iterator brokerIter = brokerList.iterator();
+
+ JMXConnector jmxConnector =
JMXConnectorFactory.connect(jmxUrl);
+ MBeanServerConnection server =
jmxConnector.getMBeanServerConnection();
+
+ this.stopBroker(server,
((ObjectInstance)brokerIter.next()).getObjectName());
+
+ // Maybe no need to close, since context is already closed by
broker
+ //jmxConnector.close();
return;
- } else if (args[i].equals("-h") || args[i].equals("--help") ||
args[i].equals("-?")) {
- printUsage();
+ }
+ }
+
+ // Stop each specified broker
+ String brokerName;
+
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl);
+ MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
+
+ while (!brokerNames.isEmpty()) {
+ brokerName = (String)brokerNames.remove(0);
+ this.stopBroker(server, brokerName);
+ }
+
+ // Maybe be no need to close, since context is already closed by broker
+ //jmxConnector.close();
+ }
+
+ protected void taskListBrokers() throws Throwable {
+ // Check if there is a user-specified JMX URL
+ if (this.getJmxUrl() == null) {
+ this.setJmxUrl(this.getDefaultJmxUrl());
+ }
+
+ printBrokerList(this.getBrokerList(this.getJmxUrl()));
+ }
+
+ protected void taskStatBrokers(List brokerNames) throws Throwable {
+ // Check if there is a user-specified JMX URL
+ if (this.getJmxUrl() == null) {
+ this.setJmxUrl(this.getDefaultJmxUrl());
+ }
+
+ // Print the statistics for the default broker
+ if (brokerNames.isEmpty()) {
+ Set brokerList = this.getBrokerList(this.getJmxUrl());
+
+ // If there is no broker to stop
+ if (brokerList.isEmpty()) {
+ System.out.println("There are no brokers running.");
return;
+
+ // There should only be one broker to stop
+ } else if (brokerList.size() > 1) {
+ System.out.println("There are multiple brokers running. Please
select the broker to display the statistics for.");
+ System.out.println();
+ printHelp(HELP_STAT_BROKER);
+ printBrokerList(brokerList);
+ return;
+
+ // Print the statistics for the only running broker
} else {
- if (main.getUri() != null) {
- System.out.println("Multiple configuration uris cannot be
specified.");
- printUsage();
+ Iterator brokerIter = brokerList.iterator();
+
+ JMXConnector jmxConnector =
JMXConnectorFactory.connect(jmxUrl);
+ MBeanServerConnection server =
jmxConnector.getMBeanServerConnection();
+
+ ObjectName brokerObjName =
((ObjectInstance)brokerIter.next()).getObjectName();
+
this.printBrokerStat(brokerObjName.getKeyProperty(DEFAULT_KEY_BROKER_NAME),
this.getBrokerStat(server, brokerObjName));
+
+ jmxConnector.close();
+ return;
+ }
+ }
+
+ // Print the statistics for each specified broker
+ String brokerName;
+
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl);
+ MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
+
+ while (!brokerNames.isEmpty()) {
+ brokerName = (String)brokerNames.remove(0);
+
System.out.println("-----------------------------------------------------");
+ this.printBrokerStat(brokerName, this.getBrokerStat(server,
brokerName));
+ System.out.println();
+ }
+
+ jmxConnector.close();
+ }
+
+ public int parseTask(List tokens) {
+ if (tokens.isEmpty()) {
+ // If no defined arguments, assume start task and default uri
+ return TASK_START_BROKER;
+ }
+
+ // Process task token
+ String taskToken = (String)tokens.get(0);
+
+ if (taskToken.equals("start")) {
+ tokens.remove(0);
+ return TASK_START_BROKER;
+ } else if (taskToken.equals("stop")) {
+ tokens.remove(0);
+ return TASK_STOP_BROKER;
+ } else if (taskToken.equals("list")) {
+ tokens.remove(0);
+ return TASK_LIST_BROKER;
+ } else if (taskToken.equals("stat")) {
+ tokens.remove(0);
+ return TASK_STAT_BROKER;
+ } else if (taskToken.equals("-h") || taskToken.equals("-?") ||
taskToken.equals("--help")) {
+ // No need to parse other tokens
+ tokens.clear();
+ return TASK_PRINT_MAIN_HELP;
+ } else if (taskToken.equals("--version")) {
+ // No need to parse other tokens
+ tokens.clear();
+ return TASK_PRINT_VER;
+ } else {
+ // If not a valid task, assume start task and succeeding args are
options
+ return TASK_START_BROKER;
+ }
+ }
+
+ public void parseOptions(List tokens) {
+ String token;
+
+ while (!tokens.isEmpty()) {
+ token = (String)tokens.get(0);
+
+ // If token is an option
+ if (token.startsWith("-")) {
+
+ // Consider token to be processed
+ tokens.remove(0);
+
+ // If token is a help option
+ if (token.equals("-h") || token.equals("-?") ||
token.equals("--help")) {
+ switch (this.getTaskType()) {
+ case TASK_STOP_BROKER:
+ this.setTaskType(TASK_PRINT_STOP_HELP);
+ tokens.clear();
+ return;
+
+ case TASK_LIST_BROKER:
+ this.setTaskType(TASK_PRINT_LIST_HELP);
+ tokens.clear();
+ return;
+
+ case TASK_STAT_BROKER:
+ this.setTaskType(TASK_PRINT_STAT_HELP);
+ tokens.clear();
+ return;
+
+ case TASK_START_BROKER:
+ default:
+ this.setTaskType(TASK_PRINT_START_HELP);
+ tokens.clear();
+ return;
+
+ }
+
+ // If token is a version option
+ } else if (token.equals("--version")) {
+ this.setTaskType(TASK_PRINT_VER);
+ tokens.clear();
return;
+
+ // If token is an extension dir option
+ } else if (token.equals("--extdir")) {
+ if(!canUseExtdir()) {
+ printError("Extension directory feature not available
due to the system classpath being able to load: " + BROKER_FACTORY_CLASS);
+ tokens.clear();
+ return;
+ }
+
+ if (tokens.isEmpty()) {
+ printError("Extension directory not specified.");
+ return;
+ }
+
+ // Process extension dir token
+ File extDir = new File((String)tokens.remove(0));
+ if (!extDir.isDirectory()) {
+ printError("Extension directory specified is not valid
directory: " + extDir);
+ return;
+ }
+
+ this.addExtensionDirectory(extDir);
}
- try {
- main.setUri(new URI(args[i]));
- } catch (URISyntaxException e) {
- System.out.println("Invalid broker configuration URI: " +
args[i] + ", reason: " + e.getMessage());
- printUsage();
- return;
+
+ // If token is a system property define option
+ else if (token.startsWith("-D")) {
+ String key = token.substring(2);
+ String value = "";
+ int pos = key.indexOf("=");
+ if (pos >= 0) {
+ value = key.substring(pos + 1);
+ key = key.substring(0, pos);
+ }
+ System.setProperty(key, value);
+ }
+
+ // If token is a JMX URL option
+ else if (token.startsWith("--jmxurl")) {
+ if (tokens.isEmpty()) {
+ printError("JMX URL not specified.");
+ return;
+ }
+
+ if (getJmxUrl() != null) {
+ printError("Multiple JMX URL cannot be specified.");
+ tokens.clear();
+ return;
+ }
+
+ String strJmxUrl = (String)tokens.remove(0);
+ try {
+ this.setJmxUrl(new JMXServiceURL(strJmxUrl));
+ } catch (MalformedURLException e) {
+ printError("Invalid JMX URL format: " + strJmxUrl);
+ tokens.clear();
+ return;
+ }
+
+ // If token is stop all broker option
+ } else if (token.equals("--all")) {
+ this.setStopAllBrokers(true);
+
+ // Ignore unknown options
+ } else {
+ System.out.println("Ignoring unrecognized option: " +
token);
}
}
}
-
- // Add the default directories.
- if( canUseExtdir() ) {
- main.addExtensionDirectory(new File(main.getActiveMQHome(),
"conf"));
- main.addExtensionDirectory(new File(main.getActiveMQHome(),
"lib"));
- main.addExtensionDirectory(new File(new
File(main.getActiveMQHome(), "lib"), "optional"));
+ }
+
+ public void addExtensionDirectory(File directory) {
+ extensions.add(directory);
+ }
+
+ public void startBroker(URI configURI) throws Throwable {
+ System.out.println("Loading Message Broker from: " + configURI);
+ System.out.println("ACTIVEMQ_HOME: "+ getActiveMQHome());
+
+ ClassLoader cl = getClassLoader();
+
+ // Use reflection to start the broker up.
+ Object broker;
+ try {
+ Class brokerFactory = cl.loadClass(BROKER_FACTORY_CLASS);
+ Method createBroker = brokerFactory.getMethod("createBroker", new
Class[] { URI.class });
+ broker = createBroker.invoke(null, new Object[] { configURI });
+
+ Method start = broker.getClass().getMethod("start", new Class[]{});
+ start.invoke(broker, new Object[]{});
+
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ } catch (Throwable e) {
+ throw e;
}
-
+ }
- if (main.getUri() == null) {
- main.setUri(getDefaultUri());
+ public void stopBroker(MBeanServerConnection server, String brokerName) {
+ ObjectName brokerObjName = null;
+ try {
+ brokerObjName = new ObjectName(DEFAULT_JMX_DOMAIN +
":Type=Broker," + DEFAULT_KEY_BROKER_NAME + "=" + brokerName);
+ } catch (Exception e) {
+ System.out.println("Invalid broker name: " + brokerName);
+ return;
}
- main.run();
+ stopBroker(server, brokerObjName);
}
+ public void stopBroker(MBeanServerConnection server, ObjectName
brokerObjName) {
+ String brokerName =
brokerObjName.getKeyProperty(DEFAULT_KEY_BROKER_NAME);
- public static URI getDefaultUri() {
try {
- return new URI("xbean:activemq.xml");
- } catch (URISyntaxException e) {
- throw new RuntimeException(e);
+ server.invoke(brokerObjName, DEFAULT_METHOD_BROKER_STOP,
DEFAULT_PARAM_BROKER_STOP, DEFAULT_SIGN_BROKER_STOP);
+ System.out.println("Succesfully stopped broker: " + brokerName);
+ } catch (Exception e) {
+ // TODO: Check the exceptions thrown
+ // System.out.println("Failed to stop broker: [ " + brokerName + "
]. Reason: " + e.getMessage());
+ return;
}
}
/**
- * The extension directory feature will not work if the broker factory is
already in the classpath
+ * The extension directory feature will not work if the broker factory is
already in the classpath
* since we have to load him from a child ClassLoader we build for it to
work correctly.
- *
+ *
* @return
*/
- public static boolean canUseExtdir() {
+ public boolean canUseExtdir() {
try {
Main.class.getClassLoader().loadClass(BROKER_FACTORY_CLASS);
return false;
@@ -141,41 +564,91 @@
return true;
}
}
-
- private static void printUsage() {
- System.out.println();
- System.out.println("Usage: Main [options] uri");
- System.out.println();
- System.out.println("Options:");
- if( canUseExtdir() ) {
- System.out.println(" --extdir dir Add the jar files in the directory
to the classpath.");
- }
- System.out.println(" -Dname=value Define a system property");
- System.out.println(" --version Display version information");
- System.out.println(" -h,-?,--help Display help information");
- System.out.println();
- System.out.println("URI:");
- System.out.println();
- System.out.println(" XBean based broker configuration:");
- System.out.println(" ");
+
+ public void printHelp(int helpIndex) {
+ for (int i=0; i<taskHelp[helpIndex].length; i++) {
+ System.out.println(taskHelp[helpIndex][i]);
+ }
+ }
+
+ public void printAllHelp() {
+ for (int i=0; i<taskHelp.length; i++) {
+ printHelp(i);
+ }
+ }
+
+ public void printError(String message) {
+ System.out.println(message);
System.out.println();
- System.out.println(" Example: Main xbean:file:activemq.xml");
- System.out.println(" Loads the xbean configuration file from
the current working directory");
- System.out.println(" Example: Main xbean:activemq.xml");
- System.out.println(" Loads the xbean configuration file from
the classpath");
+ setTaskType(TASK_NONE);
+ }
+
+ public void printVersion() {
System.out.println();
- System.out.println(" URI Parameter based broker configuration:");
- System.out.println(" Example: Main broker:(tcp://localhost:61616,
tcp://localhost:5000)?useJmx=true");
- System.out.println(" Configures the broker with 2 transport
connectors and jmx enabled");
- System.out
- .println(" Example: Main broker:(tcp://localhost:61616,
network:tcp://localhost:5000)?persistent=false");
- System.out
- .println(" Configures the broker with 1 transport
connector, and 1 network connector and persistence disabled");
+ try {
+ System.out.println("ActiveMQ " + getVersion());
+ } catch (Throwable e) {
+ System.out.println("ActiveMQ <unknown version>");
+ }
+ System.out.println("For help or more information please see:
http://www.logicblaze.com");
System.out.println();
}
+ public void printBrokerList(Set brokerList) {
+ Object[] brokerArray = brokerList.toArray();
+
+ System.out.println("List of available brokers:");
+ for (int i=0; i<brokerArray.length; i++) {
+ String brokerName =
((ObjectInstance)brokerArray[i]).getObjectName().getKeyProperty("BrokerName");
+ System.out.println(" " + (i+1) + ".) " + brokerName);
+ }
+ }
+
+ public void printBrokerStat(String brokerName, Map brokerStat) {
+ printBrokerStat(brokerName, brokerStat, STAT_DISP_ALL);
+ }
+
+ public void printBrokerStat(String brokerName, Map brokerStat, int
dispFlags) {
+
+ System.out.println("Displaying usage statistics for broker: " +
brokerName);
+
+ if ((dispFlags & STAT_DISP_BROKER) != 0) {
+ System.out.println(" Broker Enqueue Count: " +
brokerStat.get(STAT_BROKER_MAP[0]));
+ System.out.println(" Broker Dequeue Count: " +
brokerStat.get(STAT_BROKER_MAP[1]));
+ System.out.println(" Broker Consumer Count: " +
brokerStat.get(STAT_BROKER_MAP[2]));
+ System.out.println(" Broker Message Count: " +
brokerStat.get(STAT_BROKER_MAP[3]));
+ System.out.println(" Broker Cached Message Count: " +
brokerStat.get(STAT_BROKER_MAP[4]));
+ System.out.println(" Broker Memory Percent Used: " +
brokerStat.get(STAT_BROKER_MAP[5]));
+ System.out.println(" Broker Memory Limit: " +
brokerStat.get(STAT_BROKER_MAP[6]));
+ System.out.println();
+ }
+ }
+
+ // Property setters and getters
+ public void setTaskType(int taskType) {
+ this.taskType = taskType;
+ }
+
+ public int getTaskType() {
+ return taskType;
+ }
+
+ public void setJmxUrl(JMXServiceURL url) {
+ jmxUrl = url;
+ }
+
+ public JMXServiceURL getJmxUrl() {
+ return jmxUrl;
+ }
+
+ public JMXServiceURL getDefaultJmxUrl() throws MalformedURLException {
+ return new JMXServiceURL(DEFAULT_JMX_URL);
+ }
+
public String getVersion() throws Throwable {
+ // TODO: Why is version returned invalid?
ClassLoader cl = getClassLoader();
+ // Use reflection to get the version
try {
Class activeMQConnectionMetaData =
cl.loadClass("org.activemq.ActiveMQConnectionMetaData");
Field field =
activeMQConnectionMetaData.getField("PROVIDER_VERSION");
@@ -185,74 +658,34 @@
}
}
- /**
- * @throws Throwable
- *
- */
- public void run() throws Throwable {
-
- System.out.println("Loading Message Broker from: " + uri);
- System.out.println("ACTIVEMQ_HOME: "+getActiveMQHome());
+ public URI getDefaultUri() throws URISyntaxException{
+ return new URI(DEFAULT_CONFIG_URI);
+ }
- ClassLoader cl = getClassLoader();
+ public void setConfigUri(URI uri) {
+ configURI = uri;
+ }
- // Use reflection to start the broker up.
- Object broker;
- try {
-
- Class brokerFactory = cl.loadClass(BROKER_FACTORY_CLASS);
- Method createBroker = brokerFactory.getMethod("createBroker", new
Class[] { URI.class });
- broker = createBroker.invoke(null, new Object[] { uri });
-
- Method start = broker.getClass().getMethod("start", new Class[]{});
- start.invoke(broker, new Object[]{});
-
- } catch (InvocationTargetException e) {
- throw e.getCause();
- } catch (Throwable e) {
- throw e;
- }
+ public URI getConfigUri() {
+ return configURI;
+ }
- final boolean[] shutdown = new boolean[]{false};
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- synchronized(shutdown) {
- shutdown[0]=true;
- shutdown.notify();
- }
- }
- });
- synchronized(shutdown) {
- while( !shutdown[0] ) {
- shutdown.wait();
- }
- }
-
- // Use reflection to stop the broker
- try {
- Method stop = broker.getClass().getMethod("stop", new Class[] {});
- stop.invoke(broker, new Object[] {});
- } catch (InvocationTargetException e) {
- throw e.getCause();
- } catch (Throwable e) {
- throw e;
- }
+ public void setStopAllBrokers(boolean stopAll) {
+ this.stopAll = stopAll;
}
+ public boolean isStopAllBrokers() {
+ return stopAll;
+ }
- /**
- * @return
- * @throws MalformedURLException
- */
public ClassLoader getClassLoader() throws MalformedURLException {
- if( classLoader==null ) {
-
+ if(classLoader==null) {
//
// Setup the ClassLoader
//
classLoader = Main.class.getClassLoader();
if (!extensions.isEmpty()) {
-
+
ArrayList urls = new ArrayList();
for (Iterator iter = extensions.iterator(); iter.hasNext();) {
File dir = (File) iter.next();
@@ -266,35 +699,28 @@
}
}
}
-
+
URL u[] = new URL[urls.size()];
urls.toArray(u);
classLoader = new URLClassLoader(u, classLoader);
}
-
Thread.currentThread().setContextClassLoader(classLoader);
}
return classLoader;
}
- public URI getUri() {
- return uri;
- }
- public void setUri(URI config) {
- this.uri = config;
- }
-
- public void addExtensionDirectory(File directory) {
- extensions.add(directory);
+ public void setActiveMQHome(File activeMQHome) {
+ this.activeMQHome = activeMQHome;
}
public File getActiveMQHome() {
- if( activeMQHome==null ) {
- if( System.getProperty("activemq.home") != null ) {
+ if(activeMQHome==null) {
+ if(System.getProperty("activemq.home") != null) {
activeMQHome = new File(System.getProperty("activemq.home"));
}
- if( activeMQHome==null ){
+
+ if(activeMQHome==null){
// guess from the location of the jar
URL url =
Main.class.getClassLoader().getResource("org/activemq/broker/Main.class");
if (url != null) {
@@ -307,6 +733,7 @@
}
}
}
+
if(activeMQHome==null){
activeMQHome = new File(".");
}
@@ -314,7 +741,150 @@
return activeMQHome;
}
- public static void setActiveMQHome(File activeMQHome) {
- Main.activeMQHome = activeMQHome;
+ public Set getBrokerList(JMXServiceURL jmxUrl) throws Throwable {
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl);
+ MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
+
+ ObjectName brokerObjName = new ObjectName(DEFAULT_JMX_DOMAIN +
":Type=Broker,*");
+
+ Set brokerMBeans = server.queryMBeans(brokerObjName, null);
+
+ jmxConnector.close();
+
+ return brokerMBeans;
+ }
+
+ public Map getBrokerStat(MBeanServerConnection server, String brokerName)
throws Throwable {
+ return getBrokerStat(server, brokerName, STAT_ALL);
+ }
+
+ public Map getBrokerStat(MBeanServerConnection server, ObjectName
brokerObjName) {
+ return getBrokerStat(server, brokerObjName, STAT_ALL);
}
+
+ public Map getBrokerStat(MBeanServerConnection server, String brokerName,
int statFlags) throws Throwable {
+ ObjectName brokerObjName = null;
+ try {
+ brokerObjName = new ObjectName(DEFAULT_JMX_DOMAIN +
":Type=Broker," + DEFAULT_KEY_BROKER_NAME + "=" + brokerName);
+ } catch (Exception e) {
+ System.out.println("Invalid broker name: " + brokerName);
+ return null;
+ }
+
+ return getBrokerStat(server, brokerObjName, statFlags);
+ }
+
+ public Map getBrokerStat(MBeanServerConnection server, ObjectName
brokerObjName, int statFlags) {
+ Map brokerStat = new HashMap();
+
+ try {
+ if ((statFlags & STAT_BROKER) != 0) {
+ for (int i=0; i<STAT_BROKER_MAP.length; i++) {
+ brokerStat.put(STAT_BROKER_MAP[i], // key name of statistic
+ server.getAttribute(brokerObjName,
(String)STAT_BROKER_MAP[i]) // attribute to get)
+ );
+ }
+ }
+ } catch (Exception e) {
+ return null;
+ }
+
+ return brokerStat;
+ }
+
+ // This section contains an array of the help notes of the different tasks
+ private static final String[][] taskHelp = {
+ // Main task help
+ {
+ "Usage: Main [task] [task-options] [task data]",
+ "",
+ "Tasks (default task is start):",
+ " start - Creates and starts a broker using a
configuration file, or a broker URI.",
+ " stop - Stops a running broker specified by the broker
name.",
+ " list - Lists all available broker in the specified
JMX context.",
+ " --version - Display the version information.",
+ " -h,-?,--help - Display this help information. To display task
specific help, use Main [task] -h,-?,--help",
+ "",
+ "Task Options:",
+ " - Properties specific to each task.",
+ "",
+ "Task Data:",
+ " - Information needed by each specific task.",
+ ""
+ },
+
+ // Start broker task help
+ {
+ "Task Usage: Main start [start-options] [uri]",
+ "",
+ "Start Options:",
+ " --extdir dir Add the jar files in the directory to the
classpath.",
+ " -Dname=value Define a system property.",
+ " --version Display the version information.",
+ " -h,-?,--help Display the start broker help information.",
+ "",
+ "URI:",
+ "",
+ " XBean based broker configuration:",
+ "",
+ " Example: Main xbean:file:activemq.xml",
+ " Loads the xbean configuration file from the current
working directory",
+ " Example: Main xbean:activemq.xml",
+ " Loads the xbean configuration file from the
classpath",
+ "",
+ " Spring based broker configuration:",
+ "",
+ " Example: Main spring:file:activemq.xml",
+ " Loads the spring configuration file from the current
working directory",
+ " Example: Main spring:activemq.xml",
+ " Loads the spring configuration file from the
classpath",
+ "",
+ " URI Parameter based broker configuration:",
+ "",
+ " Example: Main broker:(tcp://localhost:61616,
tcp://localhost:5000)?useJmx=true",
+ " Configures the broker with 2 transport connectors and
jmx enabled",
+ " Example: Main broker:(tcp://localhost:61616,
network:tcp://localhost:5000)?persistent=false",
+ " Configures the broker with 1 transport connector, and
1 network connector and persistence disabled",
+ ""
+ },
+
+ // Stop broker task help
+ {
+ "Task Usage: Main stop [stop-options] [broker-name1]
[broker-name2] ...",
+ "",
+ "Stop Options:",
+ " --jmxurl url Set the JMX URL to connect to.",
+ " --all Stop all brokers.",
+ " --version Display the version information.",
+ " -h,-?,--help Display the stop broker help information.",
+ "",
+ "Broker Names:",
+ " Name of the brokers that will be stopped.",
+ " If omitted, it is assumed that there is only one broker
running, and it will be stopped.",
+ " Use -all to stop all running brokers.",
+ ""
+ },
+
+ // List brokers task help
+ {
+ "Task Usage: Main list [list-options]",
+ "",
+ "List Options:",
+ " --jmxurl url Set the JMX URL to connect to.",
+ " --version Display the version information.",
+ " -h,-?,--help Display the stop broker help information.",
+ "",
+ },
+
+ // Stat brokers task help
+ {
+ "Task Usage: Main stat [stat-options] [broker-name1]
[broker-name2] ...",
+ "",
+ "Stat Options:",
+ " --jmxurl url Set the JMX URL to connect to.",
+ " --version Display the version information.",
+ " -h,-?,--help Display the stop broker help information.",
+ "",
+ }
+ };
}
Modified: incubator/activemq/trunk/assembly/src/release/bin/activemq
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/src/release/bin/activemq?rev=357932&r1=357931&r2=357932&view=diff
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/bin/activemq (original)
+++ incubator/activemq/trunk/assembly/src/release/bin/activemq Mon Dec 19
23:15:13 2005
@@ -124,9 +124,10 @@
# Uncomment to enable remote debugging
#ACTIVEMQ_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
+#ACTIVEMQ_TASK="start"
if [ -n "$CYGHOME" ]; then
- exec "$JAVACMD" $ACTIVEMQ_DEBUG_OPTS $ACTIVEMQ_OPTS -classpath ""
-Dactivemq.home="${ACTIVEMQ_HOME}" -Dcygwin.user.home="$CYGHOME" -jar
${ACTIVEMQ_HOME}/bin/run.jar $@
+ exec "$JAVACMD" $ACTIVEMQ_DEBUG_OPTS $ACTIVEMQ_OPTS -classpath ""
-Dactivemq.home="${ACTIVEMQ_HOME}" -Dcygwin.user.home="$CYGHOME" -jar
${ACTIVEMQ_HOME}/bin/run.jar $ACTIVEMQ_TASK $@
else
- exec "$JAVACMD" $ACTIVEMQ_DEBUG_OPTS $ACTIVEMQ_OPTS -classpath ""
-Dactivemq.home="${ACTIVEMQ_HOME}" -jar ${ACTIVEMQ_HOME}/bin/run.jar $@
+ exec "$JAVACMD" $ACTIVEMQ_DEBUG_OPTS $ACTIVEMQ_OPTS -classpath ""
-Dactivemq.home="${ACTIVEMQ_HOME}" -jar ${ACTIVEMQ_HOME}/bin/run.jar
$ACTIVEMQ_TASK $@
fi
Modified: incubator/activemq/trunk/assembly/src/release/bin/activemq.bat
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/src/release/bin/activemq.bat?rev=357932&r1=357931&r2=357932&view=diff
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/bin/activemq.bat (original)
+++ incubator/activemq/trunk/assembly/src/release/bin/activemq.bat Mon Dec 19
23:15:13 2005
@@ -87,8 +87,8 @@
set LOCALCLASSPATH=%ACTIVEMQ_HOME%\conf;%LOCALCLASSPATH%
-
-"%_JAVACMD%" %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS%
-Djava.ext.dirs="%JAVA_EXT_DIRS%" -classpath "%LOCALCLASSPATH%"
-Dactivemq.home="%ACTIVEMQ_HOME%" -jar %ACTIVEMQ_HOME%/bin/run.jar
%ACTIVEMQ_ARGS% %ACTIVEMQ_CMD_LINE_ARGS%
+set ACTIVEMQ_TASK="start"
+"%_JAVACMD%" %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS%
-Djava.ext.dirs="%JAVA_EXT_DIRS%" -classpath "%LOCALCLASSPATH%"
-Dactivemq.home="%ACTIVEMQ_HOME%" -jar %ACTIVEMQ_HOME%/bin/run.jar
%ACTIVEMQ_TASK% %ACTIVEMQ_CMD_LINE_ARGS%
goto end
Added: incubator/activemq/trunk/assembly/src/release/bin/shutdown
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/src/release/bin/shutdown?rev=357932&view=auto
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/bin/shutdown (added)
+++ incubator/activemq/trunk/assembly/src/release/bin/shutdown Mon Dec 19
23:15:13 2005
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+# ActiveMQ shell script
+#
+# $Id: activemq,v 1.1.1.1 2005/03/11 21:14:04 jstrachan Exp $
+#
+# This script is heavily based on the Ant script
+#
+# Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+# reserved.
+
+# load system-wide activemq configuration
+if [ -f "/etc/activemq.conf" ] ; then
+ . /etc/activemq.conf
+fi
+
+# provide default values for people who don't use RPMs
+if [ -z "$usejikes" ] ; then
+ usejikes=false;
+fi
+
+# load user activemq configuration
+if [ -f "$HOME/.activemqrc" ] ; then
+ . "$HOME/.activemqrc"
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ Darwin*) darwin=true
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ fi
+ ;;
+esac
+
+if [ -z "$ACTIVEMQ_HOME" ] ; then
+ # try to find ACTIVEMQ
+ if [ -d /opt/activemq ] ; then
+ ACTIVEMQ_HOME=/opt/activemq
+ fi
+
+ if [ -d "${HOME}/opt/activemq" ] ; then
+ ACTIVEMQ_HOME="${HOME}/opt/activemq"
+ fi
+
+ ## resolve links - $0 may be a link to activemq's home
+ PRG="$0"
+ progname=`basename "$0"`
+ saveddir=`pwd`
+
+ # need this for relative symlinks
+ dirname_prg=`dirname "$PRG"`
+ cd "$dirname_prg"
+
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '.*/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+ done
+
+ ACTIVEMQ_HOME=`dirname "$PRG"`/..
+
+ cd "$saveddir"
+
+ # make it fully qualified
+ ACTIVEMQ_HOME=`cd "$ACTIVEMQ_HOME" && pwd`
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$ACTIVEMQ_HOME" ] &&
+ ACTIVEMQ_HOME=`cygpath --unix "$ACTIVEMQ_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD=`which java 2> /dev/null `
+ if [ -z "$JAVACMD" ] ; then
+ JAVACMD=java
+ fi
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ ACTIVEMQ_HOME=`cygpath --windows "$ACTIVEMQ_HOME"`
+ JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ CYGHOME=`cygpath --windows "$HOME"`
+fi
+
+
+if [ -n "ACTIVEMQ_OPTS" ] ; then
+ ACTIVEMQ_OPTS="-Xmx512M -Dderby.system.home=../data
-Dderby.storage.fileSyncTransactionLog=true"
+fi
+
+# Uncomment to enable YourKit profiling
+#ACTIVEMQ_DEBUG_OPTS="-Xrunyjpagent"
+
+# Uncomment to enable remote debugging
+#ACTIVEMQ_DEBUG_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
+
+ACTIVEMQ_TASK="stop"
+if [ -n "$CYGHOME" ]; then
+ exec "$JAVACMD" $ACTIVEMQ_DEBUG_OPTS $ACTIVEMQ_OPTS -classpath ""
-Dactivemq.home="${ACTIVEMQ_HOME}" -Dcygwin.user.home="$CYGHOME" -jar
${ACTIVEMQ_HOME}/bin/run.jar $ACTIVEMQ_TASK $@
+else
+ exec "$JAVACMD" $ACTIVEMQ_DEBUG_OPTS $ACTIVEMQ_OPTS -classpath ""
-Dactivemq.home="${ACTIVEMQ_HOME}" -jar ${ACTIVEMQ_HOME}/bin/run.jar
$ACTIVEMQ_TASK $@
+fi
+
Added: incubator/activemq/trunk/assembly/src/release/bin/shutdown.bat
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/assembly/src/release/bin/shutdown.bat?rev=357932&view=auto
==============================================================================
--- incubator/activemq/trunk/assembly/src/release/bin/shutdown.bat (added)
+++ incubator/activemq/trunk/assembly/src/release/bin/shutdown.bat Mon Dec 19
23:15:13 2005
@@ -0,0 +1,106 @@
[EMAIL PROTECTED] off
+
+REM ActiveMQ shell script
+REM
+REM $Id: shutdown.bat,v 1.1.1.1 2005/12/09 21:14:04 aco Exp $
+REM
+REM This script is heavily based on the Ant script
+REM
+REM Copyright (c) 2001-2003 The Apache Software Foundation. All rights
+REM reserved.
+
+if exist "%HOME%\activemqrc_pre.bat" call "%HOME%\activemqrc_pre.bat"
+
+if "%OS%"=="Windows_NT" @setlocal
+
+rem %~dp0 is expanded pathname of the current script under NT
+set DEFAULT_ACTIVEMQ_HOME=%~dp0..
+
+if "%ACTIVEMQ_HOME%"=="" set ACTIVEMQ_HOME=%DEFAULT_ACTIVEMQ_HOME%
+set DEFAULT_ACTIVEMQ_HOME=
+
+rem Slurp the command line arguments. This loop allows for an unlimited number
+rem of arguments (up to the command line limit, anyway).
+set ACTIVEMQ_CMD_LINE_ARGS=%1
+if ""%1""=="""" goto doneStart
+shift
+:setupArgs
+if ""%1""=="""" goto doneStart
+set ACTIVEMQ_CMD_LINE_ARGS=%ACTIVEMQ_CMD_LINE_ARGS% %1
+shift
+goto setupArgs
+rem This label provides a place for the argument list loop to break out
+rem and for NT handling to skip to.
+
+:doneStart
+rem find ACTIVEMQ_HOME if it does not exist due to either an invalid value
passed
+rem by the user or the %0 problem on Windows 9x
+if exist "%ACTIVEMQ_HOME%\README.txt" goto checkJava
+
+rem check for activemq in Program Files on system drive
+if not exist "%SystemDrive%\Program Files\activemq" goto checkSystemDrive
+set ACTIVEMQ_HOME=%SystemDrive%\Program Files\activemq
+goto checkJava
+
+:checkSystemDrive
+rem check for activemq in root directory of system drive
+if not exist %SystemDrive%\activemq\README.txt goto checkCDrive
+set ACTIVEMQ_HOME=%SystemDrive%\activemq
+goto checkJava
+
+:checkCDrive
+rem check for activemq in C:\activemq for Win9X users
+if not exist C:\activemq\README.txt goto noAntHome
+set ACTIVEMQ_HOME=C:\activemq
+goto checkJava
+
+:noAntHome
+echo ACTIVEMQ_HOME is set incorrectly or activemq could not be located. Please
set ACTIVEMQ_HOME.
+goto end
+
+:checkJava
+set _JAVACMD=%JAVACMD%
+set LOCALCLASSPATH=%CLASSPATH%
+
+set
JAVA_EXT_DIRS=%JAVA_HOME%\lib\ext;%ACTIVEMQ_HOME%;%ACTIVEMQ_HOME%\lib;%ACTIVEMQ_HOME%\lib\optional
+
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
+goto runAnt
+
+:noJavaHome
+if "%_JAVACMD%" == "" set _JAVACMD=java.exe
+echo.
+echo Warning: JAVA_HOME environment variable is not set.
+echo.
+
+:runAnt
+
+if "%ACTIVEMQ_OPTS%" == "" set ACTIVEMQ_OPTS=-Xmx512M
-Dderby.system.home="..\data" -Dderby.storage.fileSyncTransactionLog=true
+
+REM Uncomment to enable YourKit profiling
+REM SET ACTIVEMQ_DEBUG_OPTS="-Xrunyjpagent"
+
+REM Uncomment to enable remote debugging
+REM SET ACTIVEMQ_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
+
+set LOCALCLASSPATH=%ACTIVEMQ_HOME%\conf;%LOCALCLASSPATH%
+
+set ACTIVEMQ_TASK="stop"
+"%_JAVACMD%" %ACTIVEMQ_DEBUG_OPTS% %ACTIVEMQ_OPTS%
-Djava.ext.dirs="%JAVA_EXT_DIRS%" -classpath "%LOCALCLASSPATH%" -jar
%ACTIVEMQ_HOME%/bin/run.jar %ACTIVEMQ_TASK% %ACTIVEMQ_CMD_LINE_ARGS%
+
+
+goto end
+
+
+:end
+set LOCALCLASSPATH=
+set _JAVACMD=
+set ACTIVEMQ_CMD_LINE_ARGS=
+
+if "%OS%"=="Windows_NT" @endlocal
+
+:mainEnd
+if exist "%HOME%\activemqrc_post.bat" call "%HOME%\activemqrc_post.bat"
+