Package org.apache.ode.bpel.dao

Examples of org.apache.ode.bpel.dao.CorrelatorDAO


        if (_instantiatingMessageExchange != null && _dao.getState() == ProcessState.STATE_READY) {
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + ": CHECKING for NEW INSTANCE match");
            }
            for (int i = 0; i < correlators.size(); ++i) {
                CorrelatorDAO ci = correlators.get(i);
                if (ci.equals(_dao.getInstantiatingCorrelator())) {
                    inputMsgMatch(pickResponseChannelStr, i, _instantiatingMessageExchange);
                    if (BpelProcess.__log.isDebugEnabled()) {
                        BpelProcess.__log.debug("SELECT: " + pickResponseChannel
                                + ": FOUND match for NEW instance mexRef=" + _instantiatingMessageExchange);
                    }
                    return;
                }
            }
        }

        // if (BpelProcess.__log.isDebugEnabled()) {
        // BpelProcess.__log.debug("SELECT: " + pickResponseChannel
        // + ": NEW instance match NOT FOUND; CHECKING MESSAGES. ");
        // }
        //
        //
        // for (int i = 0; i < selectors.length; ++i) {
        // CorrelatorDAO correlator = correlators.get(i);
        // Selector selector = selectors[i];
        // MessageExchangeDAO mexdao = correlator
        // .dequeueMessage(selector.correlationKey);
        // if (mexdao != null) {
        // // Found message matching one of our selectors.
        // if (BpelProcess.__log.isDebugEnabled()) {
        // BpelProcess.__log.debug("SELECT: " + pickResponseChannel
        // + ": FOUND match to MESSAGE " + mexdao + " on CKEY "
        // + selector.correlationKey);
        // }
        //
        // MyRoleMessageExchangeImpl mex = new MyRoleMessageExchangeImpl(
        // _bpelProcess._engine, mexdao);
        //
        // inputMsgMatch(pickResponseChannel.export(), i, mex);
        // return;
        // }
        // }
        //
        // if (BpelProcess.__log.isDebugEnabled()) {
        // BpelProcess.__log.debug("SELECT: " + pickResponseChannel
        // + ": MESSAGE match NOT FOUND.");
        // }

        if (timeout != null) {
            registerTimer(pickResponseChannel, timeout);
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + "REGISTERED TIMEOUT for " + timeout);
            }
        }

        for (int i = 0; i < selectors.length; ++i) {
            CorrelatorDAO correlator = correlators.get(i);
            Selector selector = selectors[i];

            correlator.addRoute(pickResponseChannel.export(), _dao, i, selector.correlationKey);
            scheduleCorrelatorMatcher(correlator.getCorrelatorId(), selector.correlationKey);

            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + ": ADDED ROUTE " + correlator.getCorrelatorId() + ": "
                        + selector.correlationKey + " --> " + _dao.getInstanceId());
            }
        }

