SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
MONTREAL 1/3 JULY 2011




COScheduler
Philippe Rabier - twitter.com/prabier
Sophiacom / bebook
Very often, if not always, we need to create jobs running
periodically. It can be database cleanup, mail sending, statistics
calculations, …

One implementation among other is to create DirectActions
invoked by Cron but there is a better option: Quartz. Quartz is a
famous java open source library that allows developers to create
jobs easily. In this session, you will learn how it's easy to integrate
Quartz in your WebObjects application and how you can use job
persistance based on EOF.
COScheduler = Corason + Quartz Scheduler

      But maybe, 1 day, we’ll call it

                                        ERXScheduler
Agenda
•   Quartz Overview

•   COScheduler Overview

•   Implementation Process

•   First Demo

•   Diving into COScheduler

•   Second Demo

•   Q&A
Quartz Overview
Quartz Job Scheduler

•   Very popular open source java library

•   Exists for a long time (earlier than 2004)

•   Can be used to create simple or complex schedules for
    executing tens, hundreds, or even tens-of-thousands of jobs

•   Quartz 2.0 with new APIs live since 03/29/11
Main Components

•   The JobDetails (JobDetail.java)

•   The Triggers (Trigger.java)

•   The Jobs (Job.java)

•   The Scheduler (Scheduler.java)

•   The Job Store (JobStore.java)
                                  ➡ All of this objects are interface!
COScheduler Overview
The Goals
•   Hide the (relative) complexity of Quartz

•   Make simple job scheduling very simple to implement

•   EOF integration

•   Based on Project Wonder but with few dependancies (ERJars,
    ERExtensions and ERJavaMail)

•   Based on the “Framework Principal” pattern (mandatory)
    http://wiki.objectstyle.org/confluence/display/WONDER/Creating+a+ERXFrameworkPrincipal+subclass


•   You can also use pure java objets rather than EOs!
But…
•   No EOModel embedded

•   Reduce the possibilities provided by Quartz

    •   Only one Trigger linked to a Job Detail

    •   Only CronTrigger is supported

    •   Persistence must be handled by you (use of the RAMJobStore)

•   No clustering

•   Doesn’t fit your needs if you have to handle a big number of jobs
Your Best Friends

•   COJobDescription
    •Interface that your EOs must implement

•   COSchedulerServiceFrameworkPrincipal
    •Abstract class that you have to subclass.

•   COJob
    •Abstract class that you can use to implement your jobs
Implementation Process
COJobDescription
•   COJobDescription = JobDetail + 1 Trigger

•   There are 13 methods exposed by the interface

•   Only 4 are mandatory:
    •name() (the name must be unique)
    •cronExpression()
    •classPath() (ex: org.wocommunity.demo.job.JobDemo)
    •isEnterpriseObject() (must return true if EO)
COSchedulerFrameworkPrincipal
public class MyFrameworkPrincipal extends COSchedulerServiceFrameworkPrincipal
{

	   static
	   {
	   	    setUpFrameworkPrincipalClass(MyFrameworkPrincipal.class);
	   }

	   @Override
	   public NSArray<? extends COJobDescription> getListOfJobDescription(final EOEditingContext editingContext)
	   {
	   	    return myMethodWhichFetchesObjects(editingContext);
	   }

	   @Override
	   public EOEditingContext newEditingContext()
	   {
	   	    return MyFactory.newEditingContext(new EOObjectStoreCoordinator());
	   }

	    @Override
    // can be removed
	    public void finishInitialization()
	    {
	    	    // Your code if you need;
	    	    super.finishInitialization();
	    }
}
COJob, the worker
•   It’s an abstract class that exposes 5 methods to fill out

•   Only 1 is mandatory:
    •_execute()
•   The other are optional
    • willDelete(final COJobDescription jobDescription)
    • willSave(final COJobDescription jobDescription)
    • validateForDelete(final COJobDescription jobDescription)
    • validateForSave(final COJobDescription jobDescription)
La Demo 1
It’s time to dive…
COJobDescription
•   The complete description:

    •   name() (the name must be unique)
    •   cronExpression()
    •   classPath() (ex: org.wocommunity.demo.job.JobDemo)
    •   isEnterpriseObject() (must return true if EO)
    •   group() (can return null, a default value is provided)
    •   jobDescription() (useful when displaying the list of jobs)
    •   jobInfos() (return a map passed to the job when running)
