Bug 994533 - ksession.getProcessInstances() does not return active process instances.
ksession.getProcessInstances() does not return active process instances.
Product: JBoss BPMS Platform 6
Classification: JBoss
Component: jBPM Core (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Kris Verlaenen
Marek Baluch
Depends On:
  Show dependency treegraph
Reported: 2013-08-07 09:00 EDT by Marek Baluch
Modified: 2013-08-07 11:19 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-08-07 11:19:08 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
kverlaen: needinfo+

Attachments (Terms of Use)

  None (edit)
Description Marek Baluch 2013-08-07 09:00:56 EDT
Description of problem:

Call to 'getProcessInstancees()' in the following code snippet will not return the expected process instance.

KieSession ksession = createKnowledgeSession("BPMN2-UserTask.bpmn2");
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
ProcessInstance pi = ksession.startProcess("UserTask");
System.out.println(ksession.getProcessInstance(pi.getId())); // prints out the instance correctly		System.out.println(ksession.getProcessInstances()); // prints an empty list

jBPM with JPA on PostgreSQL 9.1.
Comment 1 Kris Verlaenen 2013-08-07 09:38:53 EDT
This is actually expected behaviour.  The getProcessInstances() operation returns the process instances that are currently active in this ksession.  When not using persistence, this will be equivalent to all process instances for that ksession (as they all are in memory).  However, when using persistence, process instances are only in the ksession during execution of that process instance.  As soon as an operation is completed, the process instances are persisted in the database.

Changing the implementation of this operation (for example to load all active process instances from database and return those) wouldn't be very useful, as in any real-life system, the number of process instances could be very large.

If the user want to know information about which process instances are active etc., the history log aka audit log is the place to search for these.

See also JavaDocs:

I would therefore recommend closing this as not a bug.  Please let me know if you disagree, so we can discuss alternatives.
Comment 2 Marek Baluch 2013-08-07 10:55:17 EDT
If the active statement in the documentation does not refer to ProcessInstance.STATE_ACTIVE then please close the issue.

Note You need to log in before you can comment on or make changes to this bug.