spring-batch

spring-batch (java-config) identifying and executing step using JobExecutionDecider

廉价感情. 提交于 2019-12-23 16:06:39
问题 I have 3 steps A, B, C which should execute in the sequence A->B->C where B is optional. I've to execute step B only based on some condition. I'm using JobExecutionDecider to decide as follows: @Bean(name = "decider") JobExecutionDecider isStepRequired { return new JobExecutionDecider() { @Override public FlowExecutionStatus decide(final JobExecution jobExecution, final StepExecution stepExecution) { if (condition not satisfied) { // return status to skip step B and go to step C return

Spring Batch thread-safe Map job repository

一世执手 提交于 2019-12-23 15:49:37
问题 the Spring Batch docs say of the Map-backed job repository: Note that the in-memory repository is volatile and so does not allow restart between JVM instances. It also cannot guarantee that two job instances with the same parameters are launched simultaneously, and is not suitable for use in a multi-threaded Job, or a locally partitioned Step. So use the database version of the repository wherever you need those features. I would like to use a Map job repository, and I do not care about

Spring Batch - Is it possible to have a dynamic column in FlatFileReader?

情到浓时终转凉″ 提交于 2019-12-23 12:44:40
问题 I'm dealing with many CSVs files that don't have a fixed header/column, saying that I can get file1.csv with 10 column and file2.csv with 50 column. I can't know in advance the number of column that I'll have, I can't create a specific job for each file type, my input will be a black box: bunch of CSV that will have an X number of column from 10 to infinite. As I want to use Spring Batch to auto import these CSVs, I want to know if it is possible? I know that I have to get a fixed number of

Spring Batch - FlatFileItemReader \001 delimiter issue

烈酒焚心 提交于 2019-12-23 05:33:20
问题 I am working on a Spring batch application where i am using FlatFileItemReader to read the file with delimiter ~ or | and its working fine and its calling the processor once read is completed. But when i try to use the delimiter as \001 the processor is not called and i am not getting any error also in the console.(Linux environment) Example file format: 0002~000000000000000470~000006206210008078~PR~7044656907~7044641561~~~~240082202~~~ENG~CH~~19940926~D~~~AL~~~P~USA This is my reader

Spring Batch - compositeItemReader and compositeItemWritter examples - Unable to print both tables data in same XML/CSV file

谁说我不能喝 提交于 2019-12-23 05:12:41
问题 I am developing the Composite Reader and Writter example. I am able to successfully developed the code, but when trying to run the code I am getting only one tables data, I don't see other tables data is coming in CSV file. Please guide. Customer.java public class Customer implements Serializable{ private static final long serialVersionUID = 1L; private Integer customerNumber; private String customerName; private String contactLastName; private String contactFirstName; private String phone;

Can we use AmqpItemReader and AmqpItermWriter for request/reply use case in spring batch?

安稳与你 提交于 2019-12-23 04:54:20
问题 I have seen the AmqpJobSample http://docs.spring.io/spring-batch/spring-batch-samples/#AmqpJobFunctionalTests It uses AmqpItemReader to read from rabbitmq message queue, processes it using message handler and then writes back to queue using AmqpItemWriter. My use case is to, read items from listItemReader which I have implemented, then sends items to messaging queue which will be processed by consumers running on different servers (rabbitmq cluster) and those consumers will respond back

spring batch writing to a fixed format file

久未见 提交于 2019-12-23 04:02:53
问题 I have an Item Writer as below: <beans:property name="lineAggregator"> <beans:bean class="org.springframework.batch.item.file.transform.FormatterLineAggregator"> <beans:property name="fieldExtractor"> <beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"> <beans:property name="names" value="column1, column2, column3, column4 " /> </beans:bean> </beans:property> <beans:property name="format" value="%-8s%-12s%-11s%-16s" /> </beans:bean> </beans:property> As

spring batch writing to a fixed format file

最后都变了- 提交于 2019-12-23 04:02:20
问题 I have an Item Writer as below: <beans:property name="lineAggregator"> <beans:bean class="org.springframework.batch.item.file.transform.FormatterLineAggregator"> <beans:property name="fieldExtractor"> <beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"> <beans:property name="names" value="column1, column2, column3, column4 " /> </beans:bean> </beans:property> <beans:property name="format" value="%-8s%-12s%-11s%-16s" /> </beans:bean> </beans:property> As

Caused by: java.lang.IllegalArgumentException: Unable to deserialize the execution context in Spring Batch

半城伤御伤魂 提交于 2019-12-23 03:26:09
问题 I am developing Spring Boot + Batch XML based approach. In this example, I have created following classes. When I simply load or class the Spring Batch Job. I get the below error. I web search links like : Migration to Spring Boot 2 and using Spring Batch 4 , but it did not solve my problem. Could anyone please guide what exact solution needs to be applied here ? Error: Caused by: java.lang.IllegalArgumentException: Unable to deserialize the execution context at org.springframework.batch.core

How to do aggregation with Spring Batch?

走远了吗. 提交于 2019-12-23 02:52:21
问题 I am trying to figure out how to do aggregation with Spring Batch. For example, I have a CSV file with a list of names: name John Amy John Ryan And I want name count in text file: name, count Amy, 1 John, 2 Ryan, 1 From what I learned from Spring Batch, the ETL batch process (itemReader -> ItemProcessor -> ItemWriter) is more like just a mapping phase in map-reduce lingo. How do I do the reduce(aggregation) phase in Spring Batch? Is Spring Batch the right tool to use? Or should I use Spark