Affects Version/s: 5.10.0
Fix Version/s: None
AMQ : 5.10.0
java : Oracle 1.7.0_72-b14
OS : debian 7.4
Here is the fragement of our spring config which declares the connectors:
<amq:networkConnector name="brokerName" uri="multicast://default" />
<amq:transportConnector name="openwire" uri="tcp://10.1.1.5:61616" discoveryUri="multicast://default">
<amq:publishedAddressPolicy publishedHostStrategy="IPADDRESS" />
We have a configuration where several IP addresses are given to the machine in /etc/hosts. There is no dns resolving mybox.
The relevant part is this one:
127.0.0.1 mybox localhost
In org.apache.activemq.transport.tcp.TcpTransportServer:138, the method bind() calls resolveHostName(serverSocket, addr) to rewrite the URI (why??).
The URI tcp://10.1.1.5:61616 is rewritten tcp://mybox:61616.
We can't advertise tcp://mybox:61616 since there is no name resolution. This is why the publishedAddressPolicy is set to IPADDRESS.
The multicast agent rewrites the URI again but the name resolution found for mybox is 127.0.0.1. The advertised URI is now tcp://127.0.0.1:61616. Each broker tries to connect to themselves.
Depending on the order of the lines in /etc/hosts to resolve to the correct ip is about random chance.
Is this call to resolveHostName(serverSocket, addr) really necessary? Why trying to outsmart the configuration?