I have a simple REST application running on Tomcat8 in a docker container. I also have 3 docker containers running ActiveMQ 5.11.1 broker in master slave (with mysql as persistence) on ports 61616
, 61617
and 61618
respectively.
docker run --name myRESTApp -t -i --rm -p 8080:8080 -p 9090:9090 -v $(pwd)/webapps:/usr/local/tomcat/webapps -v $(pwd)/logs:/usr/local/tomcat/logs --link activemq1:activemq myRESTApp
In myRESTApp's activeMQConfiguration.xml
:
<property name="brokerURL" value="failover:(#{systemEnvironment['ACTIVEMQ_PORT_61616_TCP']})?randomize=false"/>
The 3 ActiveMQ brokers has this in their activemq.xml
:
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:0" updateClusterClients="true" rebalanceClusterClients="true" updateClusterClientsOnRemove="true" />
</transportConnectors>
The master initially was running on 61616
, I stopped the master, slave (port 61617
) became the new master.
Even before the master on 61616
was stopped, it threw
Connect fail to: tcp://172.17.0.84:61616, reason: java.net.ConnectException: Connection refused
Why after linking, it still unable to connect to the broker?
After the master on 61616
is stopped, it is failing with:
Connect fail to: tcp://172.17.0.84:61616, reason: java.net.NoRouteToHostException: No route to host
Shouldn't it auto update the client of the new master like what being mentioned here?
Can anyone please advise what is the best practise for connecting the ActiveMQ cluster of broker to my application? Thanks