AnsweredAssumed Answered

Recorded running time of process instance problem

Question asked by serid on Aug 31, 2016
Latest reply on Aug 31, 2016 by serid
Hi All,

I have a dedicated service layer which triggers start of a process.
I also have a "counterpart" of all available activiti processes in non apache activiti DB table which I update accordingly for my own purposes and needs (that is the main reason I use an additional service layer really).
I do some checks before starting a process and if it finds out that a process cannot start immediately such a process in my own DB table is marked as "Queued". The simplest way of trying to start the queued processes is to listen to "PROCESS_COMPLETED" event. Now here is the interesting part. If I start the queued processes in the event listener using the same thread which invoked the listener then the duration time of the process instance which made the second process to be put in a queue is the sum of the duration time of the process instance and the queued process instance. So it goes something like this:

1) Two processes available: A, B and each of them runs exactly 50 seconds
2) Someone starts process A and while A is running someone starts process B
3) Because process B cannot run at the same time as process A process B is queued
4) On PROCESS_COMPLETED event for A I start the queued process using the same thread which invoked the onEvent method
5) Process B completes
6) I check the act_hi_procinst table and process A's duration is 1m40s which is the double time of running it (which is the sum of the 2 processes) and process B's duration is correct - 50 s. That is because the process A's END_TIME_ is the same as process B's END_TIME_ although their START_TIME_ values are different and accurate for each of them.

If I start the queued processes in a separate thread all is good.
The processes are synchronous.

Is this the expected behaviour ? Looks to me a bit inconsistent especially that START_TIME_ gets recorded properly …


Thanks,
Adrian

Outcomes