Get a specific timer from the current tenant.

Get a specific timer from the current tenant.



I want to get/check if a multi-tenant timer is currently running for a specific tenant.

The reason for this is I have a big process that will take 10-30mins depending on the number of items it needs to process, using Process BPM is quite good but sometimes the Process was getting aborted. So, the best way to handle this case is a timer and adjust the default timeout (Let me know if I'm wrong.).

Now, How I can check if the timer is currently running to prevent another invocation of the timer from the web app?



If you invoke the timer while it is currently running, it will simply run again after the current run completes. If you invoke it more than one time while it is running, it will still only run once. The best pattern for this is to have the web app write rows into an entity that represents a job queue, with a status on them and the needed data for the job. Have the timer check for any un-run jobs when it starts, loop over them, and do the needed actions for each one, marking them as complete (and probably running CommitTransaction at the end of each loop, to make sure the job only gets run once)... have the per-job work performed inside a separate action that catches errors and marks the job as failed, so this way an exception doesn't cause the whole timer to fail, just the job that failed to get marked as failed and let the rest process. At the end of the timer, you can re-launch it to make sure it doesn't let things sit in the job queue too long.


But, if you REALLY want to check it, the System entities around "Cyclic_Job", "Cyclic_Job_Shared", and the entities they tie to, have the timer information.


Yeah, What I'm actually doing is a create a multi-tenant table that will store the status of the timer and it has 3 status.



So, if the user tried to trigger the timer from the web UI and then there is a running timer for that tenant, it will prevent it.

Gotcha. I would definitely use a separate entity for this then (especially so you can view failures).