use of org.apache.qpid.proton.engine.Handler in project azure-service-bus-java by Azure.
the class MessagingFactory method closeConnection.
// One of the parameters must be null
private void closeConnection(ErrorCondition error, Exception cause) {
// Important to copy the reference of the connection as a call to getConnection might create a new connection while we are still in this method
Connection currentConnection = this.connection;
if (currentConnection != null) {
Link[] links = this.registeredLinks.toArray(new Link[0]);
this.registeredLinks.clear();
TRACE_LOGGER.debug("Closing all links on the connection. Number of links '{}'", links.length);
for (Link link : links) {
link.close();
}
TRACE_LOGGER.debug("Closed all links on the connection. Number of links '{}'", links.length);
if (currentConnection.getLocalState() != EndpointState.CLOSED) {
TRACE_LOGGER.info("Closing connection to host");
currentConnection.close();
}
for (Link link : links) {
Handler handler = BaseHandler.getHandler(link);
if (handler != null && handler instanceof BaseLinkHandler) {
BaseLinkHandler linkHandler = (BaseLinkHandler) handler;
if (error != null) {
linkHandler.processOnClose(link, error);
} else {
linkHandler.processOnClose(link, cause);
}
}
}
}
}
Aggregations