COJobDescription
•   The complete description (follow):

    •   recipients(boolean executionSucceeded)
        a mail can be sent automatically when the job is done
    •   lastExecutionDate()
        setLastExecutionDate(NSTimestamp lastExecutionDate)
    •   firstExecutionDate()
        setFirstExecutionDate(NSTimestamp firstExecutionDate)
    •   setNextExecutionDate(NSTimestamp nextExecutionDate)
Your Good Friends

The Job

                            The JobSupervisor




          The JobListener
COJobSupervisor

•   It’s a job triggered by the scheduler periodically

•   Fetches the job descriptions
    • It calls getListOfJobDescription()

•   Update the list of jobs handled by Quartz
    •add and remove jobs
    •update existing one (JobDetail is rescheduled if only
     cronExpression changed, otherwise recreated)
COJobSupervisor

•       You can define the periodicity by setting a property which is by
        default 5mn.
    •    Example: fr.sophiacom.corason.scheduler.COJobSupervisor.sleepduration=10
            triggers the supervisor every 10 mn

•       You can replace the default supervisor by your own
    ➡      Use an annotation @COMySupervisor defined in your
           framework principal class
COJobSupervisor
   @COMySupervisor("org.wocommunity.wowodc11.COJobSupervisor")
public class COSchedulerFP4Test extends COSchedulerServiceFrameworkPrincipal
{
	
	 @Override
	 public NSArray<COJobDescription> getListOfJobDescription(final EOEditingContext editingContext)
	 {
	 	 return NSArray.emptyArray();
	 }

	   @Override
	   public EOEditingContext newEditingContext()
	   {
	   	 return new MockEditingContext();
	   }
}
COJobSupervisor
•   Manage only the job descriptions returned by
    getListOfJobDescription().

•   How does it do that?

•   There is a convention: it adds a prefix to the group

    •   “CO.” by default

    •   prefix can be changed by the property
        fr.sophiacom.corason.scheduler.foundation.COJobSupervisor.prefix
COJobListener

•   Just before the job runs, it posts a notification
    •  Register an observer with COJobListener.JOB_WILL_RUN
    •  Get the Job Description in the notification userInfo
    •  2 potential keys:
       COJob.ENTERPRISE_OBJECT_KEY
       COJob.NOT_PERSISTENT_OBJECT_KEY
COJobListener

•   When the job is done, it does the following:
    •Post a notification
    •Update the Job Description (firstExecutionDate, last and next)
    •Send an email
    •Log the result
        ************** Job 'CO.DEFAULT.My first job' is starting. FireTime: Wed Jun 29 15:47:20 CEST 2011 /previousFireTime: Wed
        Jun 29 15:47:00 CEST 2011 /nextFireTime: Wed Jun 29 15:47:40 CEST 2011 **************
        ************** Job 'CO.DEFAULT.My first job' is done and it took: 10s **************
COJobListener

•   The notification when the job is done
    • Register an observer with COJobListener.JOB_RAN
    • Get the Job Description in the notification userInfo
    • Get the exception with the key
      COJob.EXCEPTION_KEY
COJobListener
•   Email sending when the job is done
    • A default text mail template is provided
    • You can give more informations by calling setResultMessage()
      just before the job ends up
    • Call recipients(boolean executionSucceeded)
    • You must set the following properties
        fr.sophiacom.ynp.schedulerService.COJobListener.sendingmail=true
        fr.sophiacom.ynp.schedulerService.COJobListener.from=noreply@wocommunity.org
        fr.sophiacom.ynp.schedulerService.COJobListener.to=admin@wocommunity.org
COJobListener
    	   protected void _execute() throws JobExecutionException
	   {
	   	   COJobDescription jd = getJobDescription();
	   	   for (int i = 0; i < 10; i++)
	   	   {
	   	   	   System.out.println("job name: " + jd.name() + " /i value: " + i);
	   	   	   setResultMessage(jd.name() + " : " + i);
	   	   	   try {
	   	   	   	   Thread.sleep(1000L);
	   	   	   } catch (InterruptedException e)
	   	   	   {
	   	   	   	   e.printStackTrace();
	   	   	   }
	   	   }	 	
	   	   setResultMessage("The job " + jd.name() + " is happy!");
	   }


