Package org.apache.ode.bpel.dao

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


        }
        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);
            }

            MyRoleMessageExchangeImpl mex = new MyRoleMessageExchangeImpl(_bpelProcess._engine, mexdao);

            inputMsgMatch(mroute.getGroupId(), mroute.getIndex(), mex);
            execute();
        } else {
            __log.debug("MatcherEvent handling: nothing to do, no matching message in DB");

        }
View Full Code Here


        String correlatorId = BpelProcess.genCorrelatorId(_plinkDef, operation.getName());

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

        CorrelationKey[] keys;
        MessageRouteDAO messageRoute = null;

        // 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 {
            keys = 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;
        }

        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="
                    + ArrayUtils.makeCollection(HashSet.class, keys) + " mySessionId=" + mySessionId
                    + " partnerSessionId=" + partnerSessionId);
        }

        CorrelationKey matchedKey = null;

        // Try to find a route for one of our keys.
        for (CorrelationKey key : keys) {
            messageRoute = correlator.findRoute(key);
            if (messageRoute != null) {
                if (__log.isDebugEnabled()) {
                    __log.debug("INPUTMSG: " + correlatorId + ": ckey " + key + " route is to " + messageRoute);
                }
                matchedKey = key;
                break;
            }
        }

        // TODO - ODE-58

        // If no luck, and this operation qualifies for create-instance
        // treatment, then create a new process
        // instance.
        if (messageRoute == null && isCreateInstnace) {
            if (__log.isDebugEnabled()) {
                __log.debug("INPUTMSG: " + correlatorId + ": 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!");
                return;
            }

            ProcessInstanceDAO newInstance = processDAO.createInstance(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);

            instance.execute();
        } else if (messageRoute != null) {
            if (__log.isDebugEnabled()) {
                __log.debug("INPUTMSG: " + correlatorId + ": ROUTING to instance "
                        + messageRoute.getTargetInstance().getInstanceId());
            }

            ProcessInstanceDAO instanceDao = messageRoute.getTargetInstance();

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

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

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

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

            // EXPERIMENTAL -- LOCK
            // instanceDao.lock();

            mex.setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.MATCHED);
            mex.getDAO().setInstance(messageRoute.getTargetInstance());
            instance.execute();
        } else {
            if (__log.isDebugEnabled()) {
                __log.debug("INPUTMSG: " + correlatorId + ": SAVING to DB (no match) ");
            }
View Full Code Here

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

        }
        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);
            }

            MyRoleMessageExchangeImpl mex = new MyRoleMessageExchangeImpl(_bpelProcess._engine, mexdao);

            inputMsgMatch(mroute.getGroupId(), mroute.getIndex(), mex);
            execute();
        } else {
            __log.debug("MatcherEvent handling: nothing to do, no matching message in DB");

        }
View Full Code Here

        String correlatorId = BpelProcess.genCorrelatorId(_plinkDef, operation.getName());

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

        CorrelationKey[] keys;
        MessageRouteDAO messageRoute = null;

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

        String correlatorId = BpelProcess.genCorrelatorId(_plinkDef, operation.getName());

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

        CorrelationKey[] keys;
        MessageRouteDAO messageRoute = null;

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

        }
        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);
            }

            MyRoleMessageExchangeImpl mex = new MyRoleMessageExchangeImpl(_bpelProcess._engine, mexdao);

            inputMsgMatch(mroute.getGroupId(), mroute.getIndex(), mex);
            execute();
        } else {
            __log.debug("MatcherEvent handling: nothing to do, no matching message in DB");

        }
View Full Code Here

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

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

                // 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);

            // Found message matching one of our selectors.
            if (BpelProcess.__log.isDebugEnabled()) {
                BpelProcess.__log.debug("SELECT: " + mroute.getGroupId() + ": matched to MESSAGE " + mexdao
                        + " on CKEYSET " + ckeySet);
            }

            MyRoleMessageExchangeImpl mex = new MyRoleMessageExchangeImpl(_bpelProcess, _bpelProcess._engine, mexdao);

            inputMsgMatch(mroute.getGroupId(), mroute.getIndex(), mex);
            execute();

            // Do not release yet if the process is suspended, the mex will be used again
            if (_dao.getState() != ProcessState.STATE_SUSPENDED)
                mexdao.releasePremieMessages();
View Full Code Here

TOP

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

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.