-
Notifications
You must be signed in to change notification settings - Fork 199
job configuration
Mahmoud Ben Hassine edited this page Sep 24, 2020
·
4 revisions
The JobBuilder
API is the main entry point to configure and create batch jobs:
Job job = new JobBuilder()
.named("myJob")
.build();
By default, the job name is job
.
Once you have created a batch job instance, you can run it:
//Either by calling the job directly
JobReport jobReport = job.call();
// Or using the org.easybatch.core.job.JobExecutor API
JobExecutor jobExecutor = new JobExecutor();
JobReport jobReport = jobExecutor.execute(job);
// Or using a java.util.concurrent.ExecutorService
ExecutorService executorService = ..;
JobReport jobReport = executorService.submit(job).get();
// Using the org.easybatch.core.job.JobExecutor API
JobExecutor jobExecutor = new JobExecutor();
Future<JobReport> jobReport = jobExecutor.submit(job);
// Or using a java.util.concurrent.ExecutorService
ExecutorService executorService = ..;
Future<JobReport> jobReport = executorService.submit(job);
When the job is finished, you get an execution report with statistics and metrics about the job run.
NOTE: Don't forget to shutdown the JobExecutor
at the end of your application using JobExecutor#shutdown()
method.
Easy Batch jobs can be configured with the following parameters:
Parameter | Type | Default | Description |
---|---|---|---|
batch size | long | 100 | the size of each batch |
error threshold | long | +∞ | error limit after which the job is aborted |
enable jmx | boolean | false | enable JMX monitoring |
enable batch scanning | boolean | false | enable batch scanning for the faulty record after a failed write operation |
All parameters can be set through the JobBuilder
. Here is an example:
Job job = new JobBuilder()
.batchSize(50)
.errorThreshold(10)
.enableJmx(true)
.enableBatchScanning(true)
// define batch components (reader, writer, etc)
.build();
Easy Batch is created by Mahmoud Ben Hassine with the help of some awesome contributors
-
Introduction
-
User guide
-
Job reference
-
Component reference
-
Get involved