cancel
Showing results for 
Search instead for 
Did you mean: 

how to resume timer job once the exception is resolved

rohran
Champ in-the-making
Champ in-the-making
Hello all,

I have a timer task scheduled in activiti.

But an exception was thrown stating "Unknown property used in expression" in ACT_RU_JOB and a corresponding exception details msg created in ACT_GE_BYTEARRAY table.

I fixed the issue and the due_date in act_ru_job is now become past date. I thought that if i update that table manually with future date would resume the timer job with the resolved exceptions, but it isn't.

Can anyone have expertise of how to resume the timer job if its thrown exceptions? ( i also tried restarting the server/process but it didn't work 😞 )

-rohran
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
There is a field in the ACT_RU_JOB table that state show many retries are left. If this number reaches zero, regardless of the date, it will never be ran automatically. Two ways or re-running the job:

1. Safest way is through the API: Query the job and execute it (may contain compile errors, just off the top of my head). The job is executed in the CALLING thread:


List<Job> jobs = managementService.createJobQuery().withException().list();

for(Job job : jobs)
{
    try {
     managementService.executeJob(job.getId());
    }
    catch(ActivitiException ae) {
       // TODO: Handle Smiley Wink
   }
}

2. Update the "retry count" using the management service, similar approach as above, but the execution will actually happen by the job-executor in car the due date has passed:

managementService.setJobRetries(jobId, 2);

arc
Champ in-the-making
Champ in-the-making
When I tried to use the setJobRetries it seems like the retries_ column is updated as expected but at the same time the duedate_ column is set to null why the job will not execute even though the retries_ column has been set to e.g. 3.

I created another SetJobRetriesCmd which sets both the retries and the duedate and then the job is restarted.

When I debugged the SetJobRetriesCmd it seems like the job read from the db contains null in duedate even though the db contains a correct date value.

    JobEntity job = commandContext
            .getJobEntityManager()
            .findJobById(jobId);

This code snippet from SetJobRetriesCmd returns a job where duedate is set to null regardless of the db value.

jbarrez
Star Contributor
Star Contributor
And is the duedate already null before it is read from the database?

arc
Champ in-the-making
Champ in-the-making
Ok, I have submitted a bug issue for this with an included test case. Maybe it isn't bug, just a misunderstanding?
"Issue ACT-2253 - Job entity does not handle due date correctly in queries has been successfully created."

arc
Champ in-the-making
Champ in-the-making
The ACT-2253 has not been migrated to atlassian jira. Should I resubmit the bug?

jbarrez
Star Contributor
Star Contributor
Yes please. Probably you've just hit the gap when we migrated.