/** * @deprecated use {@link #getEvent().getMessage()} instead */ @Deprecated public MuleMessage getMuleMessage() { if ((getEvent() != null)) { return event.getMessage(); } return muleMessage; }
private void sendFailureResponseIfNeccessary(MessagingException messagingException, FlowProcessingPhaseTemplate flowProcessingPhaseTemplate) throws MuleException { if (flowProcessingPhaseTemplate instanceof RequestResponseFlowProcessingPhaseTemplate) { fireNotification(messagingException.getEvent(), MESSAGE_ERROR_RESPONSE); ((RequestResponseFlowProcessingPhaseTemplate) flowProcessingPhaseTemplate).sendFailureResponseToClient(messagingException); } }
protected void handleException(Throwable exception, String message, HttpServletResponse response) { logger.error("message: " + exception.getMessage(), exception); int code = Integer.valueOf(ExceptionHelper.getErrorMapping("http", exception.getClass(),muleContext)); response.setStatus(code); try { String errorMessage = message + ": " + exception.getMessage(); if (exception instanceof MessagingException && ((MessagingException) exception).getEvent() != null) { MessagingException me = (MessagingException) exception; writeErrorResponseFromMessage(response, me.getEvent().getMessage(), code, errorMessage); } else { response.sendError(code, errorMessage); } } catch (Exception e) { logger.error("Failed to sendError on response: " + e.getMessage(), e); } }
private int retrieveStatusCode(MessagingException messagingException) { final Object statusCodeValue = messagingException.getEvent().getMessage().getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY); if (statusCodeValue != null) { if (statusCodeValue instanceof Number) { return ((Number)statusCodeValue).intValue(); } return Integer.valueOf((String) statusCodeValue); } else { return Integer.valueOf(ExceptionHelper.getErrorMapping("http", messagingException.getClass(), muleContext)); } }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { exception.setProcessedEvent(createReturnEventForParentFlowConstruct(exception.getEvent(), event)); replyToHandler.processExceptionReplyTo(exception, null); } }, getExceptionListener());
@Override public MuleEvent execute(ExecutionCallback<MuleEvent> processingCallback, ExecutionContext executionContext) throws Exception { try { return this.next.execute(processingCallback, executionContext); } catch (MessagingException e) { if (e.handled()) { return e.getEvent(); } throw e; } } }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { try { MuleEvent handledEvent = processCatch(exception.getEvent(), exception); originalReplyToHandler.processReplyTo(handledEvent, null, null); } catch (Exception e) { originalReplyToHandler.processExceptionReplyTo(exception, replyTo); } finally { processFinally(exception.getEvent(), exception); } } };
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { if (fireNotification) { MuleEvent result = exception.getEvent(); fireNotification(notificationManager, event.getFlowConstruct(), result != null ? result : event, messageProcessor, null, MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE); } originalReplyToHandler.processExceptionReplyTo(exception, replyTo); } });
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { MuleEvent result; if (messagingExceptionHandler != null) { result = messagingExceptionHandler.handleException(exception, exception.getEvent()); } else { result = exception.getEvent().getFlowConstruct().getExceptionListener().handleException(exception, exception.getEvent()); } exception.setProcessedEvent(result); if (!exception.handled()) { delegate.processExceptionReplyTo(exception, replyTo); } else { try { delegate.processReplyTo(exception.getEvent(), exception.getEvent().getMessage(), replyTo); } catch (MuleException e) { delegate.processExceptionReplyTo(new MessagingException(exception.getEvent(), e), replyTo); } } } }
@Override public MuleEvent execute(ExecutionCallback<MuleEvent> callback, ExecutionContext executionContext) throws Exception { try { return next.execute(callback, executionContext); } catch (MessagingException e) { MuleEvent result; if (messagingExceptionHandler != null) { result = messagingExceptionHandler.handleException(e, e.getEvent()); } else { result = e.getEvent().getFlowConstruct().getExceptionListener().handleException(e,e.getEvent()); } e.setProcessedEvent(result); throw e; } catch (Exception e) { throw e; } } }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { try { fireNotification(exception.getEvent(), MESSAGE_ERROR_RESPONSE); template.sendFailureResponseToClient(exception, createSendFailureResponseCompletationCallback(phaseResultNotifier)); } catch (MuleException e) { phaseResultNotifier.phaseFailure(e); } } }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { try { originalReplyToHandler.processExceptionReplyTo(exception, replyTo); } finally { try { last(exception.getEvent(), time, startTime, true); } catch (MuleException muleException) { throw new MuleRuntimeException(muleException); } } } }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { if (replyToHandler != null) { replyToHandler.processExceptionReplyTo(exception, replyTo); } else { event.getFlowConstruct().getExceptionListener().handleException(exception, exception.getEvent()); } } }
@Override public void sendFailureResponseToClient(MessagingException messagingException) throws MuleException { MuleEvent response = messagingException.getEvent(); MessagingException e = getExceptionForCreatingFailureResponse(messagingException, response); String temp = ExceptionHelper.getErrorMapping(getInboundEndpoint().getConnector().getProtocol(), messagingException.getClass(), getMuleContext()); int httpStatus = Integer.valueOf(temp); try { sendFailureResponseToClient(e, httpStatus); } catch (IOException ioException) { throw new DefaultMuleException(ioException); } failureResponseSentToClient = true; }
@Override public void sendFailureResponseToClient(MessagingException messagingException, ResponseCompletionCallback responseCompletationCallback) throws MuleException { //For now let's use the HTTP transport exception mapping since makes sense and the gateway depends on it. String exceptionStatusCode = ExceptionHelper.getTransportErrorMapping(HTTP.getScheme(), messagingException.getClass(), sourceMuleEvent.getMuleContext()); Integer statusCodeFromException = exceptionStatusCode != null ? Integer.valueOf(exceptionStatusCode) : INTERNAL_SERVER_ERROR_STATUS_CODE; final org.mule.module.http.internal.domain.response.HttpResponseBuilder failureResponseBuilder = new org.mule.module.http.internal.domain.response.HttpResponseBuilder() .setStatusCode(statusCodeFromException) .setReasonPhrase(messagingException.getMessage()); addThrottlingHeaders(failureResponseBuilder); MuleEvent event = messagingException.getEvent(); event.getMessage().setPayload(messagingException.getMessage()); final HttpResponse response = errorResponseBuilder.build(failureResponseBuilder, event); responseReadyCallback.responseReady(response, getResponseFailureCallback(responseCompletationCallback, messagingException.getEvent())); }
@Override public void sendFailureResponseToClient(MessagingException messagingException) throws MuleException { try { int statusCode = retrieveStatusCode(messagingException); servletResponseWriter.writeErrorResponse(servletResponse, messagingException.getEvent().getMessage(), statusCode, messagingException.getMessage(), httpThrottlingHeadersMapBuilder.build()); } catch (Exception e) { throw new DefaultMuleException(e); } failureResponseSentToClient = true; }
private void sendFailureResponseToClient(MessagingException exception, int httpStatus) throws IOException, MuleException { MuleEvent response = exception.getEvent(); response.getMessage().setPayload(exception.getMessage()); httpStatus = response.getMessage().getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY) != null ? Integer.valueOf(response.getMessage().getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY).toString()) : httpStatus; response.getMessage().setOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, httpStatus); HttpResponse httpResponse = transformResponse(response.getMessage()); httpServerConnection.writeResponse(httpResponse, getThrottlingHeaders()); }
MuleEvent failedEvent = ((MessagingException) e).getEvent(); failedEvent.getFlowConstruct().getExceptionListener().handleException((MessagingException) e, failedEvent);
@Override public MuleEvent process(final MuleEvent event) throws MuleException { final MuleEvent newEvent = createMuleEventForCurrentFlow(event, event.getReplyToDestination(), event.getReplyToHandler()); try { ExecutionTemplate<MuleEvent> executionTemplate = ErrorHandlingExecutionTemplate.createErrorHandlingExecutionTemplate(muleContext, getExceptionListener()); MuleEvent result = executionTemplate.execute(new ExecutionCallback<MuleEvent>() { @Override public MuleEvent process() throws Exception { return pipeline.process(newEvent); } }); return createReturnEventForParentFlowConstruct(result, event); } catch (MessagingException e) { e.setProcessedEvent(createReturnEventForParentFlowConstruct(e.getEvent(), event)); throw e; } catch (Exception e) { resetRequestContextEvent(event); throw new DefaultMuleException(CoreMessages.createStaticMessage("Flow execution exception"),e); } }
fireNotification(e.getEvent(), MESSAGE_ERROR_RESPONSE); template.sendFailureResponseToClient(e, createSendFailureResponseCompletationCallback(phaseResultNotifier));