-
1. Re: Continue Previous Process Instance
devilkazuya99 Jun 7, 2012 11:48 PM (in response to devilkazuya99)Found these on GitHub:
May be I have to recreate the processInstance with the id i have. Will tell you the outcome.
@Test public void testWithDatabaseAndStartProcessInstance() throws Exception { // Create variable Map params = new HashMap(); NonSerializableClass processVar = new NonSerializableClass(); processVar.setString("1234567890"); params.put(VAR_NAME, processVar); // Persist variable UserTransaction ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction"); ut.begin(); EntityManagerFactory emf = (EntityManagerFactory) context.get(ENTITY_MANAGER_FACTORY); EntityManager em = emf.createEntityManager(); em.setFlushMode(FlushModeType.COMMIT); em.joinTransaction(); em.persist(processVar); em.close(); ut.commit(); // Create process, ProcessInstance processInstance = ksession.createProcessInstance(PROCESS_ID, params); long processInstanceId = processInstance.getId(); Assert.assertTrue(processInstanceId > 0); Assert.assertEquals(ProcessInstance.STATE_PENDING, processInstance.getState()); // insert process, ksession.insert(processInstance); // and start process ksession.startProcessInstance(processInstanceId); ksession.fireAllRules(); // Test results processInstance = ksession.getProcessInstance(processInstanceId); Assert.assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState()); processVar = (NonSerializableClass) ((WorkflowProcessInstance) processInstance).getVariable(VAR_NAME); Assert.assertNotNull(processVar); }
-
2. Re: Continue Previous Process Instance
devilkazuya99 Jun 7, 2012 11:53 PM (in response to devilkazuya99)Nope. that is not what I want. Question: when we call
JPAKnowledgeService.loadStatefulKnowledgeSession(...)
does it also load the processinstances of the knowledgeSession from the database?
I can see records created in processinstanceinfo table but...
-
3. Re: Continue Previous Process Instance
marcosdutto Jul 5, 2012 9:51 AM (in response to devilkazuya99)Did you find any solution for this problem?
Thanks
-
4. Re: Continue Previous Process Instance
hansi007 Jul 5, 2012 10:11 AM (in response to devilkazuya99)Hi there. I Think I had the same problem you have (but with jBPM 5.2). I used to following workaround:
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, config, env ); registerWorkItemHandlersAndEventListeners(); initPersistenceLogger(); if(workitemId != -1){ WorkItemManager wManager = ksession.getWorkItemManager(); wManager.completeWorkItem(workitemId,null); }
So i had to store the sessionId and the actual workItemId.
-
5. Re: Continue Previous Process Instance
eaa Jul 5, 2012 10:32 AM (in response to devilkazuya99)As far as I remember, ksession.getProcessInstances() ALWAYS returns an empty list when you are using persistence. The idea is not to get all the instances from the DB since you could have a lot of them.
If you want to continue the execution of a previous instance you don't need (most of the times) the id of the process, what you need to do is execute the action the instance is waiting for: complete a User Task, complete a Work Item or signal an event.
Best Regards,
-
6. Re: Continue Previous Process Instance
mm524262909 Apr 26, 2014 1:42 PM (in response to eaa)but how can i get all the process Id in jbpm if i want ? i want to monitor all the process so i want to get the process id list
i hava see a lot of topic here someone say we can use history log but i dont know how to do it? can you help me ?