Example of sent message:
	   From: 	 noreply@sophiacom.fr
	   Subject: 	    Job info: CO.Figaroclassifieds.CadrEmploiNotificationSender is done.
	   Date: 	 29 juin 2011 16:24:28 HAEC
	   To: 	admin

More informations: # new notifications: 16561 /# dks: 36587 /# cache: 33987 /max parsing duration: 223ms /# HTTP requests:
33992 /# HTTP errors: 5.  It took 19mn 28s
And if you are not happy…
COJobListener
   @COMyJobListener("org.wocommunity.MyJobListener")
public class COSchedulerFP4Test extends COSchedulerServiceFrameworkPrincipal
{
	
	 @Override
	 public NSArray<COJobDescription> getListOfJobDescription(final EOEditingContext editingContext)
	 {
	 	 return NSArray.emptyArray();
	 }

	   @Override
	   public EOEditingContext newEditingContext()
	   {
	   	 return new MockEditingContext();
	   }
}
Das Demo 2!
Sum Up


•   Easy to integrate

•   Start with basic functionalities

•   Available…soon
The Chuck’s Supplement!
  One More Thing…
Co-operation with JavaMonitor

•   The goals for co-operation with JavaMonitor are these:

    •   Allow the application running the scheduled jobs to be
        scheduled for restarts in JavaMonitor

    •   Don't kill scheduled Jobs, allow them to shut down cleanly

    •   Able to defer a scheduled restart or a termination until the
        last thread ended cleanly.
Co-operation with JavaMonitor
     Add the following code in your Application class
	    public void refuseNewSessions(final boolean shouldRefuse)
    {
    	 if (shouldRefuse)
    	 {
    		    COSchedulerServiceFrameworkPrincipal.getSharedInstance().deleteAllJobs();
    	 }
    	 super.refuseNewSessions(shouldRefuse);
    }

	    public void _terminateFromMonitor()
    {
    	 COSchedulerServiceFrameworkPrincipal.getSharedInstance().deleteAllJobs();
    	 super._terminateFromMonitor();
    }

	    public boolean isTerminating()
    {
    	 (super.isTerminating())
    if
    	
    {
    	
    	   try
    	
    	   {
    	
    	   	    if (COSchedulerServiceFrameworkPrincipal.getSharedInstance().hasRunningJobs())
    	
    	   	    	   return false;
    	
    	   	    if (COSchedulerServiceFrameworkPrincipal.getSharedInstance().getScheduler().isStarted())
    	
    	   	    	   COSchedulerServiceFrameworkPrincipal.getSharedInstance().stopScheduler();
    	
    	   } catch (SchedulerException e)
    	
    	   {
    	
    	   	    log.error("method: isTerminating", e);
    	
    	   }
    	
    }
    	
    return super.isTerminating();
    }
MONTREAL 1/3 JULY 2011




Q&A

Contenu connexe

Tendances

Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Sam Muhanguzi
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadWASdev Community
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateThorben Janssen
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 updateJoshua Long
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful ControllersWO Community
 
Getting started with ReactJS
Getting started with ReactJSGetting started with ReactJS
Getting started with ReactJSKrishna Sunuwar
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleKaty Slemon
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Red Hat Developers
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Ryan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongoMax Kremer
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React AppAll Things Open
 
Using ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian PluginsUsing ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian PluginsAtlassian
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
OpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoOpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoDavid Lapsley
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internalscarlo-rtr
 

Tendances (20)

Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Don't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 InsteadDon't Wait! Develop Responsive Applications with Java EE7 Instead
Don't Wait! Develop Responsive Applications with Java EE7 Instead
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
Getting started with ReactJS
Getting started with ReactJSGetting started with ReactJS
Getting started with ReactJS
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongo
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React App
 
Using ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian PluginsUsing ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian Plugins
 
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven TomacJavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
 
Play framework
Play frameworkPlay framework
Play framework
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
OpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoOpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using Django
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internals
 

Similaire à COScheduler

COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In DepthWO Community
 
Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介dena_genom
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with MuleBui Kiet
 
CICD Pipeline configuration as a code
CICD Pipeline configuration as a codeCICD Pipeline configuration as a code
CICD Pipeline configuration as a codeGrid Dynamics
 
Symfony bundle fo asynchronous job processing
Symfony bundle fo asynchronous job processingSymfony bundle fo asynchronous job processing
Symfony bundle fo asynchronous job processingWojciech Ciołko
 
