Web / Apache OFBiz Interview questions
How does OFBiz's Job Scheduler execute persisted and recurring jobs?
Persisted jobs live as rows in the JobSandbox entity, each recording the service to run, its serialized parameters, a run time, and, for recurring jobs, a link to a TemporalExpression defining the recurrence pattern (daily, every N minutes, specific weekdays, and so on).
A background JobPoller thread polls JobSandbox for jobs whose run time has arrived, hands each due job to the Service Engine exactly like any other async call, and then, for recurring jobs, calculates the next run time from the temporal expression and writes a new JobSandbox row.
Because jobs are rows in the database rather than in-memory timers, they survive a server restart, and a cluster of OFBiz instances can share one JobSandbox table with locking so a job runs on exactly one node.
More Related questions...