@Override public void stop() throws Exception { try { synchronized (reconnectMutex) { ServiceStopper ss = new ServiceStopper(); if (!started) { return; } started = false; disposed = true; connected = false; for (Iterator<FanoutTransportHandler> iter = transports.iterator(); iter.hasNext(); ) { FanoutTransportHandler th = iter.next(); if (th.transport != null) { ss.stop(th.transport); } } LOG.debug("Stopped: " + this); ss.throwFirstException(); } } finally { reconnectTask.shutdown(); reconnectTaskFactory.shutdownNow(); } }
protected void doStop() throws Exception { this.acceptorUsed.onStopped(this); /* * What's a duplex bridge? try { synchronized (this) { if (duplexBridge != * null) { duplexBridge.stop(); } } } catch (Exception ignore) { * LOG.trace("Exception caught stopping. This exception is ignored.", * ignore); } */ try { getTransportConnection().close(); } catch (Exception e) { // log } if (taskRunner != null) { taskRunner.shutdown(1); taskRunner = null; } active = false; // Run the MessageDispatch callbacks so that message references get // cleaned up. synchronized (dispatchQueue) { for (Iterator<Command> iter = dispatchQueue.iterator(); iter.hasNext(); ) { Command command = iter.next(); if (command.isMessageDispatch()) { MessageDispatch md = (MessageDispatch) command; TransmitCallback sub = md.getTransmitCallback(); protocolManager.postProcessDispatch(md); if (sub != null) { sub.onFailure(); } } } dispatchQueue.clear(); } // // Remove all logical connection associated with this connection // from the broker. if (!protocolManager.isStopped()) { context.getStopping().set(true); try { processRemoveConnection(state.getInfo().getConnectionId(), 0L); } catch (Throwable ignore) { ignore.printStackTrace(); } } }