Junit in mule
Junit in muleJunit in mule
Junit in muleF K
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo javeed_mhd
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニックUnity Technologies Japan K.K.
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOCCarl Lu
 
Legacy Code Kata v3.0
Legacy Code Kata v3.0Legacy Code Kata v3.0
Legacy Code Kata v3.0William Munn
 
Anatomy of classic map reduce in hadoop
Anatomy of classic map reduce in hadoop Anatomy of classic map reduce in hadoop
Anatomy of classic map reduce in hadoop Rajesh Ananda Kumar
 

Similaire à COScheduler (20)

COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In Depth
 
Group111
Group111Group111
Group111
 
Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介Unity 2018からのハイパフォーマンスな機能紹介
Unity 2018からのハイパフォーマンスな機能紹介
 
Enjoy Munit with Mule
Enjoy Munit with MuleEnjoy Munit with Mule
Enjoy Munit with Mule
 
CICD Pipeline configuration as a code
CICD Pipeline configuration as a codeCICD Pipeline configuration as a code
CICD Pipeline configuration as a code
 
Symfony bundle fo asynchronous job processing
Symfony bundle fo asynchronous job processingSymfony bundle fo asynchronous job processing
Symfony bundle fo asynchronous job processing
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule
Junit in muleJunit in mule
Junit in mule
 
Junit in mule demo
Junit in mule demo Junit in mule demo
Junit in mule demo
 
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
【Unite 2017 Tokyo】C#ジョブシステムによるモバイルゲームのパフォーマンス向上テクニック
 
Spock
SpockSpock
Spock
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 
CPP06 - Functions
CPP06 - FunctionsCPP06 - Functions
CPP06 - Functions
 
Legacy Code Kata v3.0
Legacy Code Kata v3.0Legacy Code Kata v3.0
Legacy Code Kata v3.0
 
Spring batch
Spring batchSpring batch
Spring batch
 
Anatomy of classic map reduce in hadoop
Anatomy of classic map reduce in hadoop Anatomy of classic map reduce in hadoop
Anatomy of classic map reduce in hadoop
 
JS Essence
JS EssenceJS Essence
JS Essence
 

Plus de WO Community

In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engineWO Community
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsWO Community
 
Build and deployment
Build and deploymentBuild and deployment
Build and deploymentWO Community
 
Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSWO Community
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldWO Community
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on WindowsWO Community
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnitWO Community
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache CayenneWO Community
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to WonderWO Community
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative versionWO Community
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" patternWO Community
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W WO Community
 
Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languagesWO Community
 

Plus de WO Community (20)

KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systems
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
 
High availability
High availabilityHigh availability
High availability
 
Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWS
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real World
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on Windows
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnit
 
Life outside WO
Life outside WOLife outside WO
Life outside WO
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache Cayenne
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
 
iOS for ERREST
iOS for ERRESTiOS for ERREST
iOS for ERREST
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" pattern
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
 
WOver
WOverWOver
WOver
 
Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languages
 
WOdka
WOdkaWOdka
WOdka
 
ERGroupware
ERGroupwareERGroupware
ERGroupware
 

Dernier

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

