[rabbitmq-discuss] Java client: closed connection doesn't raise exception immediately

carlhoerberg carl.hoerberg at gmail.com
Tue May 7 04:32:49 BST 2013


It looks like the rabbitmq java client doesn't raise an exception as soon as
a connection fails, eg. due to network cable disconnection. 

The following code will continue to run for 2 minutes after the
disconnection, and first then raise an exception. 
 
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setUri("MyUri");
        connection = connectionFactory.newConnection();
        channel = connection.createChannel();
        channel.exchangeDeclare("messagesExchange", "direct", true);
        channel.queueDeclare("messagesQueue", true, false, false, null);
        channel.queueBind("messagesQueue", "messagesExchange",
"messagesRK");
        for (int i = 0;i<10000;i++){
          try {
            channel.basicPublish("messagesExchange",
"messagesRK",MessageProperties.PERSISTENT_TEXT_PLAIN, "My
message".getBytes());
           } catch (IOException ioe) {
             //I would expect that this exception will throw on network
failure but nothing happens
            System.out.println("Error enqueueing message " + ioe);
         }
       }




--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/Java-client-closed-connection-doesn-t-raise-exception-immediately-tp26465.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list