<div dir="ltr"><div>Created Cluster with two rabbitMQ nodes. Configuration is as below for rabbit1 and rabbit2 nodes.</div><div><br></div><div>    1&gt; CachingConnectionFactory connectionFactory = new CachingConnectionFactory();</div>
<div>    connectionFactory.setAddresses(&quot;rabbit1:5672,rabbit2:5672&quot;);</div><div><br></div><div>2&gt; node types</div><div>rabbit1 - disc node</div><div>rabbit2 - ram node</div><div>3&gt; producer and consumer programs sits on rabbit2 node(ie&gt; ram node)</div>
<div>    </div><div>    4&gt; Producer sample code -</div><div>    String QueueName = &quot;Queue.&quot;;</div><div>    for(int m=0; m&lt;50000; m++){</div><div>    <span class="" style="white-space:pre">        </span>// send message</div>
<div>    <span class="" style="white-space:pre">        </span>System.out.println(this.rabbitTemplate.getConnectionFactory().getHost());</div><div>    <span class="" style="white-space:pre">        </span>this.rabbitTemplate.convertAndSend(m);</div>
<div>    <span class="" style="white-space:pre">        </span>/*Thread.sleep(100);*/</div><div>    }</div><div>    </div><div>    5&gt; consumer code -</div><div>    String QueueName = &quot;Queue.&quot;;</div><div>    public void run() {</div>
<div>    <span class="" style="white-space:pre">        </span>System.out.println(&quot;Consumer running host : &quot; + this.connectionFactory.getHost());</div><div>    <span class="" style="white-space:pre">        </span>SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();</div>
<div>    <span class="" style="white-space:pre">        </span>container.setConnectionFactory(this.connectionFactory);</div><div>    <span class="" style="white-space:pre">        </span>container.setQueueNames(this.queueName);</div><div>
    <span class="" style="white-space:pre">        </span>container.setMessageListener(new MessageListenerAdapter(new TestMessageHandler(this.connectionFactory.getHost()), new JsonMessageConverter())); </div><div>    <span class="" style="white-space:pre">        </span>container.start();</div>
<div>    }</div><div>    </div><div>    TestMessageHandler class sample code-</div><div>    </div><div>    <span class="" style="white-space:pre">        </span>public TestMessageHandler(String hostName){</div><div>    <span class="" style="white-space:pre">                </span>System.out.println(&quot;Host: &quot; + hostName);</div>
<div>    <span class="" style="white-space:pre">                </span>this.hostName = hostName;</div><div>    <span class="" style="white-space:pre">        </span>}</div><div>    <span class="" style="white-space:pre">        </span></div><div>    <span class="" style="white-space:pre">        </span>// Handle message</div>
<div>    <span class="" style="white-space:pre">        </span>public void handleMessage(int message) {</div><div>    <span class="" style="white-space:pre">                </span>System.out.println(&quot;handleMessage Host: &quot; + this.hostName);</div>
<div>    <span class="" style="white-space:pre">                </span>System.out.println(&quot;Int : &quot; + message);</div><div>    <span class="" style="white-space:pre">        </span>}</div><div>    <span class="" style="white-space:pre">        </span></div>
<div>    6&gt; Each node executed below policy</div><div>    cmd&gt; rabbitmqctl set_policy ha-all &quot;^Queue\.&quot; &quot;{&quot;&quot;ha-mode&quot;&quot;:&quot;&quot;all&quot;&quot;}&quot;</div><div>    </div><div>    7&gt; Started producer and consumer simultaneously. Could see host name as &quot;rabbit1&quot; then stopped &quot;rabbit1&quot; node with &quot;rabbitmqctl stop_app&quot; command to test fail-over scenario. Then got the below error</div>
<div>    </div><div>        WARN  [.listener.SimpleMessageListenerContainer]: Consumer raised exception, processing can restart if the connection factory supports it</div><div>        com.rabbitmq.client.ShutdownSignalException: connection error; reason: {#method&lt;connection.close&gt;(reply-code=541, reply-text=INTERNAL_ERROR, class-id=0, method-id=0), null, &quot;&quot;}</div>
<div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQConnection.startShutdown(AMQConnection.java:678)</div><div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQConnection.shutdown(AMQConnection.java:668)</div>
<div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQConnection.handleConnectionClose(AMQConnection.java:624)</div><div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQConnection.processControlCommand(AMQConnection.java:598)</div>
<div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQConnection$1.processAsync(AMQConnection.java:96)</div><div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:144)</div>
<div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:91)</div><div>        <span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:523)</div>
<div>        INFO  [.listener.SimpleMessageListenerContainer]: Restarting Consumer: tag=[amq.ctag-5CJ3YJYfMZDnJOnXsds6_Q], channel=Cached Rabbit Channel: AMQChannel(amqp://<a href="http://guest@192.168.97.70:5672/,1">guest@192.168.97.70:5672/,1</a>), acknowledgeMode=AUTO local queue size=0</div>
<div>    </div><div>    after this warning, again am getting host name as &quot;rabbit1&quot; only. actually it should be &quot;rabbit2&quot; as per my understanding but its not happening.</div><div>    </div><div>        So, here are my Queries -</div>
<div>        </div><div>            1&gt; Why am getting host name as &quot;rabbit1&quot; even after stopping?</div><div>            2&gt; To test the fail-over do we require any load balancer?</div><div>            3&gt; If my steps are wrong for testing fail-over case, please provide steps for the same?</div>
<div>            4&gt; How to distribute queues/messages to particular node, as below, 1-500 messages/queues to node1, 501-1000 messages/queues to node2, etc.</div><div>            5&gt; Please let me know is there any other approach to test fail-over scenario?</div>
<div><br></div><div>Appreciate any help on this.</div><div><br></div><div><br></div><div><br></div></div>