Timer with parameter period of time

Timer with parameter period of time

  

Let's say I want to execute an action every 3 hours. But then user can change it to their needs like every 1 hour. So this is a parameterized value stored on either DB or Site properties.

How to achieve this?

Solution

Eric Halim wrote:

Let's say I want to execute an action every 3 hours. But then user can change it to their needs like every 1 hour. So this is a parameterized value stored on either DB or Site properties.

How to achieve this?

Hi  Eric, Just before timer gets end, You may need to update the schedule run every time in ossys_cyclic_job with adding the configured hours for next schedule.

Sachin



Solution

Also need to consider how many "Users" you are doing this for. For example if you only have one user and one timer then as Sachin said you can just update the timer job either by changing the schedule or the next run time. 

But if you want to do this for multiple or hundreds of users then a separate timer for each probably isn't best approach. For that I would create one timer which checks an entity (say once every hour) to see what user jobs need to be run and each user job could have its own next run time. I know it is duplicating some of the Outsystems functionality but I've never been a fan of having hundreds of different timers.

Hi Eric,

For a single schedule, Sachin's approach is what I'd go for.

For the kind of scenario John mentions (multiple users, each with their own "schedule" for the Action) you may want to consider using BPT processes. You can trigger new instances of a process by simply creating new entity records (a new Job Entity record, for instance, that has info on when to execute your Action next, for that particular user).

So..it is a never ending timer then? So you will set the timer to run only on "when published" rather than on specific period of time. Is that correct?

Hi Eric,

Run on publish is basically when you do things only once while publishing and more on UAT or PROD environments when you deploy a new release and want to populate some specific data there.

The solution to your problem depends upon what you want to do (how big your process) , you can go for BPT as Jorge suggested if you want to perform small task with less data and if your task is big and can take some good time in process you may go for timers.

Now Instead scheduling your timer every time you can schedule your timer for every 15 Min and check how many user has their schedules that time (may be +-15 min) and perform that task for all of them.


Regards

-PJ-



Sorry oot.. I created the timer but never gets executed I log it to table when the timer starts but the table always empty. And the timer also not found on Service Center. Did I miss something? Does timer need a privilege?

Hi Eric,

Timers don't use privileges. The timer you created, what is its schedule? When you say that the timer cannot be found in SC, I assume you mean in the Timer Log, as opposed to the Timer tab of the eSpace? You can always run the timer manually, to see if it runs at all.

Kilian Hekhuis wrote:

Hi Eric,

Timers don't use privileges. The timer you created, what is its schedule? When you say that the timer cannot be found in SC, I assume you mean in the Timer Log, as opposed to the Timer tab of the eSpace? You can always run the timer manually, to see if it runs at all.

Ah I see I wrongly see timers log.. so it never be there. Thank for pointing that out. I can see the timers tab on the espace. But anyway it never gets executed even when I click "Run Now" button. I will find out I think probably due to security issue.


Hi Eric,

If there is no mention of your Timer in the Timers log page of Service Center (Monitoring->Timers), then your time was not executed. I see two main reasons for that: your timer doesn't have a schedule (so the platform never runs it), or your front-end is configured not to run timers.

If there are rows on the Timers log page for your timer, but you don't see any changes on your Entity's table, then the Timer probably has errors (you can find them on the Errors log tab and the Timers log tab). 

Jorge Martins wrote:

Hi Eric,

If there is no mention of your Timer in the Timers log page of Service Center (Monitoring->Timers), then your time was not executed. I see two main reasons for that: your timer doesn't have a schedule (so the platform never runs it), or your front-end is configured not to run timers.

If there are rows on the Timers log page for your timer, but you don't see any changes on your Entity's table, then the Timer probably has errors (you can find them on the Errors log tab and the Timers log tab). 

Thanks a lot yes apparently the front-end is not configured to do so. (I was like banging my head lol)

I think OS platform should show warning message instead of successful message. So developers are not mislead.


Eric,

Glad we could help, but... what warning message/successful message are you referring to?

So appaently front-end was not configured to run timers. But when I execute the timers (from SC via button manually) the message says timers has been successfully executed. So I was thinking everything was fine.

I'm not sure what's the message that displays, but the timer is never executed immediately when you tell the platform to execute it (via SC or otherwise). What you're telling the platform is something similar to "execute this timer as soon as there's an available timer thread".

If you go to Environment Health you will be able to see the list of scheduled timers... if some time has passed since they should've executed, you will see a yellow exclamation next to them, with a relevant message. If no front-end is running timers, you will end up with all timers with a warning saying they should've executed a while ago, but haven't yet