I have multiple instances of ActiveMQ running on my machine. They are configured as shared file system master slave. If one ActiveMQ server is down then the other should be picked up automatically. This is working as expected.
Relevant configuration for the first instance of ActiveMQ:
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61626?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61623?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1889?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61625?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<persistenceAdapter>
<kahaDB directory="/Users/srikanth.doddi/Downloads/apachemq3.2.4/data/kahadb"/>
</persistenceAdapter>
Relevant configuration for the second instance of ActiveMQ:
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5673?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<persistenceAdapter>
<kahaDB directory="/Users/srikanth.doddi/Downloads/apachemqold/data/kahadb"/>
</persistenceAdapter>
I am using an AMQP connection in NodeJS use rhea in the following way:
var container = require('rhea');
container.on('message', function (context) {
console.log(context.message.body);
context.connection.close();
});
container.once('sendable', function (context) {
context.sender.send({body:'Hello World!'});
});
var connection = container.connect({'port':5672});
connection.open_receiver('examples');
connection.open_sender('examples');
Now since I have my ActiveMQ running as master-slave if 5672 is down I want the client to automatically connect to 5673 and continue working. This check should happen continuously.
This is how it is implemented in Spring-boot
activemq_url=tcp://localhost:61616,tcp://localhost:61626
spring.activemq.broker-url=failover://(${activemq_url})?randomize=false