spring-batch

Spring batch - One transaction over whole Job

让人想犯罪 __ 提交于 2019-12-18 05:07:15
问题 I am using Spring-Batch to execute a batch that creates some objects in the database, creates a file from these objects and then sends the file to a FTP server. Thus, I have 2 steps : One that reads conf from DB, insert into the DB and creates the file ; the second sends the file to the FTP server. The problem is when there is a problem with the FTP server, I can't rollback the transaction (to cancel the new inserts into the DB). How can I configure my Job to use just one transaction over the

Spring Batch : How to use spring batch to read file from sftp server and save it into database?

蹲街弑〆低调 提交于 2019-12-18 05:07:07
问题 My current project is based on Spring Batch and Spring integration. My goal is using Spring Batch to execute job flow steps: read file from SFTP server(step1). decrypt the file(step2). save the file into database(step3). I want to divide this into steps queue(read from sftp, decrypt, write to db). And I also need to save the file, transfer start time, transfer end time, file size into DB. Some days ago, I used Spring integration to poll file from sftp server and then send it to Spring batch

Grid Size in Spring batch

此生再无相见时 提交于 2019-12-18 04:18:28
问题 I have batch job which reads data from bulk files, process it and insert in DB. I'm using spring's partitioning features using the default partition handler. <bean class="org.spr...TaskExecutorPartitionHandler"> <property name="taskExecutor" ref="taskExecutor"/> <property name="step" ref="readFromFile" /> <property name="gridSize" value="10" /> </bean> What is the significance of the gridSize here ? I have configured in such a way that it is equal to the concurrency in taskExecutor. 回答1:

How is the skipping implemented in Spring Batch?

不想你离开。 提交于 2019-12-18 04:08:44
问题 I was wondering how I could determine in my ItemWriter , whether Spring Batch was currently in chunk-processing-mode or in the fallback single-item-processing-mode. In the first place I didn't find the information how this fallback mechanism is implemented anyway. Even if I haven't found the solution to my actual problem yet, I'd like to share my knowledge about the fallback mechanism with you. Feel free to add answers with additional information if I missed anything ;-) 回答1: The

how to select which spring batch job to run based on application argument - spring boot java config

[亡魂溺海] 提交于 2019-12-18 02:50:39
问题 I have two independent spring batch jobs in the same project because I want to use the same infrastructure-related beans. Everything is configured in Java. I would like to know if there's a proper way to start the jobs independent based for example on the first java app argument in the main method for example. If I run SpringApplication.run only the second job gets executed by magic. The main method looks like: @ComponentScan @EnableAutoConfiguration public class Application { public static

How to write a spring batch step without an itemwriter

这一生的挚爱 提交于 2019-12-18 02:47:21
问题 I am trying to configure a spring batch step without an item writer using below configuraion. However i get error saying that writer element has neither a 'writer' attribute nor a element. I went through the link spring batch : Tasklet without ItemWriter. But could not resolve issue. Could any one tell me the specific changes to be made in the code snippet I mentioned <batch:job id="helloWorldJob"> <batch:step id="step1"> <batch:tasklet> <batch:chunk reader="cvsFileItemReader" commit-interval

How should I use .tasklet() / .chunk() to finish job succesfully?

╄→гoц情女王★ 提交于 2019-12-17 21:59:31
问题 I use Spring Batch for cloning table from source to target database. The job is started manually from service layer using jobLauncher with passing parameters. Everything is fine, but using current configuration (below) with .chunk(10) in step description I have only 10 rows cloned and Caused by: java.sql.SQLException: Result set already closed exception. How to describe step properly just to finish read->write the whole table from source to target DB? @Configuration @EnableBatchProcessing

Spring Boot Batch ResourcelessTransactionManager DataSourceProperties$DataSourceBeanCreationException

為{幸葍}努か 提交于 2019-12-17 21:22:33
问题 I'm trying to setup a spring boot batch project that uses a ResourcelessTransactionManager transaction manager using Java Configuration, but I'm having no luck. The reason I am trying to do this is that I don't want any state persisted, and I'd prefer not to waste memory with hsqldb if I don't want it to begin with. I have an existing Spring Batch project that is not using Spring Boot, and it is working with no persistance and without hsqldb. I'm using this sample project as the base (but

Spring Batch Java Config: Skip step when exception and go to next steps

我怕爱的太早我们不能终老 提交于 2019-12-17 21:07:40
问题 e.g. i have 3 Steps in Job (similar to Step1): @Autowired private StepBuilderFactory stepBuilderFactory; @Bean public Step step1() { return stepBuilderFactory .get("step1") .<String, String> chunk(1) .reader(reader()) .processor(processor()) .writer(writer()) .build(); } How go to Step 2 and 3 even after exception in Step 1? I mean configuration in Java. 回答1: Here is an example on how to configure it when creating a flow. That should be similar to configure it directly with the job builder:

Creating Indices name Dynamically in Elasticsearch using Spring-Data Elasticsearch

ⅰ亾dé卋堺 提交于 2019-12-17 20:57:18
问题 I have a use case where in need to create the indices per month in Elasticsearch. The idea is to create indices on the monthly bases so that they are easy to maintain and can be deleted when expired.For this to achieve i have used the spring-batch and have a monthly job which will create the indices on monthly bases For Elasticsearch-Java integration I have used the Spring-Data Elasticsearch implementation. The problem which i am facing now is, I am not able to figure out how to provide the