use of org.apache.ode.bpel.engine.BpelEngineImpl 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);
}
}
Aggregations