@Override
  public void run() {
    logger.trace("AsyncRequestWorker started");
    AsyncRequestInfo requestInfo = null;
    try {
      while (isRunning()) {
        try {
          requestInfo = requests.take();
          if (requestInfo.restRequest != null) {
            processRequest(requestInfo);
            logger.trace("Request {} was processed successfully", requestInfo.restRequest.getUri());
          } else {
            break;
          }
        } catch (Throwable e) {
          if (!(e instanceof Exception)) {
            metrics.requestProcessingThrowableError.inc();
            if (requestInfo != null) {
              logger.error("Throwable only while processing the requests" + requestInfo.restRequest, e);
            } else {
              logger.error("Throwable only while processing the requests", e);
            }
            e = new Exception(e);
          }
          metrics.requestProcessingError.inc();
          if (requestInfo != null) {
            onProcessingFailure(requestInfo.restRequest, requestInfo.restResponseChannel, (Exception) e);
          } else {
            logger.error("Unexpected exception while processing requests", e);
          }
        }
      }
    } finally {
      running.set(false);
      discardRequests();
      logger.info("AsyncRequestWorker stopped");
      shutdownLatch.countDown();
    }
  }
Handles queued requests continuously until shutdown.
ambry-rest/src/main/java/com/github/ambry/rest/AsyncRequestResponseHandler.java