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();
      }
    }
  }