The CWDS Jobs project provides java based stand alone applications which are meant to be scheduled periodically.
Prerequisites are job dependent but typically you can expect the following to be needed :
- DB2 10.x
- Postgres 9.x
- Elasticsearch 5.3.2 or newer (newer would require testing)
- Source code, available at GitHub
- Java SE 8 development kit
- DB2 Database
- Postgres Database
- Elasticsearch
% ./gradlew build
Main Class: gov.ca.cwds.jobs.FacilityIndexerJob run job using following command:
$java -cp jobs.jar gov.ca.cwds.jobs.FacilityIndexerJob path/to/config/file.yaml
In order to create new job you have to implement 2 interfaces: JobReader, JobWriter and optional JobProcessor JobReader has a single method I read() which is responsible for reading items from input source. It must return null when everything is read. JobWriter has a single method write(List<I> items) which is responsible for writing chunk of data to output target. JobProcessor has a single method O process(I item), you can implement it if some mapping logic is required Then you should provide those components to a job. Google guice example config:
@Provides
@Named("job")
@Inject
public Job job(@Named("reader") JobReader reader,
@Named("writer") JobWriter writer) {
return new AsyncReadWriteJob(reader, writer);
}
//or with processor
@Provides
@Named("job")
@Inject
public Job job(@Named("reader") JobReader reader,
@Named("processor") JobProcessor processor,
@Named("writer") JobWriter writer) {
return new AsyncReadWriteJob(reader, processor, writer);
}
Read and write operation runs in separate threads.