NonBlockingCompletionHandler(MuleEvent event) { this.event = event; this.replyToHandler = event.getReplyToHandler(); }
public NonBlockingProcessorExecutor(MuleEvent event, List<MessageProcessor> processors, MessageProcessorExecutionTemplate executionTemplate, boolean copyOnVoidEvent) { super(event, processors, executionTemplate, copyOnVoidEvent); this.replyToHandler = event.getReplyToHandler(); this.messageExchangePattern = event.getExchangePattern(); }
@Override public void handleException(Map<String, Object> ctx, Throwable ex) { event.getReplyToHandler().processExceptionReplyTo(wrapException(responseHolder.value, ex), null); } }, bop, getArgs(event), ctx, exchange);
protected boolean isNonBlocking(MuleEvent event) { return event.isAllowNonBlocking() && event.getReplyToHandler() != null; }
protected boolean canProcessAsync(MuleEvent event) throws MessagingException { return !(event.isSynchronous() || event.isTransacted() || event.getReplyToHandler() instanceof NonBlockingReplyToHandler); }
/** * Copy constructor to be used when synchronicity and {@link org.mule.MessageExchangePattern} both need changing. */ public DefaultMuleEvent(MuleMessage message, MuleEvent rewriteEvent, boolean synchronus, boolean shareFlowVars, MessageExchangePattern messageExchangePattern) { this(message, rewriteEvent, rewriteEvent.getFlowConstruct(), rewriteEvent.getSession(), synchronus, shareFlowVars, messageExchangePattern, rewriteEvent.getReplyToHandler()); }
protected boolean isNonBlocking(MuleEvent event) { return event.getFlowConstruct() instanceof Flow && event.isAllowNonBlocking() && event.getReplyToHandler() != null; }
@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 public void run() { resetAccessControl(event); // Set RequestContext ThreadLocal in new thread for backwards compatibility unsafeSetEvent(event); event.getReplyToHandler().processExceptionReplyTo(new MessagingException(event, exception), null); }
@Override protected boolean shouldProcessEvent(MuleEvent event) { // Only process ReplyToHandler is running one-way and standard ReplyToHandler is being used. return !event.getExchangePattern().hasResponse() && (event.getFlowConstruct() instanceof Flow) && event .getReplyToHandler() instanceof DefaultReplyToHandler; }
public DefaultMuleEvent(MuleMessage message, MuleEvent rewriteEvent, boolean synchronus, boolean shareFlowVars) { this(message, rewriteEvent, rewriteEvent.getFlowConstruct(), rewriteEvent.getSession(), synchronus, shareFlowVars, rewriteEvent.getExchangePattern(), rewriteEvent.getReplyToHandler()); }
@Override public void handleResponse(Map<String, Object> ctx, Object[] res) { try { event.getReplyToHandler().processReplyTo(buildResponseMessage(event, responseHolder.value, res), null, null); } catch (MuleException ex) { handleException(ctx, ex); } }
protected DefaultMuleEvent(MuleMessage message, MuleEvent rewriteEvent, FlowConstruct flowConstruct, MuleSession session, boolean synchronous) { this(message, rewriteEvent, flowConstruct, session, synchronous, rewriteEvent.getReplyToHandler(), rewriteEvent.getReplyToDestination(), true, rewriteEvent.getExchangePattern()); }
private boolean isNonBlocking(MuleEvent event) { return event.getFlowConstruct() instanceof Flow && event.isAllowNonBlocking() && event.getReplyToHandler() != null && isSupportsNonBlocking() && !endpoint.getTransactionConfig().isTransacted(); }
private MuleEvent createReturnEventForParentFlowConstruct(MuleEvent result, MuleEvent original) { if (result != null && !(result instanceof VoidMuleEvent)) { // Create new event with original FlowConstruct, ReplyToHandler and synchronous result = new DefaultMuleEvent(result, original.getFlowConstruct(), original.getReplyToHandler(), original.getReplyToDestination(), original.isSynchronous()); } resetRequestContextEvent(result); return result; }
@Override protected MuleEvent processResponse(MuleEvent response, MuleEvent request) throws MuleException { processOutboundRouterStatistics(flowConstruct); response = afterRouting(exception, response); if (response != null && !VoidMuleEvent.getInstance().equals(response)) { // Only process reply-to if non-blocking is not enabled. Checking the exchange pattern is not sufficient // because JMS inbound endpoints for example use a REQUEST_RESPONSE exchange pattern and async processing. if (!(request.isAllowNonBlocking() && request.getReplyToHandler() instanceof NonBlockingReplyToHandler)) { processReplyTo(response, exception); } closeStream(response.getMessage()); nullifyExceptionPayloadIfRequired(response); } return response; }
@Override protected MuleEvent processNonBlocking(final MuleEvent event) throws MuleException { final long startTime = System.currentTimeMillis(); final ProcessingTime time = event.getProcessingTime(); MuleEvent responseEvent = event; final ReplyToHandler originalReplyToHandler = event.getReplyToHandler(); responseEvent = new DefaultMuleEvent(event, new ResponseReplyToHandler(originalReplyToHandler, time, startTime)); // Update RequestContext ThreadLocal for backwards compatibility OptimizedRequestContext.unsafeSetEvent(responseEvent); try { responseEvent = processNext(processRequest(responseEvent)); if (!(responseEvent instanceof NonBlockingVoidMuleEvent)) { responseEvent = processResponse(responseEvent, event); } } catch (Exception exception) { last(responseEvent, time, startTime, true); throw exception; } return responseEvent; }
@Override public MuleEvent process(MuleEvent event) throws MuleException { MuleEvent resultEvent; if (shouldProcessEvent(event)) { Object replyTo = event.getReplyToDestination(); ReplyToHandler replyToHandler = event.getReplyToHandler(); resultEvent = processNext(event); // Allow components to stop processing of the ReplyTo property (e.g. CXF) final String replyToStop = resultEvent.getMessage().getInvocationProperty( MuleProperties.MULE_REPLY_TO_STOP_PROPERTY); if (resultEvent != null && !VoidMuleEvent.getInstance().equals(resultEvent) && !BooleanUtils.toBoolean(replyToStop)) { // reply-to processing should not resurrect a dead event processReplyTo(event, resultEvent, replyToHandler, replyTo); } } else { resultEvent = processNext(event); } return resultEvent; }
protected MuleEvent processNonBlocking(final MuleEvent event) throws MuleException { MessagingException exception = null; MuleEvent eventToProcess = new DefaultMuleEvent(event, createReplyToHandler(event)); // Update RequestContext ThreadLocal for backwards compatibility eventToProcess = OptimizedRequestContext.unsafeSetEvent(eventToProcess); try { MuleEvent result = processNext(processRequest(eventToProcess)); if (!(result instanceof NonBlockingVoidMuleEvent)) { return processResponse(recreateEventWithOriginalReplyToHandler(result, event.getReplyToHandler()), event); } else { return result; } } catch (MessagingException e) { exception = e; return processCatch(event, e); } finally { processFinally(event, exception); } }
@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); }