Created
January 27, 2018 14:43
-
-
Save jonasurbano/cabcf4e845f545b53cd785dd70b4e69d to your computer and use it in GitHub Desktop.
This file contains 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
Spring Batch give us those ItemReader implementations out of the box: | |
AbstractItemCountingItem | |
StreamItemReader | |
AmqpItemReader | |
FlatFileItemReader | |
HibernateCursorItemReader | |
HibernatePagingItemReader | |
IbatisPagingItemReader | |
ItemReaderAdapter | |
JdbcCursorItemReader | |
JdbcPagingItemReader | |
JmsItemReader | |
JpaPagingItemReader | |
ListItemReader | |
MongoItemReader | |
Neo4jItemReader | |
RepositoryItemReader | |
Spring Batch give us those ItemWriter implementations out of t he box: | |
AbstractItemStream | |
AmqpItemWriter | |
CompositeItemWriter | |
FlatFileItemWriter | |
GemfireItemWriter | |
HibernateItemWriter | |
IbatisBatchItemWriter | |
ItemWriterAdapter | |
JdbcBatchItemWriter | |
JmsItemWriter | |
JpaItemWriter | |
MimeMessageItemWriter | |
MongoItemWriter | |
Neo4jItemWriter | |
RepositoryItemWriter | |
StaxEventItemWriter |
This file contains 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, | |
version=3, | |
name=step1, | |
status=COMPLETED, | |
exitStatus=COMPLETED, | |
readCount=3, | |
filterCount=0, | |
writeCount=2 | |
readSkipCount=1, | |
writeSkipCount=1, | |
processSkipCount=0, | |
commitCount=2, | |
rollbackCount=2 |
This file contains 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
# Download and run Spring Cloud Data Flow locally: | |
wget http://repo.spring.io/release/org/springframework/cloud/spring-cloud-dataflow-server-local/1.2.3.RELEASE/spring-cloud-dataflow-server-local-1.2.3.RELEASE.jar | |
java -jar spring-cloud-dataflow-server-local-1.2.3.RELEASE.jar | |
# Download and run Spring Cloud Data Flow Shell locally: | |
wget http://repo.spring.io/release/org/springframework/cloud/spring-cloud-dataflow-shell/1.2.3.RELEASE/spring-cloud-dataflow-shell-1.2.3.RELEASE.jar | |
java -jar spring-cloud-dataflow-shell-1.2.3.RELEASE.jar | |
# Register the application: | |
app register — name batch-demo — type task — uri file:///Users/jurbano/Desktop/batch-demo-0.0.1-SNAPSHOT.jar | |
# The common case is to register the application with the Maven URI maven.// so Spring Cloud Data Flow downloads the artifact from the repository. Other application types are sinks and sources. | |
# Create and run the job: | |
task create myjob — definition batch-demo | |
task launch myjob |
This file contains 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
@Bean | |
public Job job(Step step1) throws Exception { | |
return jobBuilderFactory.get("job1") | |
.incrementer(new RunIdIncrementer()) | |
.start(step1) | |
.build(); | |
} | |
@Bean | |
public Step step1() { | |
return stepBuilderFactory.get("step1") | |
.tasklet(new Tasklet() { | |
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) { | |
System.out.println("Reading..."); | |
return null; | |
} | |
}) | |
.build(); | |
} |
This file contains 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
@Bean | |
public Step step1() { | |
return stepBuilderFactory.get("step1") | |
.<Person,Person>chunk(2) | |
.reader(csvReader()) | |
.writer(writer()) | |
.faultTolerant() | |
.skipLimit(2) | |
.skip(FlatFileParseException.class) | |
.skip(FlatFileFormatException.class) | |
.skip(IllegalArgumentException.class) | |
.listener(skipListener()) | |
.build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment