cancel
Showing results for 
Search instead for 
Did you mean: 

Get Script Start Time while running

eransinger
Champ in-the-making
Champ in-the-making
Hello.
I want to log Start time for Activities, Script activity to be precise.
I saw that i can get it by calling
historyService.createProcessInstanceHistoryLogQuery(processInstanceId)
                                     .includeActivities()
                                     .includeComments()
                                     .includeTasks()
                                     .singleResult()

and for HistoricActivityInstanceEntity i can get the time (.getTime()).

I've notice that i get the start time data ONLY AFTER the activity is done.
Meaning i can't get start time for failed activities that are stuck. (This is a requirement )

Obviously the data is stored some Where.

Do you know a good way to retrieve by activityId the startTime of an activity that is currently running/Stuck?

Thanks
2 REPLIES 2

yvoswillens
Champ in-the-making
Champ in-the-making
Hi Eran,

The historic data is persisted when the transaction is completed. That explains the described behaviour.

Are your script activities async? (I guess they are because they can be 'stuck'?)
In that case it's possible to query the job table (used by the job executor). The job is persisted before the activity is started.

It's also possible to implement a ExecutionListener ( http://www.activiti.org/userguide/#executionListeners )
This way you can hook in on several events with custom logic. F.e. the start and / or the end of and activity. In that custom logic you can start a separate transaction for logging the start time somewhere.
But it is important to be aware of the fact why you want to start a separate transaction. In case of a rollback (and retries) this may cause unexpected behaviour.

Regards,

Yvo

The job Table has no Data about the start time. Will try The execution Listener.
Thanks!