[jboss-user] [jBPM Users] - Re: How to stop a process instance

fdegrigny do-not-reply at jboss.com
Thu Oct 8 04:56:03 EDT 2009


Last I found how to do this.
In fact the ProcessIntance.end() method really terminate the process but not all the running process tasks in it (this has confused me).
The process tasks have to be terminated separately.

At last, I have made all my ActionHandlers extends a custom base one :

public abstract class BaseActionHandler implements ActionHandler {
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception {
  | 		try {
  | 			doAction(executionContext);
  | 		} catch (Throwable t) {
  | 			handleException(t, executionContext);		
  | 		}
  | 	}
  | 	
  | 	public abstract void doAction(ExecutionContext executionContext) throws Exception; 
  | 	
  | 	protected void handleException(Throwable t, ExecutionContext executionContext) throws Exception {
  | 		log.fatal("Error in " + this.getClass().getName() + ": " + t.getMessage(), t);
  | 		
  | 			//try to stop process instance and associated tasks
  | 			ProcessInstance processInstance = executionContext.getProcessInstance();
  | 			stopProcess(processInstance);
  | 				
  | 		throw new JbpmException(t.getMessage(), t);			
  | 	}
  | 	
  | 	protected void stopProcess(ProcessInstance processInstance) {
  | 		JbpmContext jbpmContext = JbpmConfiguration.getInstance().getCurrentJbpmContext();
  | 		Collection<TaskInstance> taskInstances = unchekedCast(processInstance.getTaskMgmtInstance().getTaskInstances());
  | 		for(TaskInstance task : taskInstances) {
  | 			if( ! task.hasEnded() ) {
  | 				task.setSignalling(false);
  | 				task.cancel();
  | 				jbpmContext.save(task);		
  | 			}	
  | 		}
  | 		processInstance.end();		
  | 	}
  | }

What I have found over-complicated is the JBPM API itself. I'm working with for few month now and  there is many things I still cannot understand. For example, the various variables scopes are very confusing and the semantic of many operations are not very clear.
My customers have very basics needs for their workflows but I have discover that they cannot be done simply with the JBPM API.


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259303#4259303

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259303



More information about the jboss-user mailing list