Last active
March 23, 2021 16:19
-
-
Save fmbenhassine/68a8796afb451e91488c4b350cb7c865 to your computer and use it in GitHub Desktop.
An example of how to use Easy Jobs to run Easy Batch jobs #EasyBatch #EasyJobs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id: 1 | |
name: uppercase job | |
description: An easy batch job that transforms text to uppercase | |
class: UppercaseJob | |
method: uppercase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.jeasy</groupId> | |
<artifactId>easy-jobs-easy-batch-job</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<dependencies> | |
<dependency> | |
<groupId>org.easybatch</groupId> | |
<artifactId>easybatch-core</artifactId> | |
<version>5.1.0</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>3.1.0</version> | |
<configuration> | |
</configuration> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.easybatch.core.job.Job; | |
import org.easybatch.core.job.JobBuilder; | |
import org.easybatch.core.processor.RecordProcessor; | |
import org.easybatch.core.reader.StringRecordReader; | |
import org.easybatch.core.record.StringRecord; | |
import org.easybatch.core.writer.StandardOutputRecordWriter; | |
public class UppercaseJob { | |
private String text; | |
public String getText() { | |
return text; | |
} | |
public void setText(String text) { | |
this.text = text; | |
} | |
public void uppercase() { | |
Job job = JobBuilder.aNewJob() | |
.named("UppercaseJob") | |
.reader(new StringRecordReader(text)) | |
.processor(new RecordProcessor<StringRecord, StringRecord>() { | |
public StringRecord processRecord(StringRecord record) throws Exception { | |
return new StringRecord(record.getHeader(), record.getPayload().toUpperCase()); | |
} | |
}) | |
.writer(new StandardOutputRecordWriter()) | |
.build(); | |
job.call(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment