Пример #1
0
  /**
   * @param handler
   * @param retryCount
   */
  private void executeExceptionRequestHandler(final IRequestHandler handler, final int retryCount) {
    scheduleRequestHandlerAfterCurrent(null);

    try {
      requestHandlerExecutor.execute(handler);
    } catch (Exception e) {
      if (retryCount > 0) {
        IRequestHandler next = handleException(e);
        if (next != null) {
          executeExceptionRequestHandler(next, retryCount - 1);
          return;
        }
      }
      log.error("Error during processing error message", e);
    }
  }
Пример #2
0
  /**
   * Executes a request handler and fires pre/post listener methods
   *
   * @param handler
   */
  private void execute(IRequestHandler handler) {
    Args.notNull(handler, "handler");

    try {
      listeners.onRequestHandlerResolved(this, handler);
      requestHandlerExecutor.execute(handler);
      listeners.onRequestHandlerExecuted(this, handler);
    } catch (RuntimeException e) {
      IRequestHandler replacement = requestHandlerExecutor.resolveHandler(e);
      if (replacement != null) {
        execute(replacement);
      } else {
        throw e;
      }
    }
  }