ARTEMIS-2714 log details for 'Address already in use'

Currently when the broker hits the common 'Address already in use' issue
when starting the process terminates with a vague exception. The user is
left to guess which acceptor actually failed. If the broker has lots of
acceptors it is a tedious process to identify the problematic
configuration. This commit adds details to the exception message about
which acceptor failed and which host:port it was attempting to bind to.
This commit is contained in:
Justin Bertram 2020-04-15 13:48:57 -05:00 committed by Clebert Suconic
parent 9c537900ee
commit f0b4afa672
2 changed files with 9 additions and 1 deletions

View File

@ -661,7 +661,12 @@ public class NettyAcceptor extends AbstractAcceptor {
} else {
address = new InetSocketAddress(h, port);
}
Channel serverChannel = bootstrap.bind(address).syncUninterruptibly().channel();
Channel serverChannel = null;
try {
serverChannel = bootstrap.bind(address).syncUninterruptibly().channel();
} catch (Exception e) {
throw ActiveMQMessageBundle.BUNDLE.failedToBind(getName(), h + ":" + port, e);
}
serverChannelGroup.add(serverChannel);
}
}

View File

@ -485,4 +485,7 @@ public interface ActiveMQMessageBundle {
@Message(id = 229229, value = "Failed to parse JSON queue configuration: {0}", format = Message.Format.MESSAGE_FORMAT)
IllegalArgumentException failedToParseJson(String json);
@Message(id = 229230, value = "Failed to bind acceptor {0} to {1}", format = Message.Format.MESSAGE_FORMAT)
IllegalStateException failedToBind(String acceptor, String hostPort, @Cause Exception e);
}