Hi,

first of all we have a terminology problem: the term job is overloaded.
While both modules talk about jobs they mean different things.

The commons scheduler is a general purpose scheduler (based on Quartz).
It allows to schedule "things" (quartz calls them jobs), basically a
runnable which gets executed on the instance where it is scheduled based
on the schedule. As you pass java objects (runnables or equivalent) to
the scheduler, and these objects might reference other things like OSGi
services etc. these can't be persisted in a general version. Therefore
it is up to the caller to make sure that the right action is performed
if the server restarts.
Typical use cases include periodically pinging remote servers to check
if they are still there etc.

The scheduled jobs as part of the Sling Event module have been added a
long time back and where in the initial code base (long before
SLING-3028). A Sling job is a task that is executed exactly once
somewhere in a clustered installation. (Of course single server works as
well, and exactly once is only achieved under specific circumstances).
Usually such a job is generated ad hoc, like "process this workflow",
"encode this video" etc.
However there are some uses cases where you want to make sure that a job
is periodically performed. In this case, the job scheduler gets a
template for a job and fires it periodically. And the executer makes
sure that this job is executed once, somewhere based on the configuration.

Now, we could get rid of these scheduled jobs as you can also use the
commons scheduler for this. But I'm not sure if it is worth the effort.

Carsten

Konrad Windszus wrote
> Some more updates:
> The Sling Jobs Scheduler was contributed with 
> https://issues.apache.org/jira/browse/SLING-3028 
> <https://issues.apache.org/jira/browse/SLING-3028> initially.
> 
> The relationship of Job Queues and the Job Scheduler are not clear to me 
> though. It seems that the scheduled jobs are only executed in a dedicated 
> single thread and have no relationship with Sling Job Queues at all. Can 
> someone confirm this?
> Thanks,
> Konrad
> 
> 
>> On 06 Apr 2016, at 16:16, Konrad Windszus <konra...@gmx.de> wrote:
>>
>> In the past there was only one service for scheduling jobs [1] (completely 
>> independent of Sling Jobs). Since Sling 7 it is even possible to schedule 
>> Sling Jobs itself (which are persisted in the repository and may be 
>> distributed in a cluster) [2].
>> It would be really nice to have some documentation about the latter in [3] 
>> and also to have some insights on when it is recommended to use which 
>> approach. I understand that the scheduler service is more lightweight 
>> because it does not persist anything in the repo. I would be in favour of 
>> deprecating [1] and recommend everyone to only use Sling Jobs instead, then 
>> there is only one API left for scheduled jobs.
>>
>> WDYT?
>>
>> Thanks,
>> Konrad
>>
>> 1 - 
>> https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html
>> 2 - 
>> https://sling.apache.org/apidocs/sling7/org/apache/sling/event/jobs/JobBuilder.ScheduleBuilder.html
>> 3 - 
>> https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html
>>
>>
>>
> 
> 


 
-- 
Carsten Ziegeler
Adobe Research Switzerland
cziege...@apache.org

Reply via email to