<div dir="ltr">Hi,<div><br></div><div><div>I am trying to use the autorecovery feature.. </div><div><br></div><div><br></div><div>public ConnectToRabbitMq(String sServeltName, String sDeviceName, Object oStreamType) throws IOException {</div>
<div><br></div><div>        /* *****create a connection to the server/broker:******************/</div><div>        ConnectionFactory factory = new ConnectionFactory();</div><div><br></div><div>        factory.setAutomaticRecoveryEnabled(true);</div>
<div>      </div><div>        factory.setUsername(USERNAME);//the AMQP user name used when connecting to the broker</div><div>        factory.setPassword(PASSWORD);//the password used when connecting to the broker</div><div>
        factory.setVirtualHost(VHOST);//the virtual host used when connecting to the broker</div><div>        factory.setHost(HOST);//connect to a broker on the local machine - hence the localhost.  </div><div>        factory.setPort(PORT);//the default port used for connections</div>
<div><br></div><div>        connection = factory.newConnection(); </div><div>        channel = connection.createChannel();// data channel, opens channel</div><div>        </div><div>        /* *****create a connection to the server/broker:******************/</div>
<div><br></div><div>            /* ******declare que and exch******************/</div><div><br></div><div>            exchangeName = sDeviceName;</div><div>            queueName = new StringBuffer(sServeltName).append('_').append(exchangeName).toString();</div>
<div><br></div><div>            channel.exchangeDeclare(exchangeName, "topic", false, false, null); </div><div>            channel.queueDeclare(queueName, false, false, true, null);</div><div><br></div><div>            /* ******declare que and exch******************/</div>
<div><br></div><div>            String replytoBindinKey = SOMEKEY;</div><div>            </div><div>            channel.queueBind(queueName, exchangeName, replytoBindinKey);</div><div><br></div><div>            consumer = new QueueingConsumer(channel);</div>
<div>            channel.basicConsume(queueName, true, consumer);</div><div><br></div><div>    }</div><div><br></div><div>What I am trying to do is.., </div><div>I publish a message(request) to a particular exchange.., it goes to server and in server side.., based on request published and routingkey,, response is published from server side..</div>
<div>and I receive the response..</div><div><br></div><div>To publish I use  --> channel.basicPublish</div><div><br></div><div>and to receive message what I do is --> </div><div><br></div><div>while(true){</div><div>
<br></div><div>QueueingConsumer.Delivery delivery = consumer.nextDelivery();</div><div>..</div><div>..</div><div>}</div><div><br></div><div>when I disconnect the network cable, say it gets disconnected when both receiving and publishing takes place.. (Message published and received are different messages(same exchange))</div>
<div> I get the following message.</div><div><br></div><div>Caught an exception during connection recovery!</div><div>java.net.NoRouteToHostException: No route to host: connect</div><div><span class="" style="white-space:pre">       </span>at java.net.PlainSocketImpl.socketConnect(Native Method)</div>
<div><span class="" style="white-space:pre">    </span>at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)</div><div><span class="" style="white-space:pre">    </span>at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)</div>
<div><span class="" style="white-space:pre">    </span>at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)</div><div><span class="" style="white-space:pre">      </span>at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)</div>
<div><span class="" style="white-space:pre">    </span>at java.net.Socket.connect(Socket.java:519)</div><div><span class="" style="white-space:pre">        </span>at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:34)</div><div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverConnection(AutorecoveringConnection.java:388)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:360)</div><div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access$000(AutorecoveringConnection.java:48)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.recovery.AutorecoveringConnection$1.shutdownCompleted(AutorecoveringConnection.java:345)</div><div><span class="" style="white-space:pre">       </span>at com.rabbitmq.client.impl.ShutdownNotifierComponent.notifyListeners(ShutdownNotifierComponent.java:75)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)</div><div><span class="" style="white-space:pre">     </span>at java.lang.Thread.run(Thread.java:619)</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></div><div>and on connecting back.., if server side publish message to tat particular exchange.., wont receive any message in my application,, and I get this error</div>
<div><br></div><div>DefaultExceptionHandler: Consumer com.rabbitmq.client.QueueingConsumer@137d090 (amq.ctag-gl009sKgA7rr2PyKA1MxAS) method handleDelivery for channel AMQChannel(amqp://guest@localhost:5672/,1) threw an exception for channel AMQChannel(amqp://guest@localhost:5672/,1):</div>
<div>com.rabbitmq.client.ShutdownSignalException: connection error</div><div><span class="" style="white-space:pre">        </span>at com.rabbitmq.client.QueueingConsumer.checkShutdown(QueueingConsumer.java:172)</div><div><span class="" style="white-space:pre">   </span>at com.rabbitmq.client.QueueingConsumer.handleDelivery(QueueingConsumer.java:124)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:140)</div><div><span class="" style="white-space:pre">  </span>at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:85)</div>
<div><span class="" style="white-space:pre">    </span>at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</div><div><span class="" style="white-space:pre">     </span>at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</div>
<div><span class="" style="white-space:pre">    </span>at java.lang.Thread.run(Thread.java:619)</div><div>Caused by: java.net.SocketException: Software caused connection abort: recv failed</div><div><span class="" style="white-space:pre">  </span>at java.net.SocketInputStream.socketRead0(Native Method)</div>
<div><span class="" style="white-space:pre">    </span>at java.net.SocketInputStream.read(SocketInputStream.java:129)</div><div><span class="" style="white-space:pre">     </span>at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)</div>
<div><span class="" style="white-space:pre">    </span>at java.io.BufferedInputStream.read(BufferedInputStream.java:237)</div><div><span class="" style="white-space:pre">  </span>at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:271)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)</div><div><span class="" style="white-space:pre">  </span>at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:139)</div>
<div><span class="" style="white-space:pre">    </span>at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:532)</div><div><span class="" style="white-space:pre">     </span>... 1 more</div><div><br></div><div>
<br></div><div>On connecting back the network cable.., connection , channel, exchange, que and binding cant be recovered? Not getting where I am going wrong..</div></div><div><br></div><div><br></div><div><br></div></div>