示例#1
0
 // This method is used when the service invoked synchronously. It should really
 // be used independantly of if the service is invoked synchronously when we are
 // using an out-only outbound message exchange pattern
 protected MuleMessage sendToOutboundRouter(MuleEvent event, MuleMessage result)
     throws MessagingException {
   if (event.isStopFurtherProcessing()) {
     logger.debug(
         "MuleEvent stop further processing has been set, no outbound routing will be performed.");
   }
   if (result != null
       && !event.isStopFurtherProcessing()
       && !(result.getPayload() instanceof NullPayload)) {
     if (getOutboundRouter().hasEndpoints()) {
       // Here we need to use a copy of the message instance because there
       // is an inbound response so that transformers executed as part of
       // the outbound phase do not affect the inbound response. MULE-3307
       if (stats.isEnabled()) {
         stats.incSentEventSync();
       }
       MuleMessage outboundReturnMessage =
           getOutboundRouter()
               .route(new DefaultMuleMessage(result.getPayload(), result), event.getSession());
       if (outboundReturnMessage != null) {
         result = outboundReturnMessage;
       }
     } else {
       logger.debug(
           "Outbound router on service '"
               + getName()
               + "' doesn't have any endpoints configured.");
     }
   }
   return result;
 }
示例#2
0
  public void dispatchEvent(MuleEvent event) throws MuleException {
    if (stopping.get() || stopped.get()) {
      throw new ServiceException(CoreMessages.componentIsStopped(name), event.getMessage(), this);
    }

    // Dispatching event to an inbound endpoint
    // in the DefaultMuleSession#dispatchEvent
    ImmutableEndpoint endpoint = event.getEndpoint();

    if (endpoint instanceof OutboundEndpoint) {
      try {
        ((OutboundEndpoint) endpoint).dispatch(event);
      } catch (Exception e) {
        throw new DispatchException(event.getMessage(), event.getEndpoint(), e);
      }

      return;
    }

    if (logger.isDebugEnabled()) {
      logger.debug(
          "Service: "
              + name
              + " has received asynchronous event on: "
              + event.getEndpoint().getEndpointURI());
    }

    // Dispatching event to the service
    if (stats.isEnabled()) {
      stats.incReceivedEventASync();
    }
    doDispatch(event);
  }
示例#3
0
 // This method is used when the service invoked asynchronously. It should really
 // be used independantly of if the service is invoked asynchronously when we are
 // using an out-in or out-optional-in outbound message exchange pattern
 protected void dispatchToOutboundRouter(MuleEvent event, MuleMessage result)
     throws MessagingException {
   if (event.isStopFurtherProcessing()) {
     logger.debug(
         "MuleEvent stop further processing has been set, no outbound routing will be performed.");
   }
   if (result != null && !event.isStopFurtherProcessing()) {
     if (getOutboundRouter().hasEndpoints()) {
       // Here we can use the same message instance because there is no inbound response.
       if (stats.isEnabled()) {
         stats.incSentEventASync();
       }
       getOutboundRouter().route(result, event.getSession());
     }
   }
 }
示例#4
0
  public MuleMessage sendEvent(MuleEvent event) throws MuleException {
    if (stopping.get() || stopped.get()) {
      throw new ServiceException(CoreMessages.componentIsStopped(name), event.getMessage(), this);
    }

    try {
      waitIfPaused(event);
    } catch (InterruptedException e) {
      throw new ServiceException(event.getMessage(), this, e);
    }

    if (stats.isEnabled()) {
      stats.incReceivedEventSync();
    }
    if (logger.isDebugEnabled()) {
      logger.debug(
          "Service: "
              + name
              + " has received synchronous event on: "
              + event.getEndpoint().getEndpointURI());
    }
    event = OptimizedRequestContext.unsafeSetEvent(event);
    return doSend(event);
  }