Esempio n. 1
0
  /**
   * Is this [fault] message a timeout?
   *
   * @param synCtx the current fault message
   * @return true if this is defined as a timeout
   */
  protected boolean isTimeout(MessageContext synCtx) {

    Object error = synCtx.getProperty(SynapseConstants.ERROR_CODE);
    Integer errorCode = 0;
    if (error != null) {
      try {
        errorCode = Integer.parseInt(error.toString());
      } catch (NumberFormatException e) {
        errorCode = 0;
      }
    }
    if (errorCode != null) {
      if (definition.getTimeoutErrorCodes().isEmpty()) {
        // if timeout codes are not defined, assume only HTTP timeout and connection close
        boolean isTimeout = SynapseConstants.NHTTP_CONNECTION_TIMEOUT == errorCode;
        boolean isClosed = SynapseConstants.NHTTP_CONNECTION_CLOSED == errorCode;

        if (isTimeout || isClosed) {

          if (log.isDebugEnabled()) {
            log.debug(
                "Encountered a default HTTP connection "
                    + (isClosed ? "close" : "timeout")
                    + " error : "
                    + errorCode);
          }
          return true;
        }
      } else {
        if (definition.getTimeoutErrorCodes().contains(errorCode)) {
          if (log.isDebugEnabled()) {
            log.debug(
                "Encountered a mark for suspension error : "
                    + errorCode
                    + " defined "
                    + "error codes are : "
                    + definition.getTimeoutErrorCodes());
          }
          return true;
        }
      }
    }

    if (log.isDebugEnabled()) {
      log.debug(
          "Encountered a non-timeout error sending to "
              + this.toString()
              + ", error code : "
              + errorCode);
    }
    return false;
  }