scheduler_session

Download Scheduler_session

If you can't read please download the document

Upload: shivani-garg

Post on 12-Apr-2017

175 views

Category:

Documents


6 download

TRANSCRIPT

Slide 1

LAN011213001-23445-819

Agenda Scheduler

Cron Expression

Polling

Sling Jobs

Demo

LAN011213001-23445-819

What is Scheduler ???

Apache Sling Scheduler enables you to easily schedule jobs within your application

Jobs can be executed at a specific time, regularly at a given period or at the time given by a cron expression by leveraging the Sling scheduler service

The scheduler can be used in two ways:

by registering the job through the scheduler API

by leveraging the whiteboard pattern that is supported by the scheduler

How to Write a Scheduler?

Cron Expressions

LAN011213001-23445-819

What is Polling ???

Polling is a data importer service for Adobe Experience Manager (AEM) that lets you import data

To address some business requirements, importing external data into your AEM site is an important use case

Polling Importer

The Sling Event Support adds the notion of a job

A job is a special event that has to be processed exactly once

A job consumer should be prepared to process a job more than once

Sling Jobs (Guarantee of Processing)

Sling Jobs (Guarantee of Processing)

A job consists of two parts, the job topic describing the nature of the job and the payload which is a key value map of serializable objects.

In Sling jobs,we create1.Job Producer2. Job Consumer

Job producer gets created with job name in /var/eventing/unassigned

Job consumer gets created with job name in /var/eventing/assigned

Job Producer (Syntax)

@Component public class Jobs {

@Reference private JobManager jobManager;

public void startJob() { final Map props = new HashMap(); props.put("item1", "/something"); props.put("count", 5);

jobManager.addJob("sling/orderedtest/start", props); } }

Job Consumer (Syntax)

@Component @Service(value={JobConsumer.class}) @Property(name=JobConsumer.PROPERTY_TOPICS, value="my/special/jobtopic",) public class MyJobConsumer implements JobConsumer {

public JobResult process(final Job job) { // process the job and return the result return JobResult.OK; } } You can create your own queue in felix console by Apache Sling job Queue Configuration

References

References for SchedulersScheduler-jobs examples

Schedulers in AEM

aem-adobecq5-code-templates- scheduler

References for Cron Expressions Cron Trigger Explanation

Cron Making Examples

Cron Maker Online Tool