spring-batch

Spring batch run multiple jobs in parallel

断了今生、忘了曾经 提交于 2019-12-02 22:27:49
问题 I am new to Spring batch and couldn't figure out how to do this.. Basically I have a spring batch files and both are have to run parallel i.e when I request execute_job1 then BatchConfig1 have to execute and when I request execute_job2 then BatchConfig2 have to execute. How can I do this? Controller @RestController public class JobExecutionController { @Autowired JobLauncher jobLauncher; @Autowired Job job; /** * * @return */ @RequestMapping("/execute_job1") @ResponseBody public void

Spring Batch : PassThroughFieldExtractor with BigDecimal formatting

南楼画角 提交于 2019-12-02 21:13:42
问题 I'm using Spring Batch to extract a CSV file from a DB table which has a mix of column types. The sample table SQL schema is [product] [varchar](16) NOT NULL, [version] [varchar](16) NOT NULL, [life_1_dob] [date] NOT NULL, [first_itm_ratio] [decimal](9,6) NOT NULL, the sample Database column value for the 'first_itm_ration' field are first_itm_ratio 1.050750 0.920000 but I would like my CSV to drop the trailing zero's from values. first_itm_ratio 1.05075 0.92 I'd prefer not to have to define

Spring Batch : Field or property 'stepExecutionContext' cannot be found

谁说我不能喝 提交于 2019-12-02 19:43:45
问题 I have the following spring batch job configuration. There is a single reader which then passes details to a composite writer which has two specific writers. Both writers share a common parent and need to use the same JobId for the INSERT operations they execute. <bean id="job" parent="simpleJob"> <property name="steps"> <list> <bean parent="simpleStep"> <property name="itemReader" ref="policyReader"/> <property name="itemWriter" ref="stagingCompositeWriter"/> </bean> </list> </property> <

Custom ItemReader to return more than one rows[based on some column value] to ItemProcessor

筅森魡賤 提交于 2019-12-02 18:11:56
问题 I have a file with multiple rows. I need to read more than one rows based on some column value and pass it to Processor as List. Sample Input file is: 2|joe|24|CA 2|sam|32|MA 2|joe|44|CA 3|amy|21|CA The file is sorted based on first field. I wanted to pass first three rows to processor as List<item> then last row as separate List<item> Is it something we can do with CustomItemReader? Regards, Shankar 来源: https://stackoverflow.com/questions/31832341/custom-itemreader-to-return-more-than-one

Spring Batch - How to generate parallel steps based on params created in a previous step

爷,独闯天下 提交于 2019-12-02 17:30:34
问题 Introduction I am trying to use jobparameters created in a tasklet to create steps following the execution of the tasklet. A tasklet tries to finds some files (findFiles()) and if it finds some files it saves the filenames to a list of strings. In the tasklet I pass the data as following: chunkContext.getStepContext().getStepExecution().getExecutionContext().put("files", fileNames); The next step is a parallel flow where for each file a simple reader-processor-writer step will be executed (if

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

蹲街弑〆低调 提交于 2019-12-02 16:33:19
I am working on a Spring Boot Batch example with MongoDB and I have already started the mongod server. When I launch my application, I am getting the error below. Any pointers for this issue? *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database

how to implement complex pattern matching in Spring batch using PatternMatchingCompositeLineMapper

两盒软妹~` 提交于 2019-12-02 16:31:33
问题 How can we implement pattern matching in Spring Batch, I am using org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper I got to know that I can only use ? or * here to create my pattern. My requirement is like below: I have a fixed length record file and in each record I have two fields at 35th and 36th position which gives record type for example below "05" is record type which is at 35th and 36th position and total length of record is 400.

Spring batch and XA and local transactions

▼魔方 西西 提交于 2019-12-02 16:24:43
问题 It is possible to have a jobRepository in spring batch to use local transactions but execute particular job steps in distributed XA transaction? For XA I use Atomicos 3.8.0. Step is supposed to read the JMS message and update the DB after processing. The relevant part of spring configuration: <job id="job" xmlns="http://www.springframework.org/schema/batch"> <step id="inventorySync"> <tasklet transaction-manager="xaTransactionManager"> <chunk reader="jmsQueueReader" processor=

Advantages of spring batch [closed]

∥☆過路亽.° 提交于 2019-12-02 16:18:35
I understood that spring batch framework processes data in chunks. However, I was thinking that when the same chunking functionality can be acheived through java why do we need to go for batch framework. Could any one please let me know if there are more reasons for going to spring batch framework? Let me rephrase your question a bit and see if this addresses it. What does Spring Batch provide that I'd have to handle myself when building a batch application? Spring Batch served as the basis for JSR-352 (the java batch specification) and since that specification has come out, there is a lot of

How to levarage spring batch without using POJO?

。_饼干妹妹 提交于 2019-12-02 16:09:56
问题 I know BeanWrapperFieldSetMapper class depends on POJO. But here is the thing: If I want to take advantage of Spring Batch features but do not want to create separate jobs ( does not want to write POJOs and separate reader writes or mappers) how to do this? My requirement is to read *.csv file which will have the headers so I should be able to supply header names in a map or string[] and create my sql statement based on it, instead of writing a RowMapper . This will help me uploading various