spring-batch

Spring Batch - how to COMPLETE a job when the JdbcPagingItemReader returns no data

依然范特西╮ 提交于 2019-12-08 06:35:34
问题 My question is reverse of this existing SO question. Behavior of JdbcPagingItemReader seems reverse of what is being described in that question i.e. job is marked as FAILED if JdbcPagingItemReader doesn't find any records. Logs indicate that Job is marked as FAILED because reader couldn't fetch pages from page 1 on wards and SELECT fails due to SQLCODE=-313 i.e. -313 THE NUMBER OF HOST VARIABLES SPECIFIED IS NOT EQUAL TO THE NUMBER OF PARAMETER MARKERS So overall step is marked as failed

Spring Batch: Horizontal scaling of Job Repository

倖福魔咒の 提交于 2019-12-08 06:13:12
问题 I read a lot about how to enable parallel processing and chunking of an individual job, using Master/Slave paradigm. Consider an already implemented Spring Batch solution that was intended to run on a standalone server. With minimal refactoring I would like to enable this to horizontally scale and be more resilient in production operation. Speed and efficiency is not a goal. http://www.mkyong.com/spring-batch/spring-batch-hello-world-example/ In the following example a Job Repository is used

How to fetch String from setValues() method of PreparedStatementSetter

和自甴很熟 提交于 2019-12-08 06:05:07
问题 I want to fetch a string from setValues() method of ItemPreparedStatementSetter which is my SQL string. I want to use this String into setSql() method of ItemWriter . Can somebody help me to achieve this. Below is my PreparedStatementSetter class: public class PreparedStatementSetter implements ItemPreparedStatementSetter<Object>{ public static final int INT = 4; public static final int STRING = 12; public void setValues(Object item, PreparedStatement ps) throws SQLException{

Cannot convert value of type 'org.springframework.batch.item.xml.StaxEventItemWriter' to required type 'org.springframework.batch.item.ItemReader'

依然范特西╮ 提交于 2019-12-08 05:43:59
问题 I am developing Spring Batch MongoDB to XML example. I've successfully created the project, but when I am running it I see the below error is coming, I don't know what is going wrong here. Error for reference Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'step1': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org

Spring batch pause/resume vs stop/restart

假装没事ソ 提交于 2019-12-08 05:13:01
问题 I am new to spring batch and has some questions regarding pause/resume. After reading spring batch documentation, there doesn't seem to have any built-in pause or resume functions. However, there is this use case i found from the main site: http://docs.spring.io/spring-batch/2.0.x/cases/pause.html There are no sample codes provided or is there any place I could find these samples? In Spring batch, I understand there is a stop and restart function built-in. Could I use this as a form of pause

Using MultiResourceItemReader to read 2 plain text file and write into single file

蓝咒 提交于 2019-12-08 04:41:17
问题 My batch job will generate 2 text files with string format per line. I created a reader <bean id="myMultiResourceReader" class=" org.springframework.batch.item.file.MultiResourceItemReader"> <property name="resources" value="file:D:/MY/sample/*.txt" /> </bean> <bean id="myFinalWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"> <property name="resource" value="${test.file3}" /> <property name="lineAggregator"> <bean class="org.springframework.batch.item.file

Pass Spring Batch Tasklet Failure Message to Reporting Step.

*爱你&永不变心* 提交于 2019-12-08 04:28:39
问题 I'm using a Spring Batch Tasklet with OpenCSV to read my CSV files. Before the question is asked, I'm aware of chunks, but there is cross validation between files in a later step, so I must continue to use the Tasklet. What I'm trying to do is report a missing file or parsing error to my reporting step. I'm not sure what the proper approach should be to report the failure to my next step. I have the following code. Initial step to read file. public class CsvBatchReader<T> implements Tasklet,

Spring Batch annotation partitioner issue

六眼飞鱼酱① 提交于 2019-12-08 04:25:31
I am trying to create a spring batch application using annotation based approach with partitioner, which will be triggered by quartz scheduler, but getting following issues. When the job is triggered each partition is executed sequentially instead of parallelly i.e if I have 10 partitions instead of all 10 getting triggered/processed together it process one by one. When more than one instance of job(this is needed as per my requirement) gets triggered it's not getting synchronized properly i.e when 2nd instace is started it uses 1st instance data and 1st instance will stop processing but will

How to read ini file in spring batch (key=value)

北战南征 提交于 2019-12-08 04:14:06
问题 I want to create a batch using Spring batch to read from an ini file and save the data in database but when I chekced the org.springframework.batch.item.file.FlatFileItemReader class I didn't find a way to parse my data from the ini file , I tried to combine the ini4j API with the spring batch but no result my ini file : [Cat] a=1 b= 2 c= 3 d= 4 e= 5 f= 6 [Cat2] a=11 b= 21 c= 31 d= 41 e= 51 f= 61 回答1: What you can do is define your own ItemStreamReader that wraps a delegate ItemStreamReader ,

DataLoader Using Spring Batch - Partitioning

拈花ヽ惹草 提交于 2019-12-08 03:47:40
问题 I am working on a data loader that reads the flat file , some processing and write to the database. The dataloader.properties files contains the value LOAD=MM1,MM2,MM3,MM4,MM5... I have to read this properties file and using spring batch's partition step and partitioner , i want all the files inside the folder(MM1), do the reading and writing to db parallel, any db error for a particular file should rollback the content of that file, similarly for the other folders(MM2)As i am new to spring