View Full Code Here


     */
    public void matcherEvent(String correlatorId, CorrelationKey ckey) {
        if (BpelProcess.__log.isDebugEnabled()) {
            __log.debug("MatcherEvent handling: correlatorId=" + correlatorId + ", ckey=" + ckey);
        }
        CorrelatorDAO correlator = _dao.getProcess().getCorrelator(correlatorId);

        // Find the route first, this is a SELECT FOR UPDATE on the "selector" row,
        // So we want to acquire the lock before we do anthing else.
        MessageRouteDAO mroute = correlator.findRoute(ckey);
        if (mroute == null) {
            // Ok, this means that a message arrived before we did, so nothing to do.
            __log.debug("MatcherEvent handling: nothing to do, route no longer in DB");
            return;
        }

        // Now see if there is a message that matches this selector.
        MessageExchangeDAO mexdao = correlator.dequeueMessage(ckey);
        if (mexdao != null) {
            __log.debug("MatcherEvent handling: found matching message in DB (i.e. message arrived before <receive>)");

            // We have a match, so we can get rid of the routing entries.
            correlator.removeRoutes(mroute.getGroupId(),_dao);

            // Found message matching one of our selectors.
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + mroute.getGroupId() + ": matched to MESSAGE " + mexdao
                        + " on CKEY " + ckey);
View Full Code Here

    assertNotNull(p.getType());
    assertNotNull(p.getProcessId());
    assertEquals( p.getVersion() , 1 );
   
    // Assert the CorrelatorDAO
    CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
    assertNotNull( corr );
    assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);
   
    // Assert the MessageRouteDAO
    MessageRouteDAO route = corr.findRoute(key1);
    assertNotNull( route );
    assertEquals(route.getGroupId(),"testRoute" );
    assertEquals(route.getIndex() , 1 );
    assertNotNull(route.getTargetInstance() );

    // Assert the ProcessInstanceDAO
    for ( ProcessInstanceDAO inst : insts ) {
      Long id = inst.getInstanceId();
      assertNotNull( id );
     
      ProcessInstanceDAO inst2 = conn.getInstance(id);
      assertSame(inst2,inst);
     
      ProcessInstanceDAO inst3 = p.getInstance(id);
      assertSame( inst3 , inst );
     
      Long mon = inst.genMonotonic();
      assertEquals(inst.getActivityFailureCount() , 2);
      assertNotNull(inst.getActivityFailureDateTime() );
      assertNotNull(inst.getCreateTime() );
      assertTrue(inst.getExecutionState().length > 0 );
      assertNotNull(inst.getLastActiveTime() );
      assertSame(inst.getProcess() , p );
      assertEquals(inst.getPreviousState() , 0);
      assertEquals(inst.getState() , 1);
     
      // Assert the Root ScopeDAO
      ScopeDAO rs = inst.getRootScope();
      assertNotNull( rs );
      assertNotNull(rs.getChildScopes());
      ScopeDAO child1 = null;
      for ( ScopeDAO childItr : rs.getChildScopes()){
        child1 = childItr;
        break;
      }
      assertNotNull(child1);
      assertNotNull(rs.getCorrelationSets());
      assertEquals(rs.getCorrelationSets().size() , 0 );
      assertEquals(rs.getModelId(),1);
      assertEquals(rs.getName(),"Root");
      assertTrue(rs.getParentScope() == null);
      assertNotNull(rs.getPartnerLinks());
      assertEquals(rs.getPartnerLinks().size() ,0);
      assertSame(rs.getProcessInstance(),inst);
      assertNotNull(rs.getScopeInstanceId());
      assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
      assertNotNull(rs.getVariables());
      assertEquals(rs.getVariables().size(),0);
     
   
      // Assert the ActivityRecoveryDAO
      assertNotNull(inst.getActivityRecoveries());
      ActivityRecoveryDAO rec1 = null;
      for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
       if (recItr.getActivityId() == 3) {
         rec1 = recItr;break;
       }
      }
      assertNotNull(rec1);
      String tmpAct = rec1.getActions();
//      assertEquals(rec1.getActionsList(),actions);
      assertEquals(rec1.getActivityId(),3);
      assertEquals(rec1.getChannel(),"testChannel1");
      assertNotNull(rec1.getDateTime());
//      assertNotNull(rec1.getDetails());
      assertEquals(rec1.getReason(),"testReason1");
      assertEquals(rec1.getRetries(),2);
     
      // Assert the CorrelationSetDAO
      //assertNotNull(inst.getCorrelationSets());
      //CorrelationSetDAO cs1 = null;
      //for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
      //  cs1 = csItr;
      //  break;
      //}
      //assertNotNull(cs1);
     
      // Assert the FaultDAO
      FaultDAO fault = inst.getFault();
      assertNotNull(fault);
      assertEquals(fault.getActivityId(),1);
      assertNotNull(fault.getData());
      assertEquals(fault.getExplanation(),"testExplanation");
      assertEquals(fault.getLineNo(),1);
      assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));
     
      // Assert MessageExchangeDAO
      CorrelatorDAO ic = inst.getInstantiatingCorrelator();
      assertNotNull(ic);
      assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
      // The message is dequeued but not persisted
      MessageExchangeDAO me = ic.dequeueMessage(key1);
      assertNotNull(me);
      assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
      assertEquals(me.getPropagateTransactionFlag(),false);
      assertEquals(me.getChannel(),"testChannel");
      assertEquals(me.getCorrelationId(),"testCorrelationId");
View Full Code Here

    }

    void createStuff(BPELDAOConnectionFactoryImpl factory) throws Exception {
        BpelDAOConnection conn = factory.getConnection();

        CorrelatorDAO corr = createProcess(conn,"testPID1","testType");
    ProcessInstanceDAO pi1 = createProcessInstance(_process, corr);
    }
View Full Code Here

    return m;
  }
 
  private CorrelatorDAO createProcess(BpelDAOConnection conn, String pid, String type) {
    _process = conn.createProcess(new QName(TEST_NS,pid), new QName(TEST_NS,type),"GUID1",1);
    CorrelatorDAO corr = _process.addCorrelator(CORRELATOR_ID1);
    _process.addCorrelator(CORRELATOR_ID2);
    return corr;
  }
