protected MessagingException filterFailureException(MuleEvent event, Exception ex) { return new MessagingException(event, ex, this); }
private void handleException(MuleEvent event, Throwable e) throws MuleException { throw new MessagingException(CoreMessages.failedToInvoke(this.operationName), event, e); }
@Override protected MessagingException filterFailureException(MuleEvent event, Exception ex) { MessagingException messagingException = new MessagingException(event, ex, this); String docName = LocationExecutionContextProvider.getDocName(filter); messagingException.getInfo().put("Filter", docName != null ? String.format("%s (%s)", filter.toString(), docName) : filter.toString()); return messagingException; }
private void consumePayload(MuleEvent event, MuleEvent result) throws MessagingException { final Object payload = result.getMessage().getPayload(); if (payload instanceof InputStream) { try { IOUtils.toByteArray((InputStream) payload); } catch (IOException e) { throw new MessagingException(event, e, this); } } } }
private MuleException handledException(OperationContext operationContext, Exception e) { Throwable root = ExceptionUtils.getRootCause(e); if (root == null) { root = e; } return new MessagingException(createStaticMessage(root.getMessage()), ((OperationContextAdapter) operationContext).getEvent(), root, this); }
/** * Asserts that the {@link MuleMessage} in the {@link MuleEvent} doesn't carry a consumable payload. This method * is useful for routers which need to clone the message before dispatching the message to multiple routes. * * @param event The {@link MuleEvent}. * @param event The {@link MuleMessage} whose payload is to be verified. * @throws MessagingException If the payload of the message is consumable. */ protected static void assertNonConsumableMessage(MuleEvent event, MuleMessage message) throws MessagingException { if (isConsumable(message.getPayload().getClass())) { throw new MessagingException(CoreMessages.cannotCopyStreamPayload(message.getPayload().getClass().getName()), event); } } }
/** * Validates that the payload is not consumable so it can be copied. * * If validation fails then throws a MessagingException * * @param event * @param message * @throws MessagingException */ public static void validateMessageIsNotConsumable(MuleEvent event, MuleMessage message) throws MessagingException { if (isConsumable(message.getPayload().getClass())) { throw new MessagingException( CoreMessages.cannotCopyStreamPayload(message.getPayload().getClass().getName()), event); } }
@Override public void processReplyTo(final MuleEvent event, MuleMessage returnMessage, Object replyTo) throws MuleException { try { resume(event); } catch (Throwable e) { if (e instanceof MessagingException) { processExceptionReplyTo((MessagingException) e, replyTo); } else { processExceptionReplyTo(new MessagingException(event, e), replyTo); } } }
protected boolean isProcessAsync(MuleEvent event) throws MessagingException { if (!canProcessAsync(event)) { throw new MessagingException( CoreMessages.createStaticMessage(SYNCHRONOUS_NONBLOCKING_EVENT_ERROR_MESSAGE), event, this); } return doThreading && canProcessAsync(event); }
@Override public void run() { resetAccessControl(event); // Set RequestContext ThreadLocal in new thread for backwards compatibility unsafeSetEvent(event); event.getReplyToHandler().processExceptionReplyTo(new MessagingException(event, exception), null); }
private String getState(MuleEvent event) throws MuleException { String state = getPropertiesDelegate(event).get("state"); try { return StringUtils.isEmpty(state) ? StringUtils.EMPTY : URLDecoder.decode(state, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new MessagingException( MessageFactory.createStaticMessage("State query param had invalid encoding: " + state), event, this); } }
@Override public void processReplyTo(MuleEvent event, MuleMessage returnMessage, Object replyTo) throws MuleException { try { Holder<MuleEvent> holder = (Holder<MuleEvent>) m.getExchange().get("holder"); holder.value = event; sendResultBackToCxf(m, event); } catch (IOException e) { processExceptionReplyTo(new MessagingException(event, e), replyTo); } }
public MuleEvent process(MuleEvent event) throws MuleException { try { event.getMessage().setInvocationProperty(OAuthProperties.VERIFIER, extractAuthorizationCode(event)); } catch (Exception e) { throw new MessagingException(MessageFactory.createStaticMessage("Could not extract OAuth verifier"), event, e, this); } return event; }
protected void processNextAsync(MuleEvent event) throws MuleException { try { workManagerSource.getWorkManager().scheduleWork(new AsyncMessageProcessorWorker(event), WorkManager.INDEFINITE, null, new AsyncWorkListener(next)); fireAsyncScheduledNotification(event); } catch (Exception e) { throw new MessagingException(errorSchedulingMessageProcessorForAsyncInvocation(next), event, e, this); } }
public void forceGroupExpiry(String groupId) throws MessagingException { try { if (correlatorStore.retrieve(groupId, getEventGroupsPartitionKey()) != null) { handleGroupExpiry(getEventGroup(groupId)); } else { addProcessedGroup(groupId); } } catch (ObjectStoreException e) { // TODO improve this throw new MessagingException(null, e); } }
public MuleEvent process(MuleEvent event) throws MessagingException { try { return endpoint.process(new DefaultMuleEvent(event.getMessage(), endpoint.getExchangePattern(), flow, event.getSession())); } catch (MessagingException e) { throw e; } catch (MuleException e) { throw new MessagingException(e.getI18nMessage(), event, e, endpoint); } }
private MuleException wrapException(MuleEvent event, Throwable ex, boolean alwaysReturnMessagingException) { if (ex instanceof MessagingException) { return (MessagingException) ex; } if (ex instanceof Fault) { // Because of CXF API, MuleExceptions can be wrapped in a Fault, in that case we should return the mule exception Fault fault = (Fault) ex; if(fault.getCause() instanceof MuleException) { MuleException muleException = (MuleException) fault.getCause(); return alwaysReturnMessagingException ? new MessagingException(event, muleException, this) : muleException; } return new DispatchException(MessageFactory.createStaticMessage(fault.getMessage()), event, this, fault); } return new DispatchException(MessageFactory.createStaticMessage(ExceptionHelper.getRootException(ex).getMessage()), event, this, ex); }
private MuleEvent buildWsdlOrXSDResult(final MuleEvent event) throws MuleException { try { String wsdlContents = getWsdlContents(event); wsdlContents = modifyServiceAddress(wsdlContents, event); event.getMessage().setPayload(wsdlContents); // the processing is stopped so that the result is not passed through // the outbound router but will be passed back as a result event.setStopFurtherProcessing(true); return event; } catch (final Exception e) { throw new MessagingException( MessageFactory.createStaticMessage("Impossible to retrieve WSDL for proxied service"), event, e, this); } }
@Override public void run() { try { resetAccessControl(result); MuleEvent responseEvent = createResponseEvent(result, event); // Set RequestContext ThreadLocal in new thread for backwards compatibility unsafeSetEvent(responseEvent); event.getReplyToHandler().processReplyTo(responseEvent, null, null); } catch (MessagingException messagingException) { event.getReplyToHandler().processExceptionReplyTo(messagingException, null); } catch (MuleException exception) { event.getReplyToHandler().processExceptionReplyTo(new MessagingException(event, exception), null); } }
@Override protected MuleEvent doRoute(MuleEvent event) throws MessagingException { try { final Serializable eventStoreKey = storeEvent(event); scheduleForProcessing(eventStoreKey, true); if (getUntilSuccessfulConfiguration().getAckExpression() == null) { return VoidMuleEvent.getInstance(); } return processResponseThroughAckResponseExpression(event); } catch (final Exception e) { throw new MessagingException( MessageFactory.createStaticMessage("Failed to schedule the event for processing"), event, e, getUntilSuccessfulConfiguration().getRouter()); } }