0

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&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61623?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1889?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61625?maximumConnections=1000&amp;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&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5673?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;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
Sri
  • 63
  • 2
  • 10
  • Yes, @JustinBertram I have implemented it as a master-slave with a shared file system. I have multiple instances of ActiveMQ running – Sri Mar 02 '20 at 03:20
  • Right now this is how I am implementing my message broker https://www.npmjs.com/package/rhea using rhea – Sri Mar 02 '20 at 03:23
  • Your question lacks details needed to really provide sufficient answers, please edit and expand on your setup and what you are trying to achieve and what you've tried which hasn't worked out. – Tim Bish Mar 02 '20 at 03:26
  • @TimBish, I have updated my question with more inputs, kindly validate and provide an answer, please – Sri Mar 02 '20 at 03:37
  • The Spring Boot implementation is irrelevant as far as I can tell since it is using the OpenWire JMS client rather an rhea. The two clients are completely different. It's not clear to me why you've mentioned it here. – Justin Bertram Mar 02 '20 at 04:13
  • @JustinBertram I wanted to implement the failover mechanism in my NodeJS rhea code as Springboot is doing with JMS. That is why I have give an example of the implementation I want in NodejS, which is being implemented in Java straightforward – Sri Mar 02 '20 at 04:24
  • at least I want to provide multiple connections at container.connect(multipleconnections) from which it will pick available connections instead of container.connect({'port':5672}) – Sri Mar 02 '20 at 04:45

1 Answers1

0

You have to do some work to build your client code such that reconnect happens, rhea doesn't have the sort of failover processing support that clients like Qpid JMS or the Artemis Core JMS client do.

There is a reconnect example in the Rhea source tree that you can use as a starting point to build that logic into your own application.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42