private MuleEvent createMessageCollectionWithSingleMessage(MuleEvent event, MuleContext muleContext) { MuleMessageCollection coll = new DefaultMessageCollection(muleContext); coll.addMessage(event.getMessage()); event.setMessage(coll); return OptimizedRequestContext.unsafeSetEvent(event); }
@Override public MuleEvent process(MuleEvent event) throws MuleException { OperationContext operationContext = createOperationContext(event); Object result = executeOperation(operationContext); if (result instanceof MuleEvent) { return (MuleEvent) result; } else if (result instanceof MuleMessage) { event.setMessage((MuleMessage) result); } else { event.getMessage().setPayload(result); } return event; }
@Override protected void doDispatch(final MuleEvent event) throws Exception { EndpointURI endpointUri = endpoint.getEndpointURI(); if (endpointUri == null) { throw new DispatchException(CoreMessages.objectIsNull("Endpoint"), event, getEndpoint()); } MuleEvent eventToDispatch = DefaultMuleEvent.copy(event); eventToDispatch.clearFlowVariables(); eventToDispatch.setMessage(eventToDispatch.getMessage().createInboundMessage()); QueueSession session = getQueueSession(); Queue queue = session.getQueue(endpointUri.getAddress()); if (!queue.offer(eventToDispatch.getMessage(), connector.getQueueTimeout())) { // queue is full throw new DispatchException(VMMessages.queueIsFull(queue.getName(), queue.size()), eventToDispatch, getEndpoint()); } if (logger.isDebugEnabled()) { logger.debug("dispatched MuleEvent on endpointUri: " + endpointUri); } }
@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); } }
message.setMessageRootId(requestMessageRootId); muleEvent.setMessage(message); setResponsePayload(payload, muleEvent);
@Override public MuleEvent process(MuleEvent event) throws MuleException { MockEndpointManager manager = (MockEndpointManager) getEndpointManager(event); String address = realAddressAsExpression(); ExpressionManager expressionManager = event.getMuleContext().getExpressionManager(); if (expressionManager.isValidExpression(address)) { String realAddress = (String) expressionManager.evaluate(address, event); OutboundBehavior behavior = manager.getBehaviorFor(realAddress); if (behavior == null) { return realEndpoint.process(event); } if (behavior.getException() != null) { throw behavior.getException(); } MunitUtils.verifyAssertions(event, behavior.getAssertions()); if (behavior.getMuleMessageTransformer() != null) { event.setMessage(behavior.getMuleMessageTransformer().transform(event.getMessage())); } } return event; }
public Object process(Object obj, Object[] args, MethodProxy proxy) throws Throwable { MuleEvent originalEvent = (MuleEvent) args[0]; EventCopyManager eventCopyManager = new EventCopyManager(originalEvent); MuleEvent copyEvent = eventCopyManager.getCopyEvent(); MockedMessageProcessorManager manager = getMockedMessageProcessorManager(copyEvent.getMuleContext()); MunitMessageProcessorCall messageProcessorCall = buildCall(copyEvent); runSpyAssertion(manager.getBetterMatchingBeforeSpyAssertion(messageProcessorCall), copyEvent); registerCall(manager, messageProcessorCall); MessageProcessorBehavior behavior = manager.getBetterMatchingBehavior(messageProcessorCall); if (behavior != null) { if (behavior.getExceptionToThrow() != null) { runSpyAssertion(manager.getBetterMatchingAfterSpyAssertion(messageProcessorCall), copyEvent); throw behavior.getExceptionToThrow(); } if (behavior.getMuleMessageTransformer() != null) { copyEvent.setMessage(behavior.getMuleMessageTransformer().transform(copyEvent.getMessage())); } runSpyAssertion(manager.getBetterMatchingAfterSpyAssertion(messageProcessorCall), copyEvent); return handleInterceptingMessageProcessors(obj, copyEvent); } eventCopyManager.rollBackRequestContext(); Object o = invokeSuper(obj, args, proxy); runSpyAssertion(manager.getBetterMatchingAfterSpyAssertion(messageProcessorCall), (MuleEvent) o); return o; }