|
Re: How can I suspend or abort process using "Spring Bean Applicationa" [message #1219115 is a reply to message #1219033] |
Mon, 02 December 2013 06:09   |
Vikash Pandey Messages: 12 Registered: October 2011 |
Junior Member |
|
|
is this the same activity which is invoking the spring bean and trying to abort the process instance that contains the very same application activity?
Please share the code that you are using to achieve this.
If you are trying to abort the same process instance that contains the activity, it can't be done, here is the reason:
12:05:09 INFO [090-exec-1] WorkflowServiceImpl - Aborting process instance Process instance = 75 (Process Definition: Process Definition 1) (model oid = 11, version = 1, revision = 1).
12:05:09 INFO [090-exec-1] ProcessInstanceBean - State change for Process instance = 75 (Process Definition: Process Definition 1) (model oid = 11, version = 1, revision = 1): Active-->Aborting.
12:05:09 ERROR [090-exec-1] ActivityInstanceBean - Invalid state change from Application to Completed because the process instance is in process of aborting.
12:05:09 WARN [090-exec-1] ApplicationException - Rolling back activity thread.
org.eclipse.stardust.engine.api.runtime.IllegalStateChangeException: BPMRT03903 - Illegal state change: Application --> Completed for Activity instance 'abortInstance', oid: 155 (process instance = 75) (model oid = 11, version = 1, revision = 1) . Process instance state was Active.
Proces Instance gets into aborting state and the activity is still in application and has to move to Completed.
About suspending a process - if the process instance has a manual activity and its in suspended state the process instance is in Active state. We can only suspend and save manual activities to either in users worklist or roles worklist.
This is how i would do it:
public class CleanWrongOrders {
private static QueryService queryService;
private static WorkflowService workflowService;
private static UserService userService;
private static AdministrationService adminService;
private static DocumentManagementService documentService;
public static QueryService getQueryService() {
return queryService;
}
public static void setQueryService(QueryService queryService) {
CleanWrongOrders.queryService = queryService;
}
public static WorkflowService getWorkflowService() {
return workflowService;
}
public static void setWorkflowService(WorkflowService workflowService) {
CleanWrongOrders.workflowService = workflowService;
}
public static UserService getUserService() {
return userService;
}
public static void setUserService(UserService userService) {
CleanWrongOrders.userService = userService;
}
public static AdministrationService getAdminService() {
return adminService;
}
public static void setAdminService(AdministrationService adminService) {
CleanWrongOrders.adminService = adminService;
}
public static DocumentManagementService getDocumentService() {
return documentService;
}
public static void setDocumentService(DocumentManagementService documentService) {
CleanWrongOrders.documentService = documentService;
}
@SuppressWarnings("deprecation")
public static void cleanWrongOrders() {
//This method will find out all the PIs that has value as Target Price is 0 or -ve
//for a data name "WrongOrders" and abort those PIs.
try {
ActivityInstanceQuery query = ActivityInstanceQuery.findAlive("SecurityOrderProcess");
FilterOrTerm itemFilter = query.getFilter().addOrTerm();
itemFilter.or(DataFilter.isEqual("WrongOrders", "Target Price is 0 or -ve"));
ActivityInstances activityInstances = queryService.getAllActivityInstances(query);
System.out.println("Activity Instances: " + activityInstances);
for (ActivityInstance activityInstance : activityInstances) {
System.out.println("Process OID to abort: " + activityInstance.getProcessInstanceOID());
workflowService.abortProcessInstance(activityInstance.getProcessInstanceOID(), AbortScope.RootHierarchy);
}
} catch (Exception e) {
// Default thresholdMins to 10 minutes
e.printStackTrace();
} finally {
}
}
}
---------------
bean configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="cleanWrongOrders" class="com.sungard.energy.enovos.ipp.training.CleanWrongOrders">
<property name="userService" ref="carnotUserService" />
<property name="queryService" ref="carnotQueryService" />
<property name="adminService" ref="carnotAdministrationService" />
<property name="workflowService" ref="carnotWorkflowService" />
<property name="documentService" ref="carnotDocumentManagementService" />
</bean>
<bean id="enrichSecurity" class="com.sungard.energy.enovos.ipp.training.EnrichSecurity" />
</beans>
[Updated on: Mon, 02 December 2013 07:33] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02277 seconds