-
1. Re: How to get active processes via ksession.getProcessInstances() (Jbpm 5.1.1)
amin-mc Oct 8, 2011 2:29 AM (in response to rrpeterson)I had the same issue as well. In the end I created my own JPA query using the entity manager. I had a requirement to create a runtime operation to check process meta data and this was the only way I could do it. I'm not convinced my approach is the best way...
-
2. Re: How to get active processes via ksession.getProcessInstances() (Jbpm 5.1.1)
mnorsic Oct 10, 2011 4:08 AM (in response to amin-mc)1 of 1 people found this helpfulHi,
I spotted the exact same problem (please see http://community.jboss.org/message/628732, unrelated to your issue, but I have mentioned it as issue found while creating my processes).
It seems that Javadoc about method getProcessInstances() does not imply that in persistent scenario this method returns anything:
"Returns a collection of currently active process instances. Note that only process instances that are currently loaded and active inside the engine will be returned.
When using persistence, it is likely not all running process instances will be loaded as their state will be stored persistently. It is recommended not to use this method to collect information about the state of your process instances but to use a history log for that purpose."
So, I think you have to resort to the following:
1. create your own JPA query to fetch all running process instances for particular knowledge session, or
2. use history log
HTH
Miljenko
-
3. Re: How to get active processes via ksession.getProcessInstances() (Jbpm 5.1.1)
salaboy21 Oct 12, 2011 8:25 AM (in response to mnorsic)1 of 1 people found this helpfulTotally agree with Miljenko, History logs is the way to go for getting that information and not impacting the jBPM5 runtime database.
Cheers
-
4. Re: How to get active processes via ksession.getProcessInstances() (Jbpm 5.1.1)
rrpeterson Oct 20, 2011 10:57 AM (in response to amin-mc)I wound up doing something similar to Amin's solution, where I check the ProcessInstanceInfo table first to see if the session is "alive". If so I know its still active & working, and if no result is found then it's probable the processInstance is complete. For anyone else that may have the same issue, I used the JPA query:
// Query the DB for active processInstances that match the given processId
final Query nativeQuery = entityManagerFactory.createEntityManager().createQuery("SELECT procInfo from ProcessInstanceInfo procInfo where procInfo.processId = :processId");
nativeQuery.setParameter("processId", processId);