Continue process Instance
marcosdutto Jul 10, 2012 9:59 AMHi,
I have a simple process with 3 User Tasks. I am trying to load the session and continue with the process but it doesn't work.
When i complete a task from a process created in the same execution of the program it works. But when I complete a User task from a process saved previously it doesn't work. I think that the task is completed but jbpm doesn't know where it has to continue or something like that.
Doing a test i use the lines:
processInstance2 = (RuleFlowProcessInstance) ksession.getProcessInstance(XX);
NodeInstance nodeInstance = processInstance2.getNodeInstance();
and the node Instance is always an instance from the first User Task. Moreover, being at the second Task of my processInstance i saved the session after that i loaded that session and the same thing happened (the node Instance was an instance from the first User Task).
This is my piece of code:
public static final void main(String[] args) throws Exception { startUp(); KnowledgeBase kbase = readKnowledgeBase(); EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" ); Environment env = KnowledgeBaseFactory.newEnvironment(); env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); StatefulKnowledgeSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(2, kbase, null, env ); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession)); JPAWorkingMemoryDbLogger dblogger = new JPAWorkingMemoryDbLogger(ksession); Map<String, Object> params = new HashMap<String, Object>(); Thread.sleep(1000); ksession.addEventListener(new GecosProcessListener()); ksession.signalEvent("Trigger", null); Thread.sleep(2000); RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) ksession.startProcess("simple",params); Thread.sleep(1000); System.out.println("Id session: "+ksession.getId()); System.out.println("Process Instances: "+ksession.getProcessInstances().size()); System.out.println("Process Instance ID: "+processInstance.getId()); ... ... ... dblogger.dispose(); ksession.dispose(); System.exit(0); }
sdlgjh