spring-batch

Spring Batch - MongoDB to XML - Caused by: java.lang.IllegalStateException: A type to convert the input into is required

本秂侑毒 提交于 2019-12-02 09:09:41
问题 I am developing Spring Batch - MongoDB to XML example. In this example, when I run the main method I see the below error is cominng. Please guide on the below error. I tried to find the solution on the web, but I dont find anything helpful on the web yet. Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': Cannot resolve reference to bean 'mongodbItemReader' while setting bean property 'itemReader'; nested exception is org

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

旧街凉风 提交于 2019-12-02 08:55: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 you are interested in how I got there please see my previous question: Spring Batch - Looping a reader

Spring Batch DelimitedLineTokenizer class quoteCharacter property behavior

我与影子孤独终老i 提交于 2019-12-02 08:37:26
I have a item reader as below: <beans:bean id="myItemReader" class="org.springframework.batch.item.file.FlatFileItemReader"> <beans:property name="resource" ref="myFileResource" /> <beans:property name="lineMapper"> <beans:bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"> <beans:property name="lineTokenizer"> <beans:bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"> <beans:property name="delimiter" value="|"/> <beans:property name="quoteCharacter" value="~"/> <beans:property name="names" value="${my_column_names}" /> </beans:bean> <

how to implement complex pattern matching in Spring batch using PatternMatchingCompositeLineMapper

空扰寡人 提交于 2019-12-02 08:37:09
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. 0000001131444444444444445589868444050MarketsABNAKKAAAAKKKA05568551456........... I tried to write regular expression but it does

Spring batch integration MessageSource<InputStream> to Joblaunch request

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 08:30:46
I am planning to use S3Streaming message source to process the import file (xml)received in S3. I am not sure how to transform MessageSource to job launch request as job parameter doesn't support parameters other than primitive type, please throw some light on how to proceed on this - Thanks If you mean you want to pass the InputStream payload to an ItemReader , no, that can't be done with a JobLauncher . Instead, the ItemReader itself needs to open the input stream (perhaps using a Spring Integration SftpRemoteFileTemplate ). Just pass the information (filename, server, credentials, etc) in

Spring Batch. How to get the number of the element being processed

泄露秘密 提交于 2019-12-02 08:00:49
We're storing the elements of a XML file into our database using spring batch. Is it possible to retrieve the number of the element being processed when inserting it into the database? To clearify, this is my job configuration: <bean id="xmlItemReader" scope="step" class="org.springframework.batch.item.xml.StaxEventItemReader"> <property name="fragmentRootElementName" value="person" /> <property name="resource" value="#{jobParameters[xmlPath]}" /> <property name="unmarshaller" ref="personUnmarshaller" /> </bean> <!-- Read and map values to object, via jaxb2 --> <bean id="personUnmarshaller"

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

隐身守侯 提交于 2019-12-02 07:50:30
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-rowsbased-on-some-column-value-to-it

Spring Batch. How to get the number of the element being processed

丶灬走出姿态 提交于 2019-12-02 07:48:29
问题 We're storing the elements of a XML file into our database using spring batch. Is it possible to retrieve the number of the element being processed when inserting it into the database? To clearify, this is my job configuration: <bean id="xmlItemReader" scope="step" class="org.springframework.batch.item.xml.StaxEventItemReader"> <property name="fragmentRootElementName" value="person" /> <property name="resource" value="#{jobParameters[xmlPath]}" /> <property name="unmarshaller" ref=

Standalone example on jberet (jsr352)

巧了我就是萌 提交于 2019-12-02 06:53:02
问题 Is there anyway to use jberet as standalone module to execute Batch Jobs? All the time getting samples on using along with WildFly. Surprised to see it looks for container to load implementations while trying some samples. Any insights on why/why not would be helpful 回答1: Here is a tutorial how to use jberet in a standalone application: http://www.mastertheboss.com/batch-api/running-batch-jobs-in-j2se-applications You'll need to include various jboss dependencies for it to work. Furthermore

Multiple spring batch jobs

瘦欲@ 提交于 2019-12-02 05:49:05
I am using the @Scheduled annotation in Spring Boot to trigger multiple jobs. Following is the code snippet: @EnableBatchProcessing @EnableScheduling public class Config extends DefaultBatchConfigurer{ @Autowired JobLauncher launcher; @Scheduled public void run(){ String[] argList = {"A", "B"}; for(String char : argList){ launcher.run(job(), new JobParametersBuilder(). addString("char", char). toJobParameters()); } } public Job job(){ //Job definition is here. } } However, this triggers the 2 jobs in succession and not in parallel, i.e. the application waits for job with parameter "A" to