spring-batch

Is there a spring batch “job” scope?

隐身守侯 提交于 2019-12-05 02:23:37
I just want to know if there is a "JOB" scope in spring batch, like the "STEP" scope ? If there is not, should we develop our custom scope, or is there a better alternative ? Thanks in advance. Raphaël Brugier A jira has been opened some times ago on the spring batch issues tracker regarding this issue: https://jira.springsource.org/browse/BATCH-1701 A pull request has been submitted as well, hopefully it will be merge soon, because I have this use case too: https://github.com/SpringSource/spring-batch/pull/41 There are multiple workarounds in the mean time, each with its drawback, see this

Spring boot + spring batch without DataSource

时光毁灭记忆、已成空白 提交于 2019-12-05 01:54:29
I'm trying to configure spring batch inside spring boot project and I want to use it without data source. I've found that ResourcelessTransactionManager is the way to go but I cannot make it work. Problem is I already have 3 another dataSources defined, but I don't want to use any of them in springBatch. I've checked default implementation DefaultBatchConfigurer and if it is not able to find dataSource it will do exactly what I want. Problem is I've 3 of them and dont want to use any. Please dont suggest to use hsql or other in memory DB as I dont want that. Nandish I got around this problem

How does one open a Reader when implementing ItemReader in a Spring Batch project?

人走茶凉 提交于 2019-12-05 01:50:34
问题 In a Spring Batch project I need to compose a record out of multiple lines. I'm implementing ItemReader to accumulate multiple lines before returning an object. After working through several example projects I have pieced this together but I am faced with a ReaderNotOpenException . I have triple checked the path to the file is correct. When I debug the delegate contains the resource and file path from my configuration file. Any help appreciated. Config file: <bean id="cvsFileItemReader" class

Spring batch: Retry job if does not complete in particular time

孤人 提交于 2019-12-05 01:09:56
问题 I am working on a Spring batch application where I have used RetryTemplate with SimpleRetryPolicy . In this application, ItemProcessor usually takes 30-35 mins to complete a particular task. But sometimes, it takes from than 2hrs to complete that same task. Is there a way to retry my ItemProcessor , if the assigned task is not completed within given time period? I am looking for some Java/Spring in-build functionality instead of writing my own timeout logic. 回答1: You can define transactional

Spring Batch JpaItemWriter vs HibernateItemWriter and why HibernateTransactionManager is needed when HibernateItemWriter is used

我只是一个虾纸丫 提交于 2019-12-05 00:50:21
问题 I'm working on Spring Batch with Spring Boot project. My question is, why HibernateTransactionManager and SessionFactory from LocalSessionFactoryBean are needed when I use HibernateItemWriter as below? Application.java import java.util.Properties; import javax.sql.DataSource; import org.hibernate.SessionFactory; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure

Spring Batch (java-config) executing step after a jobExeuctionDecider

淺唱寂寞╮ 提交于 2019-12-05 00:15:28
问题 I'm trying to configure a Flow in spring batch using java-config, this flow basically has to do this: Execute a init step(which adds a record in the database), then execute a decider to check file existence, 2.1. IF the files exists it will execute the load job (which is another flow with a bunch of steps in parallel) Execute a finish step (which adds a record in the database), this should always run, even if 2.1 was not executed. I tried to do this configuration, but the finish step never

how to best approach to use spring batch annotation or xml files ?

时间秒杀一切 提交于 2019-12-04 22:29:13
firstly, thanks for attention,in my spring batch project defined many jobs , for example: <batch:job id="helloWorldJob1" job-repository="jobRepository"> <batch:step id="step1" > <batch:tasklet> <batch:chunk reader="itemReader1" writer="itemWriter1" processor="itemProcessor1"> </batch:chunk> </batch:tasklet> </batch:step> </batch:job> <batch:job id="helloWorldJob2" job-repository="jobRepository"> <batch:step id="step1" > <batch:tasklet> <batch:chunk reader="itemReader2" writer="itemWriter2" processor="itemProcessor2"> </batch:chunk> </batch:tasklet> </batch:step> </batch:job> <batch:job id=

What's the best way to pass a huge collection to a Spring Batch Step?

十年热恋 提交于 2019-12-04 22:13:26
Use case: A one-time read of data set X (from database) into a Collection C. [Collection size could be say 5000] Use Collection C to process/enrich items in a Spring Batch Step (say enrichStep) If C is much greater than what can be passed via ExecutionContext, how can we make it available in the ItemProcessor of the enrichStep? Luca Basso Ricci In your enrichStep add a StepExecutionListener.beforeStep and load your huge collection in a HugeCollectionBeanHolder bean. In this way you will load collection only once (when step start or re-start) and without persist it into execution context. In

Hibernate batch insert, batch update

与世无争的帅哥 提交于 2019-12-04 21:44:04
I have dao which basically inserts a record into a table using hibernate, this dao is marked by @Transactional annotation with propogation-NESTED , and I have service which makes some other stuff and then invokes my dao. My service is also annotated with @Transactional with propagation-REQUIRED . I call service in a loop. Does my inserts on my dao works in batch or one by one? How can I be sure that they work in batch? Does hibernateTransaction manager manage batch inserts? I am using Oracle DB. I have set following property and my performance increased; hibernate.jdbc.batch_size=50 I am no

Connecting to both spring-batch and application database using spring-boot

南笙酒味 提交于 2019-12-04 20:24:54
Spring batch had it's own database schema. My application has it's own database schema. I want to keep these separated into different databases so the spring-batch tables are not inside my applications database. By default spring-boot only supports connection to a single database. How do I configure it so that all spring-batch related operations go into the spring-batch database and all my own code goes into my applications database? I am using the latest spring-boot 1.2.2. Well this is how I did it. In application.properties ### Database Details datasource.app.driverClassName=oracle.jdbc