Search in sources :

Example 1 with BpelProcess

use of org.apache.ode.bpel.engine.BpelProcess in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method recoverActivity.

/**
 * Retry failed activity of an instance of a process
 *
 * @param iid    Instance ID
 * @param aid    Activity ID
 * @param action Action to perform
 */
public void recoverActivity(final long iid, final long aid, final Action_type1 action) throws InstanceManagementException {
    try {
        dbexec(new BpelDatabase.Callable<QName>() {

            public QName run(BpelDAOConnection conn) throws Exception {
                ProcessInstanceDAO instance = conn.getInstance(iid);
                if (instance == null) {
                    return null;
                }
                for (ActivityRecoveryDAO recovery : instance.getActivityRecoveries()) {
                    if (recovery.getActivityId() == aid) {
                        BpelProcess process = ((BpelEngineImpl) bpelServer.getODEBPELServer().getEngine())._activeProcesses.get(instance.getProcess().getProcessId());
                        if (process != null) {
                            if (action == Action_type1.cancel) {
                                process.recoverActivity(instance, recovery.getChannel(), aid, Action_type1.cancel.getValue(), null);
                                log.info("Activity retrying is canceled for activity: " + aid + " of instance: " + iid);
                            } else if (action == Action_type1.retry) {
                                process.recoverActivity(instance, recovery.getChannel(), aid, Action_type1.retry.getValue(), null);
                                log.info("Activity is retried for activity: " + aid + " of instance: " + iid);
                            } else {
                                log.warn("Invalid retry action: " + action + " for activity: " + aid + " of instance: " + iid);
                            // TODO process fault action
                            }
                            break;
                        }
                    }
                }
                return instance.getProcess().getProcessId();
            }
        });
    } catch (Exception e) {
        String errMsg = "Exception occurred while recovering the activity: " + aid + " of ths instance: " + iid + " action: " + action.getValue();
        log.error(errMsg, e);
        throw new InstanceManagementException(errMsg, e);
    }
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) BpelEngineImpl(org.apache.ode.bpel.engine.BpelEngineImpl) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) QName(javax.xml.namespace.QName) BpelProcess(org.apache.ode.bpel.engine.BpelProcess) ActivityRecoveryDAO(org.apache.ode.bpel.dao.ActivityRecoveryDAO) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) ProcessNotFoundException(org.apache.ode.bpel.pmapi.ProcessNotFoundException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessingException(org.apache.ode.bpel.pmapi.ProcessingException)

Aggregations

QName (javax.xml.namespace.QName)1 ActivityRecoveryDAO (org.apache.ode.bpel.dao.ActivityRecoveryDAO)1 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)1 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)1 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)1 BpelEngineImpl (org.apache.ode.bpel.engine.BpelEngineImpl)1 BpelProcess (org.apache.ode.bpel.engine.BpelProcess)1 ProcessNotFoundException (org.apache.ode.bpel.pmapi.ProcessNotFoundException)1 ProcessingException (org.apache.ode.bpel.pmapi.ProcessingException)1 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)1