7.2.3. Scheduled synchronization

eXo Platform provides a class that can be configured as a scheduled job. When it runs, it calls the syncAll method of the OrganizationIntegrationService.

To configure the job, add the following configuration to your sync.xml:


<external-component-plugins>
    <target-component>org.exoplatform.services.scheduler.JobSchedulerService</target-component>
    <component-plugin>
        <name>OrgInitializerCronJob</name>
        <set-method>addCronJob</set-method>
        <type>org.exoplatform.services.scheduler.CronJob</type>
        <description>Schedule the organization integration operation</description>
        <init-params>
            <properties-param>
                <name>cronjob.info</name>
                <description>Invoke initializer periodically</description>
                <property name="jobName" value="OrgInitializerCronJob"/>
                <property name="groupName" value="group"/>
                <property name="job" value="org.exoplatform.platform.organization.integration.OrganizationIntegrationJob"/>
                <property name="expression" value="0 45 23 * * ? *"/>
            </properties-param>
        </init-params>
    </component-plugin>
</external-component-plugins>

The only parameter you need to re-configure is the expression that schedules when the job is fired.

Note

Here provided just a short explanation and some examples of the expression so that you can pick up one quickly. To learn its syntax, read CRON Expression documentation.

Cron expression examples

An expression consists of seven sub-expressions separated by a white space. For being easily recognized, in the following tables, each sub-expression is written in a column (the seventh sub is optional):

SecondsMinutesHoursDay-of-MonthMonthDay-of-WeekYearDescription
04523?***23:45 every day
04523?*SUN 23:45 every Sunday
04523?*2-7 23:45 every days of the week except Sunday
04523?*TUE,THU 23:45 every Tuesday and Thursday
04523?*SUNL 23:45 the last Sunday of every months
045231*? 23:45, the 1st day of every months
04523L*? 23:45, the last day of every months
00/15*?***once per 15 minutes, starting from the minute 0

Testing

The job calls the SyncAll method. When it runs, you will see the following logs:

Start all Organizational model synchronization. [o.e.p.o.i.OrganizationIntegrationJob<DefaultQuartzScheduler_Worker-4>]
Organizational model synchronization finished successfully. [o.e.p.o.i.OrganizationIntegrationJob<DefaultQuartzScheduler_Worker-4>]

For testing, you can configure it to run every 1 minute by using the expression: * 0/1 * * * ? *.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus