We are providing parameters: 'cycles' and 'timeDuration' to the Boundary timer for performing some repetitive task .
The question here is: how can we get to know and show that How many times the boundary timer has been executed out of total given cycles ?
i.e. cycles = 5 and currently Boundary timer is executed 3 times (this 'number of times it is executed' info is needed).
Any help will be appreciated.
In what context do you want to show how many times it has been completed?
External to the process, if you're just interested in checking, or building something that would query and check those values - so long as your store the value as a process variable, you could always use the REST endpoint for querying variable values.
In a similar vein (although this doesn't sound like a User Task you're repeating), you could potentially just display that process variable data somewhere in the forms. I imagine you're looking for something more like the REST option.
Thanks a bunch for the response.
We just wanna show it in the designer visually.
I have tried to check all Runtime tables of Activiti framework i.e act_ru_job, act_ru_execution etc, but I couldn't understand how Aciviti keeps track of the number of Cycles/times timer is executed executed (mentioned in configuration of boundary timer). It would be great if you can answer this question.
And if I get to know this, then I can take current state of variable/Property/or something that can tell me 'Number of times that timer has executed out of total mentioned Cycles'.
I have checked the link that you have shared, but couldn't understand the usability of it to get exact number of cycles executed, If you can provide me Sample code for doing so, I would really be thankful to you.
the information about timers is stored in act_ru_timer_job. There is a column called repeat_. In this column the time string is stored and decreased everytime the timer is executed. Therefore you would need to use the ManagementService to query the timer job and get the string there. But i don't know if there is a better approach.
Hope this helps a bit
Thanks for providing helpful information.
Just a quick question, that you are talking about which version of Activiti? I think that Table and Value of the mentioned column would be there for upgraded version of activiti.
Because we are running on Activiti Framework version 5.15, and in that we have REPEAT_ = NULL in table act_ru_job (I didn't find any table like act_ru_timer_job for this version of Activiti).
Now suggest me someway for out current version itself.
if i use Activiti 5.15 the timer is stored in act_ru_job with the value of timeCycle in column repeat_. But the value isn't decreased. A workaround would be querying the history for activity. Something like this:
Your answer was so much helpful to me.
Lemme share my quick and EASY solution to Showing number of timer Boundary timer has been executed:
Simply we can use 'act_hi_actinst' table, if boundary timer is executed 2 times, there you find 2 entries for boundary timer, hence using sID and number of entries for the same or different sID entries, we can determine Boundary Timer Execution Count.
But now the main Question is, Where exactly Activiti stores configured 'cycles' parameter's value??
Because before boundary timer executes, we can find entry of it in 'act_ru_job' table with column value: i.e. REPEAT_ = R3/2017-02-23T14:53:06/PT1M
But once boundary timer is executed, this entry vanishes and then I can't understand how does Activiti keeps track of left 2 repetition of timer execution (in case of cycles = 3, for example).
Kindly show me simplest way of fetching values of Cycles (i.e. from any column of any Activiti table), because Byte array parsing is also not a optimised way of fetching cycle's value.
the timer is deleted from act_ru_job if all the times it should repeat are executed or if the task get's completed. The repititions are calculated and not stored. Have a look at the TimerEntity.execute method. The time when the timer was set is stored in the repeat_ column. Furthermore you can calculate if the timer has to be executed again or not.
Hope this helps,
I am almost done with the solution but just a step away.
As a scenario, if we have something that clears all pending action attached immediately after boundary timer then, despite the boundary timer was configured with cycles=3 attached to a user task, the timer runs once, and then actions are cleared so how to get original count of cycles then? As in this scenario the act_ru_job table has no entries now, so now what's the option to know Originally configured cycles??
i think there are only two options. The first one is to get the bpmnModel of the processDefinition and read the String from the timer. Or if you pass the String for the timerEvent as a processVariable you can get from a HistoricProcessInstanceQuery by including the variables.