Beispiel #1
0
  /**
   * Routes the current exception to an error endpoint such as a Dead Letter Queue (jms) This method
   * is only invoked if there is a UMOMassage available to dispatch. The message dispatched from
   * this method will be an <code>ExceptionMessage</code> which contains the exception thrown the
   * UMOMessage and any context information.
   *
   * @param message the UMOMessage being processed when the exception occurred
   * @param failedEndpoint optional; the endpoint being dispatched or recieved on when the error
   *     occurred. This is NOT the endpoint that the message will be disptched on and is only
   *     supplied to this method for logging purposes
   * @param t the exception thrown. This will be sent with the ExceptionMessage
   * @see ExceptionMessage
   */
  protected void routeException(UMOMessage message, UMOEndpoint failedEndpoint, Throwable t) {
    UMOEndpoint endpoint = getEndpoint(t);
    if (endpoint != null) {
      try {
        logger.error(
            "Message being processed is: " + (message == null ? "null" : message.toString()));
        UMOEventContext ctx = RequestContext.getEventContext();
        ExceptionMessage msg = null;
        if (failedEndpoint != null) {
          msg = new ExceptionMessage(getErrorMessagePayload(message), endpoint, t, ctx);
        } else {
          msg = new ExceptionMessage(getErrorMessagePayload(message), t, ctx);
        }

        ctx.sendEvent(new MuleMessage(msg, null), endpoint);
        logger.debug("routed Exception message via " + endpoint);

      } catch (UMOException e) {
        logFatal(message, e);
      }
    } else {
      markTransactionForRollback();
    }
  }