Bug 994533 - ksession.getProcessInstances() does not return active process instances.
Summary: ksession.getProcessInstances() does not return active process instances.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Kris Verlaenen
QA Contact: Marek Baluch
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-07 13:00 UTC by Marek Baluch
Modified: 2013-08-07 15:19 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-07 15:19:08 UTC
Type: Bug
Embargoed:
kverlaen: needinfo+


Attachments (Terms of Use)

Description Marek Baluch 2013-08-07 13:00:56 UTC
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


Environment:
jBPM with JPA on PostgreSQL 9.1.

Comment 1 Kris Verlaenen 2013-08-07 13:38:53 UTC
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:
http://docs.jboss.org/jbpm/v5.4/javadocs/org/drools/runtime/process/ProcessRuntime.html#getProcessInstances%28%29

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 14:55:17 UTC
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.