Beispiel #1
0
  public void invokeNewInstance(MyRoleMessageExchangeImpl mex, RoutingInfo routing) {
    Operation operation = getMyRoleOperation(mex.getOperationName());

    if (__log.isDebugEnabled()) {
      __log.debug(
          "INPUTMSG: "
              + routing.correlator.getCorrelatorId()
              + ": routing failed, CREATING NEW INSTANCE");
    }
    ProcessDAO processDAO = _process.getProcessDAO();

    if (_process._pconf.getState() == ProcessState.RETIRED) {
      throw new InvalidProcessException(
          "Process is retired.", InvalidProcessException.RETIRED_CAUSE_CODE);
    }

    if (!_process.processInterceptors(mex, InterceptorInvoker.__onNewInstanceInvoked)) {
      __log.debug("Not creating a new instance for mex " + mex + "; interceptor prevented!");
      throw new InvalidProcessException(
          "Cannot instantiate process '" + _process.getPID() + "' any more.",
          InvalidProcessException.TOO_MANY_INSTANCES_CAUSE_CODE);
    }

    ProcessInstanceDAO newInstance = processDAO.createInstance(routing.correlator);

    BpelRuntimeContextImpl instance =
        _process.createRuntimeContext(newInstance, new PROCESS(_process.getOProcess()), mex);

    // send process instance event
    NewProcessInstanceEvent evt =
        new NewProcessInstanceEvent(
            new QName(_process.getOProcess().targetNamespace, _process.getOProcess().getName()),
            _process.getProcessDAO().getProcessId(),
            newInstance.getInstanceId());
    evt.setPortType(mex.getPortType().getQName());
    evt.setOperation(operation.getName());
    evt.setMexId(mex.getMessageExchangeId());
    _process._debugger.onEvent(evt);
    _process.saveEvent(evt, newInstance);
    mex.setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.CREATE_INSTANCE);
    mex.getDAO().setInstance(newInstance);
    if (mex.getDAO().getCreateTime() == null)
      mex.getDAO().setCreateTime(instance.getCurrentEventDateTime());

    _process._engine.acquireInstanceLock(newInstance.getInstanceId());
    instance.execute();
  }
Beispiel #2
0
 private void setMexRole(MyRoleMessageExchangeImpl mex) {
   Operation operation = getMyRoleOperation(mex.getOperationName());
   mex.getDAO().setPartnerLinkModelId(_plinkDef.getId());
   mex.setPortOp(_plinkDef.myRolePortType, operation);
   mex.setPattern(
       operation.getOutput() == null
           ? MessageExchange.MessageExchangePattern.REQUEST_ONLY
           : MessageExchange.MessageExchangePattern.REQUEST_RESPONSE);
 }
Beispiel #3
0
  public void invokeInstance(MyRoleMessageExchangeImpl mex, RoutingInfo routing) {
    Operation operation = getMyRoleOperation(mex.getOperationName());
    if (__log.isDebugEnabled()) {
      __log.debug(
          "INPUTMSG: "
              + routing.correlator.getCorrelatorId()
              + ": ROUTING to existing instance "
              + routing.messageRoute.getTargetInstance().getInstanceId());
    }

    ProcessInstanceDAO instanceDao = routing.messageRoute.getTargetInstance();
    BpelProcess process2 =
        _process._engine._activeProcesses.get(instanceDao.getProcess().getProcessId());

    // Reload process instance for DAO.
    BpelRuntimeContextImpl instance = process2.createRuntimeContext(instanceDao, null, null);
    instance.inputMsgMatch(routing.messageRoute.getGroupId(), routing.messageRoute.getIndex(), mex);

    // Kill the route so some new message does not get routed to
    // same process instance.
    routing.correlator.removeRoutes(routing.messageRoute.getGroupId(), instanceDao);

    // send process instance event
    CorrelationMatchEvent evt =
        new CorrelationMatchEvent(
            new QName(process2.getOProcess().targetNamespace, process2.getOProcess().getName()),
            process2.getProcessDAO().getProcessId(),
            instanceDao.getInstanceId(),
            routing.matchedKeySet);
    evt.setPortType(mex.getPortType().getQName());
    evt.setOperation(operation.getName());
    evt.setMexId(mex.getMessageExchangeId());

    process2._debugger.onEvent(evt);
    // store event
    process2.saveEvent(evt, instanceDao);

    mex.setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.MATCHED);
    mex.getDAO().setInstance(routing.messageRoute.getTargetInstance());
    if (mex.getDAO().getCreateTime() == null)
      mex.getDAO().setCreateTime(instance.getCurrentEventDateTime());

    instance.execute();
  }
Beispiel #4
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);
      }
    }
  }