boolean processInterceptor(
     MessageExchangeInterceptor i,
     MyRoleMessageExchangeImpl mex,
     InterceptorContext ictx,
     InterceptorInvoker invoker) {
   __log.debug(invoker + "--> interceptor " + i);
   try {
     invoker.invoke(i, mex, ictx);
   } catch (FaultMessageExchangeException fme) {
     __log.debug(
         "interceptor "
             + i
             + " caused invoke on "
             + this
             + " to be aborted with FAULT "
             + fme.getFaultName());
     mex.setFault(fme.getFaultName(), fme.getFaultData());
     return false;
   } catch (AbortMessageExchangeException ame) {
     __log.debug(
         "interceptor "
             + i
             + " cause invoke on "
             + this
             + " to be aborted with FAILURE: "
             + ame.getMessage());
     mex.setFailure(
         MessageExchange.FailureType.ABORTED,
         __msgs.msgInterceptorAborted(mex.getMessageExchangeId(), i.toString(), ame.getMessage()),
         null);
     return false;
   }
   return true;
 }
Esempio n. 2
0
  public void noRoutingMatch(MyRoleMessageExchangeImpl mex, List<RoutingInfo> routings) {
    if (!mex.isAsynchronous()) {
      mex.setFailure(
          MessageExchange.FailureType.NOMATCH,
          "No process instance matching correlation keys.",
          null);
    } else {
      // enqueue message with the last message route, as per the comments in caller (@see
      // BpelProcess.invokeProcess())
      RoutingInfo routing =
          (routings != null && routings.size() > 0) ? routings.get(routings.size() - 1) : null;
      if (routing != null) {
        if (__log.isDebugEnabled()) {
          __log.debug(
              "INPUTMSG: " + routing.correlator.getCorrelatorId() + ": SAVING to DB (no match) ");
        }

        // send event
        CorrelationNoMatchEvent evt =
            new CorrelationNoMatchEvent(
                mex.getPortType().getQName(),
                mex.getOperation().getName(),
                mex.getMessageExchangeId(),
                routing.wholeKeySet);

        evt.setProcessId(_process.getProcessDAO().getProcessId());
        evt.setProcessName(
            new QName(_process.getOProcess().targetNamespace, _process.getOProcess().getName()));
        _process._debugger.onEvent(evt);

        mex.setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.QUEUED);

        // No match, means we add message exchange to the queue.
        routing.correlator.enqueueMessage(mex.getDAO(), routing.wholeKeySet);
      }
    }
  }
Esempio n. 3
0
  public List<RoutingInfo> findRoute(MyRoleMessageExchangeImpl mex) {
    List<RoutingInfo> routingInfos = new ArrayList<RoutingInfo>();

    if (__log.isTraceEnabled()) {
      __log.trace(
          ObjectPrinter.stringifyMethodEnter(
              this + ":inputMsgRcvd", new Object[] {"messageExchange", mex}));
    }

    Operation operation = getMyRoleOperation(mex.getOperationName());
    if (operation == null) {
      __log.error(
          __msgs.msgUnknownOperation(mex.getOperationName(), _plinkDef.myRolePortType.getQName()));
      mex.setFailure(MessageExchange.FailureType.UNKNOWN_OPERATION, mex.getOperationName(), null);
      return null;
    }
    setMexRole(mex);

    // now, the tricks begin: when a message arrives we have to see if there
    // is anyone waiting for it. Get the correlator, a persisted communication-reduction
    // data structure supporting correlation correlationKey matching!
    String correlatorId = BpelProcess.genCorrelatorId(_plinkDef, operation.getName());

    CorrelatorDAO correlator = _process.getProcessDAO().getCorrelator(correlatorId);

    CorrelationKeySet keySet;

    // We need to compute the correlation keys (based on the operation
    // we can  infer which correlation keys to compute - this is merely a set
    // consisting of each correlationKey used in each correlation sets
    // that is ever referenced in an <receive>/<onMessage> on this
    // partnerlink/operation.
    try {
      keySet = computeCorrelationKeys(mex);
    } catch (InvalidMessageException ime) {
      // We'd like to do a graceful exit here, no sense in rolling back due to a
      // a message format problem.
      __log.debug("Unable to evaluate correlation keys, invalid message format. ", ime);
      mex.setFailure(MessageExchange.FailureType.FORMAT_ERROR, ime.getMessage(), null);
      return null;
    }

    String mySessionId = mex.getProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID);
    String partnerSessionId = mex.getProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID);
    if (__log.isDebugEnabled()) {
      __log.debug(
          "INPUTMSG: "
              + correlatorId
              + ": MSG RCVD keys="
              + keySet
              + " mySessionId="
              + mySessionId
              + " partnerSessionId="
              + partnerSessionId);
    }

    // Try to find a route for one of our keys.
    List<MessageRouteDAO> messageRoutes = correlator.findRoute(keySet);
    if (messageRoutes != null && messageRoutes.size() > 0) {
      for (MessageRouteDAO messageRoute : messageRoutes) {
        if (__log.isDebugEnabled()) {
          __log.debug(
              "INPUTMSG: "
                  + correlatorId
                  + ": ckeySet "
                  + messageRoute.getCorrelationKeySet()
                  + " route is to "
                  + messageRoute);
        }
        routingInfos.add(
            new RoutingInfo(messageRoute, messageRoute.getCorrelationKeySet(), correlator, keySet));
      }
    }

    if (routingInfos.size() == 0) {
      routingInfos.add(new RoutingInfo(null, null, correlator, keySet));
    }

    return routingInfos;
  }