View Full Code Here

    assertNotNull(p.getType());
    assertNotNull(p.getProcessId());
    assertEquals( p.getVersion() , 1 );
   
    // Assert the CorrelatorDAO
    CorrelatorDAO corr = p.getCorrelator(CORRELATOR_ID1);
    assertNotNull( corr );
    assertEquals(corr.getCorrelatorId(),CORRELATOR_ID1);
   
    // Assert the MessageRouteDAO
    MessageRouteDAO route = corr.findRoute(key1);
    assertNotNull( route );
    assertEquals(route.getGroupId(),"testRoute" );
    assertEquals(route.getIndex() , 1 );
    assertNotNull(route.getTargetInstance() );

    // Assert the ProcessInstanceDAO
    for ( ProcessInstanceDAO inst : insts ) {
      Long id = inst.getInstanceId();
      assertNotNull( id );
     
      ProcessInstanceDAO inst2 = conn.getInstance(id);
      assertSame(inst2,inst);
     
      ProcessInstanceDAO inst3 = p.getInstance(id);
      assertSame( inst3 , inst );
     
      Long mon = inst.genMonotonic();
      assertEquals(inst.getActivityFailureCount() , 2);
      assertNotNull(inst.getActivityFailureDateTime() );
      assertNotNull(inst.getCreateTime() );
      assertTrue(inst.getExecutionState().length > 0 );
      assertNotNull(inst.getLastActiveTime() );
      assertSame(inst.getProcess() , p );
      assertEquals(inst.getPreviousState() , 0);
      assertEquals(inst.getState() , 1);
     
      // Assert the Root ScopeDAO
      ScopeDAO rs = inst.getRootScope();
      assertNotNull( rs );
      assertNotNull(rs.getChildScopes());
      ScopeDAO child1 = null;
      for ( ScopeDAO childItr : rs.getChildScopes()){
        child1 = childItr;
        break;
      }
      assertNotNull(child1);
      assertNotNull(rs.getCorrelationSets());
      assertEquals(rs.getCorrelationSets().size() , 0 );
      assertEquals(rs.getModelId(),1);
      assertEquals(rs.getName(),"Root");
      assertTrue(rs.getParentScope() == null);
      assertNotNull(rs.getPartnerLinks());
      assertEquals(rs.getPartnerLinks().size() ,0);
      assertSame(rs.getProcessInstance(),inst);
      assertNotNull(rs.getScopeInstanceId());
      assertEquals(rs.getState(),ScopeStateEnum.ACTIVE);
      assertNotNull(rs.getVariables());
      assertEquals(rs.getVariables().size(),0);
     
   
      // Assert the ActivityRecoveryDAO
      assertNotNull(inst.getActivityRecoveries());
      ActivityRecoveryDAO rec1 = null;
      for (ActivityRecoveryDAO recItr : inst.getActivityRecoveries()) {
        rec1 = recItr;
        break;
      }
      assertNotNull(rec1);
      String tmpAct = rec1.getActions();
//      assertEquals(rec1.getActionsList(),actions);
      assertEquals(rec1.getActivityId(),3);
      assertEquals(rec1.getChannel(),"testChannel1");
      assertNotNull(rec1.getDateTime());
//      assertNotNull(rec1.getDetails());
      assertEquals(rec1.getReason(),"testReason1");
      assertEquals(rec1.getRetries(),2);
     
      // Assert the CorrelationSetDAO
      //assertNotNull(inst.getCorrelationSets());
      //CorrelationSetDAO cs1 = null;
      //for ( CorrelationSetDAO csItr : inst.getCorrelationSets() ) {
      //  cs1 = csItr;
      //  break;
      //}
      //assertNotNull(cs1);
     
      // Assert the FaultDAO
      FaultDAO fault = inst.getFault();
      assertNotNull(fault);
      assertEquals(fault.getActivityId(),1);
      assertNotNull(fault.getData());
      assertEquals(fault.getExplanation(),"testExplanation");
      assertEquals(fault.getLineNo(),1);
      assertEquals(fault.getName(),new QName(TEST_NS,"testFault"));
     
      // Assert MessageExchangeDAO
      CorrelatorDAO ic = inst.getInstantiatingCorrelator();
      assertNotNull(ic);
      assertEquals(ic.getCorrelatorId(),CORRELATOR_ID1);
      // The message is dequeued but not persisted
      MessageExchangeDAO me = ic.dequeueMessage(key1);
      assertNotNull(me);
      assertEquals(me.getCallee(),new QName(TEST_NS,"testCallee"));
      assertEquals(me.getPropagateTransactionFlag(),false);
      assertEquals(me.getChannel(),"testChannel");
      assertEquals(me.getCorrelationId(),"testCorrelationId");
View Full Code Here

        // 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);
                }
