Reputation: 3174
I have ActiveMQ "Classic" 5.10.0 running on a server, and I'm trying to use the command line to extract the information that I'd see in the web console.
None of the commands work. In the bin
folder is the activemq
script to do run commands, (e.g. ./activemq bstat
or ./activemq list
) but I keep getting this error:
Connecting to JMX URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
ERROR: java.lang.RuntimeException: Failed to execute list task. Reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused]
java.lang.RuntimeException: Failed to execute list task. Reason: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
Oddly enough, when I download and start the same version of the broker on my local pc, the commands work. This is the output I get when attempting the list
command:
> activemq list
Java Runtime: Oracle Corporation 1.8.0_161 C:\Program Files\Java\jdk1.8.0_161\jre
Heap sizes: current=1005056k free=989327k max=1005056k
JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -
...........
<more log data>
...........
useJmxServiceUrl Found JMS Url: service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc5AAtVbmljYXN0UmVmMgAADjE2OS4yNTQuNjguMjM3AADDoqnwRJwaEyt6UvhZyAAAAXFkS9pNgAEAeA==
Connecting to pid: 3332
brokerName = localhost
How do I get the same commands to work that is running on the remote server?
Upvotes: 1
Views: 2097
Reputation: 3174
So looking at similar issues on StackOverflow and other sites, it seems like I need to add JVM arguments to ActiveMQ when its kicked off.
The bin folder of AMQ contains a script activemq
, in the same bin folder that script kicks off an activemq.jar
file.
I needed to update part of the script file to include those JVM arguments (in your script don't include the # comments at the end of the line):
<script code above>
# Execute java binary
if [ -n "$PIDFILE" ] && [ "$PIDFILE" != "stop" ];then
$EXEC_OPTION $DOIT_PREFIX "$JAVACMD $ACTIVEMQ_OPTS $ACTIVEMQ_DEBUG_OPTS \
-Dactivemq.classpath=\"${ACTIVEMQ_CLASSPATH}\" \
-Dactivemq.home=\"${ACTIVEMQ_HOME}\" \
-Dactivemq.base=\"${ACTIVEMQ_BASE}\" \
-Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \
-Dactivemq.data=\"${ACTIVEMQ_DATA}\" \
-Dcom.sun.management.jmxremote \ #THIS is added
-Dcom.sun.management.jmxremote.port=1099 \ #THIS is added
-Dcom.sun.management.jmxremote.rmi.port=1099 \ #THIS is added
-Dcom.sun.management.jmxremote.authenticate=false \ #THIS is added
-Dcom.sun.management.jmxremote.ssl=false \ #THIS is added
$ACTIVEMQ_CYGWIN \
-jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS >/dev/null 2>&1 &
RET=\"\$?\"; APID=\"\$!\";
echo \$APID > $PIDFILE;
echo \"INFO: pidfile created : '$PIDFILE' (pid '\$APID')\";exit \$RET" $DOIT_POSTFIX
RET="$?"
<script code below>
Afterwards I just start the ./activemq
script, and now I'm able to do the Command Lines as I could do on AMQ running on my machine.
Upvotes: 1