Я использую Java-клиент rabbitmq 2.4.1, новейшую версию.
После потери соединения TCP и вызова метода по каналу через это соединение будет выдано исключение AlreadyClosedException.
Это ошибка?Я ожидал IOException, но AlreadyClosedException, которое я получил, и AlreadyClosedException - это RuntimeException.
Если нет, почему все другие ошибки вызывают IOException.
@Test
public void testConnectionLost() throws IOException{
ConnectionFactory factory = new ConnectionFactory();
factory.setRequestedHeartbeat(60);
factory.setHost("<your rabbitmq host>");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
connection.close();
try {
channel.queueDeclare("queueName", false, false, false, null);
Assert.fail("Exception expected.");
}catch (IOException e) {
//it will NOT reach here.
//Inner exception should be AlreadyClosedException
System.out.println(e);
}catch (AlreadyClosedException e) {
// it will reach here.
System.out.println(e);
//this is strange!
//I expected IOException , but AlreadyClosedException I got.
//And AlreadyClosedException is a RuntimeException.
}
Спасибо.