-
1. Re: How to complete a signalled process ?
swiderski.maciej Sep 8, 2014 1:33 AM (in response to cyu021)with persistence enabled the ProcessInstance returned from startProcess will reflect only the state of the process instance until last wait state. Then when you signal process instance you will need to fetch the instance vie ksession.getProcessInstance to see any updates to it and I believe then you will get null as process instance has been completed.
HTH
-
2. Re: Re: How to complete a signalled process ?
cyu021 Sep 8, 2014 6:24 AM (in response to swiderski.maciej)Hi Maciej,
I think process state is the side effect of that process does not complete properly or at least been marked as complete.
Following is the database records for P1 and P2 mentioned in previous post.
P1 has processInstanceId of 16 while P2 has 15.
In processinstancelog table, we can see P2 is in complete state (status = 2) and P1 is in active state (status = 1 + both duration and end_date are null)
In processinstanceinfo table, I cannot find any record with InstanceId of 15 or 16, so I recon both P1 and P2 finish running.
and this is the code snippet (important part is highlight in blue) I used to fire signalEvent() and getState() on P1.
ds = new PoolingDataSource();
ds.setUniqueName("jdbc/testDS");
ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");
ds.setAllowLocalTransactions(true);
ds.setMaxPoolSize(3);
ds.getDriverProperties().put("driverClassName", "com.mysql.jdbc.Driver");
ds.getDriverProperties().put("Url", "jdbc:mysql://localhost:3306/jbpm");
ds.getDriverProperties().put("password", "jbpm");
ds.getDriverProperties().put("user", "jbpm");
ds.init();
kservices = KieServices.Factory.get();
kstore = kservices.getStoreServices();
environment = kservices.newEnvironment();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
TransactionManager tm = TransactionManagerServices.getTransactionManager();
environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
environment.set(EnvironmentName.TRANSACTION_MANAGER, tm);
ksconf = kservices.newKieSessionConfiguration();
kbase = kservices.getKieClasspathContainer().getKieBase();
ksession = kstore.loadKieSession(sessionId, kbase, ksconf, environment);
ProcessInstance processInstance = ksession.getProcessInstance(pid);
ksession.signalEvent(signal, data, pid);
System.out.println(processInstance.getState());
I just don't know why signalEvent() can put process into complete state when persistence is disabled and leave process in active state when persistence is enabled.
Is there any extra steps to be taken when persistence is enabled?
-
3. Re: Re: Re: How to complete a signalled process ?
cyu021 Sep 9, 2014 4:32 AM (in response to cyu021)I take one further step by examining nodeinstancelog table.
Please refer to the following observation in case you need more information.
for process instance #15 that completes properly, the node instance id is in perfect mirror.
eg. 0 -> 1 -> 2 -> 3 -> 3 -> 2 -> 1 -> 0
where node id #3 appears twice
for process instance #16 that remains active but is actually completed, the node instance id has one node id missing.
eg. 0 -> 1 -> 2 -> 3 -> 2 -> 1 -> 0
where node id #3 only appears once
-
4. Re: How to complete a signalled process ?
swiderski.maciej Sep 10, 2014 1:15 AM (in response to cyu021)1 of 1 people found this helpfulthe problem with your code is that you don't register logger on your ksession and that's why processinstancelog table does not have log records while processinstance is actually completed.
I would recommend using RuntimeManager based code to avoid such issues. See jbpm docs for details about both JPA db logger on ksession and runtime manager.
HTH
-
5. Re: How to complete a signalled process ?
cyu021 Sep 10, 2014 2:57 AM (in response to swiderski.maciej)Thank you Maciej,
In jbpm docs, I see there is a JPAWorkingMemoryDbLogger. (Chapter 8. Core Engine: Persistence and transactions)
When I try to find a logger for real DB (not in memory DB), I cannot find one.
Do you mind to provide an example or relative document link?
-
6. Re: How to complete a signalled process ?
swiderski.maciej Sep 10, 2014 3:15 AM (in response to cyu021)same logger shall be used regardless of the data base type. The name is WorkingMemory and not MemoryDB
HTH