cancel
Showing results for 
Search instead for 
Did you mean: 

Recorded running time of process instance problem

serid
Champ in-the-making
Champ in-the-making
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
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Adrian,

Is this the expected behaviour ?
Yes, it is.
4) On PROCESS_COMPLETED event for A I start the queued process using the same thread which invoked the onEvent method
B is completed in the same thread and transaction as A. Because it is ended during PROCESS_COMPLETED event handling.

Regards
Martin

serid
Champ in-the-making
Champ in-the-making
Hi Martin,

Ok then - many thanks for your confirmation.


Best Regards,
Adrian