Reputation: 1567
I'm working on simple activiti process and i need somehow to check is current process already running or not. My idea was to use such code:
activitiInitEngineBean.getRuntimeService()
.createExecutionQuery()
.processDefinitionKey(BPConstants.PROCESS_ID_D1_ASSEMBLY_PROCESS)
.count() > 1;
So i just get runtimeService inside a java method which is executed by activiti BPConstants.PROCESS_ID_D1_ASSEMBLY_PROCESS process and add filter using definitionKey(id of the process) and check count. I found that .createExecutionQuery() always returns empty list. For example such code will return empty list also:
activitiInitEngineBean.getRuntimeService()
.createExecutionQuery()
.list()
It's not expected because i call it inside a process(so it should return at least 1 execution). What should i configure in order to work with runtimeService?
Upvotes: 1
Views: 2201
Reputation: 194
Your update is not stored to the db until wait state is reached (see Transactions and Concurrency). If you want to get your process instance from the query running process instance has to reach first wait state. In fact you do not need to create query to get execution, because execution is already present e.g. script task variables or as a parameter of the interface method.
Upvotes: 1
Reputation: 1567
By default activiti doesn't store anything to ru tables when works with < serviceTask> tag. Solution was to add async attribute:
<serviceTask activiti:async="true"
Upvotes: 0