use of org.apache.activemq.artemis.Closeable in project activemq-artemis by apache.
the class ServerSessionImpl method doClose.
protected void doClose(final boolean failed) throws Exception {
if (callback != null) {
callback.close(failed);
}
synchronized (this) {
if (!closed) {
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.beforeCloseSession(this, failed));
}
}
this.setStarted(false);
if (closed)
return;
if (tx != null && tx.getXid() == null) {
try {
rollback(failed, false);
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.unableToRollbackOnClose(e);
}
}
}
// putting closing of consumers outside the sync block
// https://issues.jboss.org/browse/HORNETQ-1141
Set<ServerConsumer> consumersClone = new HashSet<>(consumers.values());
for (ServerConsumer consumer : consumersClone) {
try {
consumer.close(failed);
} catch (Throwable e) {
ActiveMQServerLogger.LOGGER.unableToCloseConsumer(e);
try {
consumer.removeItself();
} catch (Throwable e2) {
ActiveMQServerLogger.LOGGER.unableToRemoveConsumer(e2);
}
}
}
consumers.clear();
producers.clear();
if (closeables != null) {
for (Closeable closeable : closeables) {
closeable.close(failed);
}
}
synchronized (this) {
server.removeSession(name);
remotingConnection.removeFailureListener(this);
if (callback != null) {
callback.closed();
}
closed = true;
if (server.hasBrokerPlugins()) {
server.callBrokerPlugins(plugin -> plugin.afterCloseSession(this, failed));
}
}
}
Aggregations