[rabbitmq-discuss] Autorecovery Issue
Ranjitha Shet
ranjithavshet09 at gmail.com
Wed Jun 4 12:20:13 BST 2014
Hi,
I am trying to use the autorecovery feature..
public ConnectToRabbitMq(String sServeltName, String sDeviceName, Object
oStreamType) throws IOException {
/* *****create a connection to the server/broker:******************/
ConnectionFactory factory = new ConnectionFactory();
factory.setAutomaticRecoveryEnabled(true);
factory.setUsername(USERNAME);//the AMQP user name used when
connecting to the broker
factory.setPassword(PASSWORD);//the password used when connecting
to the broker
factory.setVirtualHost(VHOST);//the virtual host used when
connecting to the broker
factory.setHost(HOST);//connect to a broker on the local machine -
hence the localhost.
factory.setPort(PORT);//the default port used for connections
connection = factory.newConnection();
channel = connection.createChannel();// data channel, opens channel
/* *****create a connection to the server/broker:******************/
/* ******declare que and exch******************/
exchangeName = sDeviceName;
queueName = new
StringBuffer(sServeltName).append('_').append(exchangeName).toString();
channel.exchangeDeclare(exchangeName, "topic", false, false,
null);
channel.queueDeclare(queueName, false, false, true, null);
/* ******declare que and exch******************/
String replytoBindinKey = SOMEKEY;
channel.queueBind(queueName, exchangeName, replytoBindinKey);
consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, true, consumer);
}
What I am trying to do is..,
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..
and I receive the response..
To publish I use --> channel.basicPublish
and to receive message what I do is -->
while(true){
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
..
..
}
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))
I get the following message.
Caught an exception during connection recovery!
java.net.NoRouteToHostException: No route to host: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at
com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at
com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:34)
at
com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverConnection(AutorecoveringConnection.java:388)
at
com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:360)
at
com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access$000(AutorecoveringConnection.java:48)
at
com.rabbitmq.client.impl.recovery.AutorecoveringConnection$1.shutdownCompleted(AutorecoveringConnection.java:345)
at
com.rabbitmq.client.impl.ShutdownNotifierComponent.notifyListeners(ShutdownNotifierComponent.java:75)
at
com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)
at java.lang.Thread.run(Thread.java:619)
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
DefaultExceptionHandler: Consumer
com.rabbitmq.client.QueueingConsumer at 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):
com.rabbitmq.client.ShutdownSignalException: connection error
at
com.rabbitmq.client.QueueingConsumer.checkShutdown(QueueingConsumer.java:172)
at
com.rabbitmq.client.QueueingConsumer.handleDelivery(QueueingConsumer.java:124)
at
com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:140)
at
com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:85)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.SocketException: Software caused connection abort: recv
failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:271)
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)
at
com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:139)
at
com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:532)
... 1 more
On connecting back the network cable.., connection , channel, exchange, que
and binding cant be recovered? Not getting where I am going wrong..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140604/0bed955c/attachment.html>
More information about the rabbitmq-discuss
mailing list