protected Object getErrorMessagePayload(UMOMessage message) { try { return message.getPayloadAsString(); } catch (Exception e) { logException(e); logger.info("Failed to read message payload as string, using raw payload"); return message.getPayload(); } }
private void setRemoteSync(UMOMessage message, UMOEndpoint endpoint) { if (endpoint.isRemoteSync()) { if (getTransaction() == null) { message.setBooleanProperty(MuleProperties.MULE_REMOTE_SYNC_PROPERTY, true); } else { throw new IllegalStateException( new Message(Messages.CANNOT_USE_TX_AND_REMOTE_SYNC).getMessage()); } } }
/** * 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(); } }
/** * Logs a fatal error message to the logging system. This should be used mostly if an error occurs * in the exception listener itself. This implementation logs the the message itself to the logs * if it is not null * * @param message The UMOMessage currently being processed * @param t the fatal exception to log */ protected void logFatal(UMOMessage message, Throwable t) { logger.fatal( "Failed to dispatch message to error queue after it failed to process. This may cause message loss." + (message == null ? "" : "Logging Message here: \n" + message.toString()), t); }