Documentation Home

Module Installation

To add scheduled jobs and events module to a previous community installation requires configuration and database changes.

For clients recieving an enterprise starting project, this module is already configured and nothing further needs to be done.

Configuration Changes

Step 1. Add the dependency management section to your parent pom.xml:

<dependency>
    <groupId>com.broadleafcommerce</groupId>
    <artifactId>broadleaf-jobs-events</artifactId>
    <version>1.1.0-GA</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>

Step 2. Pull this dependency into your core/pom.xml so that it may be used by both the site and admin projects:

<dependency>
    <groupId>com.broadleafcommerce</groupId>
    <artifactId>broadleaf-jobs-events</artifactId>
</dependency>

Data Changes

Schema Changes

This module introduces additional tables which are described in the Data Model documentation. (TODO:link and test to general documentation on schema adds and updates)

Jobs and Events Datasource Configuration

The Scheduled Jobs and Events module requires a new datasource be configured. This is done to facilitate offloading of event message traffic if needed to minimize impact to site performance.

This datasource can be configured to point to the exact same schema as the blPU persistence unit for development and for low to medium volume installations.

For installations with a large amount of admin users (tens of concurrently active users) or other heavy custom event usage, a separate physical database can be used.

Step 1 - Configure the Persistence Unit

Here is an example blEventPU configuration for a MySQL installation. Add this to common-shared.properties in your core project.

blEventPU.hibernate.hbm2ddl.auto=validate
blEventPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blEventPU.hibernate.show_sql=false
blEventPU.hibernate.cache.use_second_level_cache=false
blEventPU.hibernate.cache.use_query_cache=false
blEventPU.hibernate.hbm2ddl.import_files=null

Step 2 - Add the Persistence Unit to the Application

Add the following line to persistence-core.xml in the core project:

<persistence-unit name="blEventPU" transaction-type="RESOURCE_LOCAL">
    <non-jta-data-source>jdbc/event</non-jta-data-source>
    <exclude-unlisted-classes/>
</persistence-unit>

The key item here is the non-jta-data-source name, which should match the datasource configured in your container. Please refer to your container documentation for instructions on configuring a jdbc datasource.

Step 3 - Configure the Datasource in the Application

Add the following line to applicationContext-datasource.xml in both admin and site:

<jee:jndi-lookup id="webEventDS" jndi-name="jdbc/event"/>

You'll find the other datasource entries such as "webDS" already in this file.

Step 4 - Register the Datasource with Broadleaf

Add the following to the sourceMap property of blMergedDataSource in both applicationContext.xml in site and applicationContext-admin.xml in admin:

<entry key="jdbc/event" value-ref="webEventDS"/>

Broadleaf enterprise provides several jobs that should be configured for each site. These jobs are located in the Enterprise project in the file /config/bc/sql/load_sample_jobs.sql.

Here are the contents of that file (may not reflect most up to date values)

-- This file loads default scheduled jobs
--
--poll the system every hour
INSERT INTO BLC_SCHED_JOB (SCHED_JOB_ID, TYPE, NAME, ENABLED, DATE_UPDATED, CRON_EXPRESSION) VALUES (-101, 'CART_PURGE', 'Cart Purge', TRUE, CURRENT_TIMESTAMP, '0 0/60 * * * ?');
--delete abandoned carts that are older than a day
INSERT INTO BLC_SCHED_JOB_DETAIL (SCHED_JOB_DETAIL_ID, SCHED_JOB_ID, NAME, FRIENDLY_NAME, VALUE) VALUES (-100, -101, 'SECONDS_OLD', 'Delete carts older than a day', '86400');
INSERT INTO BLC_SCHED_JOB_DETAIL (SCHED_JOB_DETAIL_ID, SCHED_JOB_ID, NAME, FRIENDLY_NAME, VALUE) VALUES (-101, -101, 'STATUS', 'Delete abandoned carts', 'IN_PROCESS');

--poll the system every hour
INSERT INTO BLC_SCHED_JOB (SCHED_JOB_ID, TYPE, NAME, ENABLED, DATE_UPDATED, CRON_EXPRESSION) VALUES (-120, 'CUSTOMER_PURGE', 'Customer Purge', TRUE, CURRENT_TIMESTAMP, '0 0/60 * * * ?');
--delete anonymous customers that are older than a day
INSERT INTO BLC_SCHED_JOB_DETAIL (SCHED_JOB_DETAIL_ID, SCHED_JOB_ID, NAME, FRIENDLY_NAME, VALUE) VALUES (-120, -120, 'SECONDS_OLD', 'Delete customers older than a day', '86400');
INSERT INTO BLC_SCHED_JOB_DETAIL (SCHED_JOB_DETAIL_ID, SCHED_JOB_ID, NAME, FRIENDLY_NAME, VALUE) VALUES (-121, -120, 'IS_REGISTERED', 'Delete un-registered customers', 'false');

--poll the system every hour
INSERT INTO BLC_SCHED_JOB (SCHED_JOB_ID, TYPE, NAME, ENABLED, DATE_UPDATED, CRON_EXPRESSION) VALUES (-122, 'SANDBOX_CLONE_PURGE', 'Deployed Sandbox Clone Purge', TRUE, CURRENT_TIMESTAMP, '0 0/60 * * * ?');