cancel
Showing results for 
Search instead for 
Did you mean: 

Process not query-able immediately after it started

ekolesnikov
Champ in-the-making
Champ in-the-making
Hi all,

Just found this weird thing: if there is a sub-process, or parallel execution, it appears that process instance / execution queries return null up until the process reaches its first wait state.

I.e. I have the following code in my sub-process' Java Service Task:


      RuntimeService rs = execution.getEngineServices().getRuntimeService();
      String processInstanceId = execution.getProcessInstanceId();
      ProcessInstance parentProcess = rs.createProcessInstanceQuery().subProcessInstanceId(processInstanceId).includeProcessVariables().singleResult();


The sub-process diagram is quite simple: http://www.screencast.com/t/kZaTJsIb

The problem here is that without that intermediary timer event, the query above will return null for parent process. With the timer, everything appears to be working properly.

It looks like the task execution happens in a separate database transaction - hence the lack of visibility. Is this correct behaviour?
1 REPLY 1

trademak
Star Contributor
Star Contributor
Hi,

This is normal behaviour in Activiti. The database changes will only be performed when a wait state is reached, so it's not yet in the database at all. An activity can be made asynchronous to force a wait state as well.

Best regards,