Batch Job Scheduling

In Batch Developers Guide we showed you how to build batch applications and launch them in an adh-hoc fashion.
But typically batch jobs are launched at as scheduled time or based on some event. In this section, we will show you how you can schedule the launch of the batch jobs using Spring Cloud Data Flow.

Spring Cloud Data Flow Scheduling Overview

Spring Cloud Data Flow lets a user schedule the launching of tasks via a cron expression. A schedule can be created through the RESTful API or the Spring Cloud Data Flow UI. Spring Cloud Data Flow will schedule the execution of its tasks via a scheduling agent that is available on the cloud platform. Scheduling Architecture When using the Cloud Foundry platform Spring Cloud Data Flow will use the PCF Scheduler. When using Kubernetes, CronJobs will be used.

Scheduling a Batch Job

Make sure you have registered your timestamp application and created a definition for it as discussed in the Getting Started Guide. So using the UI we will schedule the timestamp-task by pressing the drop down button and selecting the "Schedule Task" option as highlighted below: Create Schedule

So for this scenario we want to launch this application once a minute. To do this fill out the Schedule setup page as follows:

In the sample below we set the name of the schedule to timestamp-task-once-a-minute and the cron expression to */1 * ? * *. Notice that the cron expression is expressed in the format used by Quartz. Also notice we can add command line arguments and deployment parameters for this schedule, but we will not do so for this example. Once you have entered the cron expression, press the Schedule the task button. Now PCF Scheduler will handle the scheduled launches for your batch application.

Schedule Batch App Cloud Foundry

In the sample below we set the name of the schedule to timestamp-task-once-a-minute and the cron expression to */1 * * * *. Notice we can add command line arguments and deployment parameters for this schedule, but we will not do so for this example. Now press the Schedule the task button. Now a Cron Job has been created to handle the scheduled launches for your batch application.

Schedule Batch App Kubernetes

Spring Cloud Data Flow does not support scheduling on the local platform.

Monitoring Task Launches

The status of each scheduled launch can be viewed on Spring Cloud Data Flow's Executions tab.

SCDF Scheduled Executions

Deleting a Schedule

From the Schedules tab, press the drop down button next to the schedule you want to remove and select the "Delete schedule" option as highlighted below: Delete Schedule

When the confirmation dialog appears, press the Delete Task Schedules(s) button. SCDF Confirm Schedule Delete