View Full Code Here

            throw new FaultException(_bpelProcess.getOProcess().constants.qnConflictingReceive, selectors[conflict]
                    .toString());

        // Check for ambiguous receive
        for (int i = 0; i < selectors.length; ++i) {
            CorrelatorDAO correlator = correlators.get(i);
            Selector selector = selectors[i];

            if (!correlator.checkRoute(selector.correlationKeySet)) {
                throw new FaultException(_bpelProcess.getOProcess().constants.qnAmbiguousReceive(), selector.toString());
            }
        }

        //Registering
        _imaManager.register(pickResponseChannelStr, selectors);

        // First check if we match to a new instance.
        if (_instantiatingMessageExchange != null && _dao.getState() == ProcessState.STATE_READY) {
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + ": CHECKING for NEW INSTANCE match");
            }
            for (int i = 0; i < correlators.size(); ++i) {
                CorrelatorDAO ci = correlators.get(i);
                if (ci.equals(_dao.getInstantiatingCorrelator())) {
                    inputMsgMatch(pickResponseChannelStr, i, _instantiatingMessageExchange);
                    if (BpelProcess.__log.isDebugEnabled()) {
                        BpelProcess.__log.debug("SELECT: " + pickResponseChannel
                                + ": FOUND match for NEW instance mexRef=" + _instantiatingMessageExchange);
                    }
                    return;
                }
            }
        }

        if (timeout != null) {
            registerTimer(pickResponseChannel, timeout);
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + "REGISTERED TIMEOUT for " + timeout);
            }
        }

        for (int i = 0; i < selectors.length; ++i) {
            CorrelatorDAO correlator = correlators.get(i);
            Selector selector = selectors[i];

            correlator.addRoute(pickResponseChannel.export(), _dao, i, selector.correlationKeySet, selector.route);
            scheduleCorrelatorMatcher(correlator.getCorrelatorId(), selector.correlationKeySet);

            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + pickResponseChannel + ": ADDED ROUTE " + correlator.getCorrelatorId() + ": "
                        + selector.correlationKeySet + " --> " + _dao.getInstanceId());
            }
        }
    }
View Full Code Here

     */
    public void matcherEvent(String correlatorId, CorrelationKeySet ckeySet) {
        if (BpelProcess.__log.isDebugEnabled()) {
            __log.debug("MatcherEvent handling: correlatorId=" + correlatorId + ", ckeySet=" + ckeySet);
        }
        CorrelatorDAO correlator = _dao.getProcess().getCorrelator(correlatorId);

        // Find the route first, this is a SELECT FOR UPDATE on the "selector" row,
        // So we want to acquire the lock before we do anthing else.
        List<MessageRouteDAO> mroutes = correlator.findRoute(ckeySet);
        if (mroutes == null || mroutes.size() == 0) {
            // Ok, this means that a message arrived before we did, so nothing to do.
            __log.debug("MatcherEvent handling: nothing to do, route no longer in DB");
            return;
        }

        // Now see if there is a message that matches this selector.
        MessageExchangeDAO mexdao = correlator.dequeueMessage(ckeySet);
        if (mexdao != null) {
            __log.debug("MatcherEvent handling: found matching message in DB (i.e. message arrived before <receive>)");
            if( MessageExchangePattern.REQUEST_RESPONSE.toString().equals(mexdao.getPattern())) {
                __log.warn("A message arrived before a receive is ready for a request/response pattern. This may be processed to success. However, you should consider revising your process since a TCP port and a container thread will be held for a longer time and the process will not scale under heavy load.");
            }

            for (MessageRouteDAO mroute : mroutes) {
                // We have a match, so we can get rid of the routing entries.
                correlator.removeRoutes(mroute.getGroupId(), _dao);
            }

            // Selecting first route to proceed, other matching entries are ignored
            MessageRouteDAO mroute = mroutes.get(0);

View Full Code Here

            __log.trace("RegisterForExtensionNotification method, with notification channel " +
                                   notificationChannelId);
        }

        ProcessDAO processDao = _dao.getProcess();
        CorrelatorDAO notificationCorrelator = processDao.getCorrelator(correlatorId);
        CorrelationKey notificationCorrelationKey = new CorrelationKey("-1", correlationValues);
        CorrelationKeySet correlationKeySet = new CorrelationKeySet();
        correlationKeySet.add(notificationCorrelationKey);
        notificationCorrelator.addRoute(notificationChannelId, _dao, 0, correlationKeySet, "one");
        scheduleCorrelatorMatcher(notificationCorrelator.getCorrelatorId(), correlationKeySet);
    }
View Full Code Here

TOP

Related Classes of org.apache.ode.bpel.dao.CorrelatorDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.