I was looking at the method protected JMXServiceURL useJmxServiceUrl() throws
MalformedURLException in
org.apache.activemq.console.command.AbstractJmxCommand -
Here is the relevant code from that method -
List allVMs = (List)getVMList.invoke(null, (Object[])null);
for(Object vmInstance : allVMs) {
String displayName =
(String)getVMDescriptor.invoke(vmInstance, (Object[])null);
if (displayName.contains("activemq.jar start")) {
String id = (String)getVMId.invoke(vmInstance,
(Object[])null);
Object vm = attachToVM.invoke(null, id);
Properties agentProperties =
(Properties)getAgentProperties.invoke(vm, (Object[])null);
String connectorAddress =
agentProperties.getProperty(CONNECTOR_ADDRESS);
if (connectorAddress != null) {
jmxUrl = connectorAddress;
connectingPid = Integer.parseInt(id);
context.print("useJmxServiceUrl Found JMS Url:
" + jmxUrl);
break;
}
}
}
The loop that goes thru allVMs seems to have a "break;" statement if the
connectorAddress is not null. So, the code might have a bug in it since it
might break after the first vm in allVMs.
This code has not been modified in a while. I talked to my friend and he said
that "the assumption at the time might have been to just use the first broker
you find since the commands weren't really written with the idea that they'd be
dealing with multiple brokers. If you want the commands to work with more than
one broker on the same machine there might be room for some contributions"
Pull requests are welcome.
Thanks.
----- Original Message -----
From: "Gerard Weatherby" <[email protected]>
To: [email protected]
Sent: Thursday, August 13, 2015 9:52:53 AM
Subject: Second instance uses wrong pid
ActiveMQ 5.11.1
We have multiple instances running on the same server. This were created using
the activemq script "create" command and then changing the openwire port in
activemq.xml and the web port in jetty.xml. All transports other than openwire
are commented out.
The instances are in sibling directories:
/usr/local/apache-activemq-5.11.1/rel
/usr/local/apache-activemq-5.11.1/qbio
Et. al.
The correct pids are in the corresponding data/activemq.pid files.
When I execute "qbio query" it finds and queries the activemq instance of a
different server. From the log message, it seems to have something to do with
jmxServiceUrl, but I don't understand what that's about. Here's the top lines
of output, ending with the wrong pid:
INFO: Loading '/usr/local/apache-activemq-5.11.1/bin/env'
INFO: Using java '/usr/lib/jvm/jdk1.8.0_45/jre/bin/java'
Java Runtime: Oracle Corporation 1.8.0_45 /usr/lib/jvm/jdk1.8.0_45/jre
Heap sizes: current=1005056k free=989327k max=1005056k
JVM args: -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties
-Djava.security.auth.login.config=/usr/local/apache-activemq-5.11.1/qbio/conf/login.config
-Dactivemq.classpath=/usr/local/apache-activemq-5.11.1/qbio/conf:
-Dactivemq.home=/usr/local/apache-activemq-5.11.1
-Dactivemq.base=/usr/local/apache-activemq-5.11.1/qbio
-Dactivemq.conf=/usr/local/apache-activemq-5.11.1/qbio/conf
-Dactivemq.data=/usr/local/apache-activemq-5.11.1/qbio/data
Extensions classpath:
[/usr/local/apache-activemq-5.11.1/qbio/lib,/usr/local/apache-activemq-5.11.1/lib,/usr/local/apache-activemq-5.11.1/qbio/lib/camel,/usr/local/apache-activemq-5.11.1/qbio/lib/optional,/usr/local/apache-activemq-5.11.1/qbio/lib/web,/usr/local/apache-activemq-5.11.1/qbio/lib/extra,/usr/local/apache-activemq-5.11.1/lib/camel,/usr/local/apache-activemq-5.11.1/lib/optional,/usr/local/apache-activemq-5.11.1/lib/web,/usr/local/apache-activemq-5.11.1/lib/extra]
ACTIVEMQ_HOME: /usr/local/apache-activemq-5.11.1
ACTIVEMQ_BASE: /usr/local/apache-activemq-5.11.1/qbio
ACTIVEMQ_CONF: /usr/local/apache-activemq-5.11.1/qbio/conf
ACTIVEMQ_DATA: /usr/local/apache-activemq-5.11.1/qbio/data
useJmxServiceUrl Found JMS Url:
service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc5AAtVbmljYXN0UmVmMgAADjE1NS4zNy4xNzYuMTg3AADuGJUNmYhm4HoFE5hCNgAAAU8M22XIgAEAeA==
Connecting to pid: 27587
Tech data:
Linux code2.cam.uchc.edu 2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33
CST 2011 x86_64 x86_64 x86_64 GNU/Linux
CentOS release 6.2 (Final)
JRE 1.8.0_45
Not using an application server.
Thanks,
Gerard Weatherby | Application Architect
Center for Cell Analysis & Modeling | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
Office: 860.679.2065
uchc.edu