问题
I am using Apache ActiveMQ version 5.8.0
and I downloaded Apache ActiveMQ Browser version 2.5.2.8
Within Apache ActiveMQ I edited the activemq.xml
configuration to use JMX:
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true" brokerName="localhost" dataDirectory="${activemq.data}">
<!-- This needed to be set to true, otherwise JMX won't start in 5.8.0 -->
<managementContext>
<managementContext createConnector="true"/>
</managementContext>
</broker>
Within the startup script I set the JMX settings as follows:
#ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=11099 "
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_CONF}/jmx.password"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_CONF}/jmx.access"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote.ssl=false"
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote"
When I restart Apache ActiveMQ, the log shows me the JMX is started and accessible:
JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi | org.apache.activemq.broker.jmx.ManagementContext | JMX connector
Also checking if the port is listening results into a listening port:
[me@server ~]$ netstat -lptun | grep 1099
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 :::1099 :::* LISTEN 16775/java
Apache ActiveMQ is running on a server. For example on IP 10.0.0.100. Apache ActiveMQ Browser runs on my PC (10.0.0.200).
When I try to connect with Apache ActiveMQ Browser the connections keeps failing. I'm using the following settings:
JMX URL: service:jmx:rmi:///jndi/rmi://10.0.0.100:1099/jmxrmi
JMX role: admin
JMS password: activemq
I left the user and password at this moment as default in jmx.password and jmx.access.
I also tried when connecting with putty to create a tunnel for port 1099 to local port 1099 and then connect to localhost instead of 10.0.0.100 to be sure no firewall is the issue. But all fails.
Am I forgetting anything?
回答1:
Unfortunately, JMX needs two ports to operate properly. And the second one (the RMI registry port) is by default picked randomly causing problems with firewalls etc.
Since JDK7u4 you can use
-Dcom.sun.management.jmxremote.rmi.port=<port>
to set the RMI port to be used.
回答2:
After hours of suffering. The magic to connect behind a firewall.
<managementContext>
<managementContext createConnector="true" rmiServerPort="1098" connectorPort="1099" />
</managementContext>
Sample connection string:
service:jmx:rmi://10.0.4.14:1098/jndi/rmi://10.0.4.14:1099/jmxrmi
回答3:
If you are restricted by JDK version, so cannot use -Dcom.sun.management.jmxremote.rmi.port, you can alternatively specify the RMI registry port in the managementContext itself.
<broker xmlns="http://activemq.apache.org/schema/core" useJmx="true" brokerName="localhost" dataDirectory="${activemq.data}">
...
<managementContext>
<managementContext connectorPort="1099" rmiServerPort="<port>" />
</managementContext>
...
</broker>
回答4:
For me I got this: Connection refused to host: ; nested exception is: ....
even though it was TCP listening on its jmx port.
Seems I also needed -Djava.rmi.server.hostname=my.local.ip.address then it worked with normal connect url
service:jmx:rmi:///jndi/rmi://host:your_jmxremote_port/jmxrmi
not sure why...
Possibly also needed this on activemq side, not sure:
--jmxurl service:jmx:rmi:///jndi/rmi://127.0.0.1:11099/jmxrmi
来源:https://stackoverflow.com/questions/19093003/apache-activemq-browser-cant-connect-to-jmx-console