COScheduler

  • 1. MONTREAL 1/3 JULY 2011 COScheduler Philippe Rabier - twitter.com/prabier Sophiacom / bebook
  • 2. Very often, if not always, we need to create jobs running periodically. It can be database cleanup, mail sending, statistics calculations, … One implementation among other is to create DirectActions invoked by Cron but there is a better option: Quartz. Quartz is a famous java open source library that allows developers to create jobs easily. In this session, you will learn how it's easy to integrate Quartz in your WebObjects application and how you can use job persistance based on EOF.
  • 3. COScheduler = Corason + Quartz Scheduler But maybe, 1 day, we’ll call it ERXScheduler
  • 4. Agenda • Quartz Overview • COScheduler Overview • Implementation Process • First Demo • Diving into COScheduler • Second Demo • Q&A
  • 6. Quartz Job Scheduler • Very popular open source java library • Exists for a long time (earlier than 2004) • Can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs • Quartz 2.0 with new APIs live since 03/29/11
  • 7. Main Components • The JobDetails (JobDetail.java) • The Triggers (Trigger.java) • The Jobs (Job.java) • The Scheduler (Scheduler.java) • The Job Store (JobStore.java) ➡ All of this objects are interface!
  • 9. The Goals • Hide the (relative) complexity of Quartz • Make simple job scheduling very simple to implement • EOF integration • Based on Project Wonder but with few dependancies (ERJars, ERExtensions and ERJavaMail) • Based on the “Framework Principal” pattern (mandatory) http://wiki.objectstyle.org/confluence/display/WONDER/Creating+a+ERXFrameworkPrincipal+subclass • You can also use pure java objets rather than EOs!
  • 10. But… • No EOModel embedded • Reduce the possibilities provided by Quartz • Only one Trigger linked to a Job Detail • Only CronTrigger is supported • Persistence must be handled by you (use of the RAMJobStore) • No clustering • Doesn’t fit your needs if you have to handle a big number of jobs
  • 11. Your Best Friends • COJobDescription •Interface that your EOs must implement • COSchedulerServiceFrameworkPrincipal •Abstract class that you have to subclass. • COJob •Abstract class that you can use to implement your jobs
  • 13. COJobDescription • COJobDescription = JobDetail + 1 Trigger • There are 13 methods exposed by the interface • Only 4 are mandatory: •name() (the name must be unique) •cronExpression() •classPath() (ex: org.wocommunity.demo.job.JobDemo) •isEnterpriseObject() (must return true if EO)
  • 14. COSchedulerFrameworkPrincipal public class MyFrameworkPrincipal extends COSchedulerServiceFrameworkPrincipal { static { setUpFrameworkPrincipalClass(MyFrameworkPrincipal.class); } @Override public NSArray<? extends COJobDescription> getListOfJobDescription(final EOEditingContext editingContext) { return myMethodWhichFetchesObjects(editingContext); } @Override public EOEditingContext newEditingContext() { return MyFactory.newEditingContext(new EOObjectStoreCoordinator()); } @Override // can be removed public void finishInitialization() { // Your code if you need; super.finishInitialization(); } }
  • 15. COJob, the worker • It’s an abstract class that exposes 5 methods to fill out • Only 1 is mandatory: •_execute() • The other are optional • willDelete(final COJobDescription jobDescription) • willSave(final COJobDescription jobDescription) • validateForDelete(final COJobDescription jobDescription) • validateForSave(final COJobDescription jobDescription)
  • 17. It’s time to dive…
  • 18. COJobDescription • The complete description: • name() (the name must be unique) • cronExpression() • classPath() (ex: org.wocommunity.demo.job.JobDemo) • isEnterpriseObject() (must return true if EO) • group() (can return null, a default value is provided) • jobDescription() (useful when displaying the list of jobs) • jobInfos() (return a map passed to the job when running)
  • 19. COJobDescription • The complete description (follow): • recipients(boolean executionSucceeded) a mail can be sent automatically when the job is done • lastExecutionDate() setLastExecutionDate(NSTimestamp lastExecutionDate) • firstExecutionDate() setFirstExecutionDate(NSTimestamp firstExecutionDate) • setNextExecutionDate(NSTimestamp nextExecutionDate)
  • 20. Your Good Friends The Job The JobSupervisor The JobListener
  • 21. COJobSupervisor • It’s a job triggered by the scheduler periodically • Fetches the job descriptions • It calls getListOfJobDescription() • Update the list of jobs handled by Quartz •add and remove jobs •update existing one (JobDetail is rescheduled if only cronExpression changed, otherwise recreated)
  • 22. COJobSupervisor • You can define the periodicity by setting a property which is by default 5mn. • Example: fr.sophiacom.corason.scheduler.COJobSupervisor.sleepduration=10 triggers the supervisor every 10 mn • You can replace the default supervisor by your own ➡ Use an annotation @COMySupervisor defined in your framework principal class
  • 23. COJobSupervisor @COMySupervisor("org.wocommunity.wowodc11.COJobSupervisor") public class COSchedulerFP4Test extends COSchedulerServiceFrameworkPrincipal { @Override public NSArray<COJobDescription> getListOfJobDescription(final EOEditingContext editingContext) { return NSArray.emptyArray(); } @Override public EOEditingContext newEditingContext() { return new MockEditingContext(); } }
  • 24. COJobSupervisor • Manage only the job descriptions returned by getListOfJobDescription(). • How does it do that? • There is a convention: it adds a prefix to the group • “CO.” by default • prefix can be changed by the property fr.sophiacom.corason.scheduler.foundation.COJobSupervisor.prefix
  • 25. COJobListener • Just before the job runs, it posts a notification • Register an observer with COJobListener.JOB_WILL_RUN • Get the Job Description in the notification userInfo • 2 potential keys: COJob.ENTERPRISE_OBJECT_KEY COJob.NOT_PERSISTENT_OBJECT_KEY
  • 26. COJobListener • When the job is done, it does the following: •Post a notification •Update the Job Description (firstExecutionDate, last and next) •Send an email •Log the result ************** Job 'CO.DEFAULT.My first job' is starting. FireTime: Wed Jun 29 15:47:20 CEST 2011 /previousFireTime: Wed Jun 29 15:47:00 CEST 2011 /nextFireTime: Wed Jun 29 15:47:40 CEST 2011 ************** ************** Job 'CO.DEFAULT.My first job' is done and it took: 10s **************
  • 27. COJobListener • The notification when the job is done • Register an observer with COJobListener.JOB_RAN • Get the Job Description in the notification userInfo • Get the exception with the key COJob.EXCEPTION_KEY
  • 28. COJobListener • Email sending when the job is done • A default text mail template is provided • You can give more informations by calling setResultMessage() just before the job ends up • Call recipients(boolean executionSucceeded) • You must set the following properties fr.sophiacom.ynp.schedulerService.COJobListener.sendingmail=true fr.sophiacom.ynp.schedulerService.COJobListener.from=noreply@wocommunity.org fr.sophiacom.ynp.schedulerService.COJobListener.to=admin@wocommunity.org
  • 29. COJobListener protected void _execute() throws JobExecutionException { COJobDescription jd = getJobDescription(); for (int i = 0; i < 10; i++) { System.out.println("job name: " + jd.name() + " /i value: " + i); setResultMessage(jd.name() + " : " + i); try { Thread.sleep(1000L); } catch (InterruptedException e) { e.printStackTrace(); } } setResultMessage("The job " + jd.name() + " is happy!"); } Example of sent message: From: noreply@sophiacom.fr Subject: Job info: CO.Figaroclassifieds.CadrEmploiNotificationSender is done. Date: 29 juin 2011 16:24:28 HAEC To: admin More informations: # new notifications: 16561 /# dks: 36587 /# cache: 33987 /max parsing duration: 223ms /# HTTP requests: 33992 /# HTTP errors: 5.  It took 19mn 28s
  • 30. And if you are not happy…
  • 31. COJobListener @COMyJobListener("org.wocommunity.MyJobListener") public class COSchedulerFP4Test extends COSchedulerServiceFrameworkPrincipal { @Override public NSArray<COJobDescription> getListOfJobDescription(final EOEditingContext editingContext) { return NSArray.emptyArray(); } @Override public EOEditingContext newEditingContext() { return new MockEditingContext(); } }
  • 33. Sum Up • Easy to integrate • Start with basic functionalities • Available…soon
  • 34. The Chuck’s Supplement! One More Thing…
  • 35. Co-operation with JavaMonitor • The goals for co-operation with JavaMonitor are these: • Allow the application running the scheduled jobs to be scheduled for restarts in JavaMonitor • Don't kill scheduled Jobs, allow them to shut down cleanly • Able to defer a scheduled restart or a termination until the last thread ended cleanly.
  • 36. Co-operation with JavaMonitor Add the following code in your Application class public void refuseNewSessions(final boolean shouldRefuse) { if (shouldRefuse) { COSchedulerServiceFrameworkPrincipal.getSharedInstance().deleteAllJobs(); } super.refuseNewSessions(shouldRefuse); } public void _terminateFromMonitor() { COSchedulerServiceFrameworkPrincipal.getSharedInstance().deleteAllJobs(); super._terminateFromMonitor(); } public boolean isTerminating() { (super.isTerminating()) if { try { if (COSchedulerServiceFrameworkPrincipal.getSharedInstance().hasRunningJobs()) return false; if (COSchedulerServiceFrameworkPrincipal.getSharedInstance().getScheduler().isStarted()) COSchedulerServiceFrameworkPrincipal.getSharedInstance().stopScheduler(); } catch (SchedulerException e) { log.error("method: isTerminating", e); } } return super.isTerminating(); }
  • 37. MONTREAL 1/3 JULY 2011 Q&A