protected void nullifyExceptionPayloadIfRequired(MuleEvent event) { if (this.handleException) { event.getMessage().setExceptionPayload(null); } }
@Override protected void nullifyExceptionPayloadIfRequired(MuleEvent event) { event.getMessage().setExceptionPayload(null); }
protected MuleMessage getResponseFromMethod(HttpMethod httpMethod, ExceptionPayload ep) throws IOException, MuleException { MuleMessage message = createMuleMessage(httpMethod); if (logger.isDebugEnabled()) { logger.debug("Http response is: " + message.getOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY)); } message.setExceptionPayload(ep); return message; }
public void onMessage(MuleResponseMessage response) { //TODO should this really be read/write response.setStatusCode(String.valueOf(status)); if(status >= 400) { response.getMessage().setExceptionPayload(new DefaultExceptionPayload(new Exception("Mock Http Error"))); } } }
@Override public MuleEvent process(MuleEvent event) throws MuleException { MuleEvent result = event; if (!messageProcessors.isEmpty()) { result = configuredMessageProcessors.process(event); } if (result != null && !VoidMuleEvent.getInstance().equals(result)) { result.getMessage().setExceptionPayload(null); } return result; }
public MuleEvent process(MuleEvent event) throws MuleException { final MuleEvent result = RequestContext.setEvent(event); try { final MuleEvent nextResult = super.processNext(event); final ExceptionPayload nextResultMessageExceptionPayload = getExceptionPayload(nextResult); if (nextResultMessageExceptionPayload != null) { result.getMessage().setExceptionPayload(nextResultMessageExceptionPayload); } } catch (final MuleException me) { logger.error(me); result.getMessage().setExceptionPayload(new DefaultExceptionPayload(me)); } return result; } }
result.setExceptionPayload(new DefaultExceptionPayload(e)); try
private void manageException(Exception readingException) throws Exception { try { logger.warn("Failed to read message: " + readingException); MuleMessage msg = new DefaultMuleMessage(NullPayload.getInstance(), getEndpoint().getMuleContext()); ExceptionPayload exceptionPayload = new DefaultExceptionPayload(readingException); msg.setExceptionPayload(exceptionPayload); List msgList = new ArrayList(1); msgList.add(msg); handleResults(msgList); } catch (Exception writingException) { logger.warn("Failed to write exception back to client: " + writingException); throw writingException; } } }
@Override public MuleEvent handleException(Exception exception, MuleEvent event) { event.getMessage().setExceptionPayload(new DefaultExceptionPayload(exception)); for (MessagingExceptionHandlerAcceptor exceptionListener : exceptionListeners) { if (exceptionListener.accept(event)) { event.getMessage().setExceptionPayload(null); return exceptionListener.handleException(exception, event); } } throw new MuleRuntimeException(CoreMessages.createStaticMessage("Default exception strategy must accept any event.")); }
/** * There is no unsafe version of this because it shouldn't be performance critical * * @param exceptionPayload */ public static void setExceptionPayload(ExceptionPayload exceptionPayload) { MuleEvent newEvent = newEvent(getEvent(), SAFE); newEvent.getMessage().setExceptionPayload(exceptionPayload); internalSetEvent(newEvent); }
protected MuleEvent route(MuleEvent event, Exception t) { if (!getMessageProcessors().isEmpty()) { try { event.getMessage().setExceptionPayload(new DefaultExceptionPayload(t)); MuleEvent result = configuredMessageProcessors.process(event); return result; } catch (Exception e) { logFatal(event, e); } } return event; }
@Override protected MuleEvent processCatch(MuleEvent event, MessagingException exception) throws MessagingException { try { logger.error("Exception during exception strategy execution"); doLogException(exception); TransactionCoordination.getInstance().rollbackCurrentTransaction(); } catch (Exception ex) { //Do nothing } event.getMessage().setExceptionPayload(new DefaultExceptionPayload(exception)); return event; }
response.getMessage().setExceptionPayload(new DefaultExceptionPayload(exception));
@Override public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { ExceptionPayload ep = message.getExceptionPayload(); Throwable e = ep.getException(); Throwable re = ep.getRootException(); String cid = message.getCorrelationId(); log.warn("CorrId: {}, Error: {}, {}", new Object[] {cid, e, re}); String errorText = e.getMessage(); if (re != null) { errorText += ", " + re.getMessage(); } LastUnsuccessfulSynchErrorType error = new LastUnsuccessfulSynchErrorType(); error.setCausingAgent(CausingAgentEnum.VIRTUALIZATION_PLATFORM); error.setCode(Integer.toString(ep.getCode())); error.setText(errorText); String logicalAddress = message.getInvocationProperty("logical-address"); message.setExceptionPayload(null); message.setPayload(new Object[] {logicalAddress, error}); return message; } }
reply.setExceptionPayload(new DefaultExceptionPayload(e)); return new MuleResponseMessage(reply);
private void abandonRetries(final MuleEvent event, final MuleEvent mutableEvent, final Exception lastException) { if (getUntilSuccessfulConfiguration().getDlqMP() == null) { logger.info("Retry attempts exhausted and no DLQ defined"); //mutableEvent should be a local copy of event messagingExceptionHandler.handleException(buildRetryPolicyExhaustedException(lastException), mutableEvent); return; } //we need another local copy in case mutableEvent is modified in the DLQ MuleEvent eventCopy = threadSafeCopy(event); logger.info("Retry attempts exhausted, routing message to DLQ: " + getUntilSuccessfulConfiguration().getDlqMP()); try { mutableEvent.getMessage().setExceptionPayload(new DefaultExceptionPayload(buildRetryPolicyExhaustedException(lastException))); getUntilSuccessfulConfiguration().getDlqMP().process(mutableEvent); } catch (MessagingException e) { messagingExceptionHandler.handleException(e, eventCopy); } catch (Exception e) { messagingExceptionHandler.handleException(new MessagingException(event, e), eventCopy); } }
@Override protected MuleEvent processRequest(MuleEvent request) throws MuleException { if (!handleException && request.getReplyToHandler() instanceof NonBlockingReplyToHandler) { request = new DefaultMuleEvent(request, request.getFlowConstruct(), null, null, true); } muleContext.getNotificationManager().fireNotification(new ExceptionStrategyNotification(request, ExceptionStrategyNotification.PROCESS_START)); fireNotification(exception); logException(exception, request); processStatistics(request); request.getMessage().setExceptionPayload(new DefaultExceptionPayload(exception)); markExceptionAsHandledIfRequired(exception); return beforeRouting(exception, request); }
@Override public void processReplyTo(MuleEvent responseEvent, MuleMessage returnMessage, Object replyTo) throws MuleException { try { // CXF execution chain was suspended, so we need to resume it. // The MuleInvoker component will be recalled, by using the CxfConstants.NON_BLOCKING_RESPONSE flag we force using the received response event instead of re-invoke the flow exchange.put(CxfConstants.MULE_EVENT, responseEvent); exchange.put(CxfConstants.NON_BLOCKING_RESPONSE, true); exchange.getInMessage().getInterceptorChain().resume(); // Process the response responseEvent = (MuleEvent) exchange.get(CxfConstants.MULE_EVENT); responseEvent = processResponse(originalEvent, exchange, responseEvent); // Continue the non blocking execution originalReplyToHandler.processReplyTo(responseEvent, responseEvent.getMessage(), replyTo); } catch (Exception e) { ExceptionPayload exceptionPayload = new DefaultExceptionPayload(e); responseEvent.getMessage().setExceptionPayload(exceptionPayload); returnMessage.setOutboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 500); responseEvent.setMessage(returnMessage); processExceptionReplyTo(new MessagingException(responseEvent, e, CxfInboundMessageProcessor.this), replyTo); } }
public MuleEvent handleException(Exception ex, MuleEvent event) { try { muleContext.getNotificationManager().fireNotification(new ExceptionStrategyNotification(event, ExceptionStrategyNotification.PROCESS_START)); //keep legacy notifications fireNotification(ex); // Work with the root exception, not anything that wraps it //Throwable t = ExceptionHelper.getRootException(ex); logException(ex, event); doHandleException(ex, event); ExceptionPayload exceptionPayload = new DefaultExceptionPayload(ex); if (RequestContext.getEvent() != null) { RequestContext.setExceptionPayload(exceptionPayload); } event.getMessage().setPayload(NullPayload.getInstance()); event.getMessage().setExceptionPayload(exceptionPayload); return event; } finally { muleContext.getNotificationManager().fireNotification(new ExceptionStrategyNotification(event, ExceptionStrategyNotification.PROCESS_END)); } }
event.getMessage().setExceptionPayload(exceptionPayload); muleResMsg.setOutboundProperty(HTTP_STATUS_PROPERTY, SC_INTERNAL_SERVER_ERROR);