spring-batch

spring batch ItemReader FlatFileItemReader set cursor to start reading from a particular line or set linestoskip dynamically

社会主义新天地 提交于 2019-12-12 12:14:24
问题 In my springbatch+quartz setup, I am reading a CSV File using FlatFileItemReader. I want to set the cursor for the reader to start the next jobinstance with the given parameters for reader. Is it possible? <bean id="cvsFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"> <!-- Read a csv file --> <property name="resource" value="classpath:cvs/input/report.csv" /> <property name="lineMapper"> <bean class="org.springframework.batch.item.file.mapping

Java Batch job in cluster environment

我的未来我决定 提交于 2019-12-12 10:50:01
问题 We have a cluster with 2 JBOSS nodes. We have a batch job which loads all users details from a active directory to a DB. This job is run everyday. It was run before in a non clustered environment and hence we designed it as a singleton. Now we have a clustered environment and I do not know what is best way to achieve the same result. I want batch job to be run only once a day. We use spring and hibernate and I looked at Spring batch. I could not get any concise answer to my question. Can

Spring - Batch update using simplejdbccall while using Stored Procedure

会有一股神秘感。 提交于 2019-12-12 10:26:15
问题 I am using spring jdbc template, to create record using stored procedure public Long create(City $obj) { SimpleJdbcCall jdbcCall = new SimpleJdbcCall(getJdbcTemplate().getDataSource()).withProcedureName(SP_ADD_UPDATE); jdbcCall.declareParameters(new SqlOutParameter(ConstantUtil.RETUR_VAL, OracleTypes.BIGINT)); Map<String, Object> jdbcCallResult = jdbcCall.execute(new MapSqlParameterSource(populateParams($obj))); return (Long) jdbcCallResult.get(ConstantUtil.RETUR_VAL); } params private static

Processing millions of database records in Java [closed]

坚强是说给别人听的谎言 提交于 2019-12-12 10:12:10
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I have a requirement to write a batch job that fetches rows from a database table and based on a certain conditions, write to other

How to set exit status in spring batch application

感情迁移 提交于 2019-12-12 09:16:12
问题 I am writing a batch application in which I would like to set the exit status immediately when ever my application logic identify an issue and return. For example I am setting the below status in my writer's write method. stepExecution.getJobExecution().setExitStatus(ExitStatus.FAILED); eventhough the above statment is executed, am getting below message in logs and the exit code is seems to be success. "Batch Execution Successful!" May I know how can I set the exit code properly? There are

Spring Batch - how to fail a job when the ItemReader returns no data

╄→гoц情女王★ 提交于 2019-12-12 09:14:19
问题 I have a spring batch application which reads data from a DB table with JdbcCursorItemReader and writes it to a flat file with FlatFileItemWriter. When I test my application, I see that the FlatFileItemWriter creates a file even if no data is returned from the DB via JdbcCursorItemReader. However, I'm planning to fail my job when there is no appropriate data in DB. Is it possible to do so or at least prevenet FlatFileItemWriter from creating a file? Regards 回答1: from http://static

spring batch - Partition Step to rollback all the previous chunk commit 's, when chunk fails

血红的双手。 提交于 2019-12-12 09:00:02
问题 I am using spring batch to process multiple files using MultiResourcePartitioner and all the itemreader and writers are in step scope.Each step runs individual files and commits to database at interval of 1000. when there is any error during current processing, all the previous commits needs to be roll backed and the step will fail . Thus the file contents are not added to the database. Which is the best way among these: Using Transaction Propogation as NESTED. Setting commit interval in

Spring Batch-Repeat step for each item in a data list

笑着哭i 提交于 2019-12-12 08:57:42
问题 This is a tough one, but I am sure it is not unheard of. I have two datasets, Countries and Demographics. The countries dataset contains the name of a country and an ID to it's Demographic data. The demographic dataset is a hierarchal dataset starting from the country down to the suburb. Both of these datasets are pulled from a 3rd party on a weekly basis. I need to split the demographics out into files, one for each country. So far the steps that i have are 1) Pull Countries 2) Pull

What is the function of JobBuilderFactory.get(job).incrementer(RunIdIncrementer)?

自闭症网瘾萝莉.ら 提交于 2019-12-12 08:12:21
问题 I'm developing a Spring-Batch project using Spring-Boot and everything is going along nicely. I've done a few spring-batch examples (including some from spring.io), but I'm not sure what some of the stuff does, and "it just works" doesn't satiate me. My spring boot main class implements CommandLineRunner and for this particular job the initial set up looked like @Bean public Job myJob(JobExecutionListenerSupport listener) { return myJobBuilderFactory.get(JOB) .listener(listener) .start(myStep

Restarting a Spring batch job after app server failure or spring batch repository DB failure?

流过昼夜 提交于 2019-12-12 07:00:42
问题 When spring batch DB failure happens or server is shut down, a spring batch job which was running at that time will be in a unknown started state. In spring batch admin, we will not see an option to restart the job. Hence we are not able to resume the job. How to restart the job from last successful commit? The old discussions suggest that it had to be dealt manually by updating tables. I was manually able to update end time, status in batch step execution and batch job execution tables. Is