spring-batch

Why Spring Boot Batch job is running just one time?

孤街浪徒 提交于 2019-12-10 08:44:05
问题 I'm using spring boot. I have a batch job which I've implemented with these classes : My main class is : @SpringBootApplication @ComponentScan("com.batch") @PropertySource("classpath:application.properties") public class Application { public static void main(String[] args) { SpringApplication.run(Application.class); } } My scheduler is : @Component @EnableScheduling public class JobScheduler { @Scheduled(fixedRate = 10000) public void runJob() { SpringApplication.run(MyBatchConfig.class); } }

Spring Batch with two different datasource issue

心不动则不痛 提交于 2019-12-10 06:15:15
问题 I have a simple Spring Batch application that's pulling records from a database and just printing the rows to the screen. Just a simple POC application. The application works just fine with Spring Boot 1.2.1.RELEASE but when I updated to 1.2.3.RELEASE I get an error message about "No qualifying bean of type [javax.sql.DataSource] is defined" I'm not sure if this is a Spring Boot issue or Spring Batch issue. Is there way to define the datasource explicitly for the Spring Batch repository? Full

How can I qualify an autowired setter that I don't “own”

 ̄綄美尐妖づ 提交于 2019-12-10 02:21:34
问题 The gist is that the Spring Batch (v2) test framework has JobLauncherTestUtils.setJob with an @Autowired annotation. Our test suite has multiple Job class providers. Since this class is not something I can modify, I'm not sure how I can qualify which job it gets autowired with, which may be different per test. STDOUT [WARN ] [2015.04.15 11:14:42] support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans

PB using JdbcBatchItemWriter with CompositeItemWriter in JAVA code- Spring-Batch

杀马特。学长 韩版系。学妹 提交于 2019-12-10 00:12:55
问题 I have extended the batch service code provided by Official Spring-Batch site - Batch Processing Service and modified the ItemWriter to generate the CSV and to write to the database. I have used CompositeItemWriter to write in both CSV and Database. However the JdbcBatchItemWriter is not working correctly with CompositeItemWriter. The code is shown below. @Bean public ItemWriter<Person> writer(DataSource dataSource) { CompositeItemWriter<Person> cWriter = new CompositeItemWriter<Person>(); //

spring batch : Tasklet without ItemWriter

北城以北 提交于 2019-12-09 20:52:44
问题 I defined my tasklet without ItemWriter like this : <b:tasklet> <b:chunk reader="baseReader" processor="baseProcessor" commit-interval="100" /> </b:tasklet> and i got this error : Configuration problem: The <b:chunk/> element has neither a 'writer' attribute nor a <writer/> element. Do you have any idea ? Thanks 回答1: Well, in a chunk, A reader and a Writer are MANDATORY! however, The ItemProcessor is optional. This is from the official doc : 5.1.1. Configuring a Step Despite the relatively

Reading file from HDFS using Spring batch

三世轮回 提交于 2019-12-09 19:24:35
问题 I've to write a Spring batch which will read a file from HDFS and will update the data in MySQL DB. The source file in HDFS contains some report data, in CSV format. Can someone point me to an example of reading a file from HDFS? Thanks. 回答1: The FlatFileItemReader in Spring Batch works with any Spring Framework Resource implementation: @Bean public FlatFileItemReader<String> itemReader() { Resource resource; // get (or autowire) resource return new FlatFileItemReaderBuilder<String>()

Spring Batch after JVM crash

纵然是瞬间 提交于 2019-12-09 17:25:29
问题 How to restart Jobs after a JVM crash? I was running a lot of Jobs implemented in Spring Batch framework, when my JVM crashed or the system failed. How can I restart these Jobs after failure? 回答1: Basically, you can do as follows: Configure a JobExplorer factory bean in your application context: Configure a JobOperator bean in your applictaion context Query the jobExplorer for distinct job names: jobExplorer.getJobNames() For each job from step (3), query the jobExplorer for unfinished jobs:

Spring Batch @StepScope cannot generate CGLIB subclass

你说的曾经没有我的故事 提交于 2019-12-09 13:46:26
问题 EDIT I created a test project that replicates the issue. It can be found at https://github.com/tomverelst/test-batch. First run the maven command exec:java to start a HSQL database. Then you can run the JUnit test MigrationJobConfigurationTest to load the Spring application context. Original question When starting my Spring Batch application, I get the following exception when Spring is loading my job's configuration: Caused by: org.springframework.aop.framework.AopConfigException: Could not

What is the best way to test job flow in Spring-Batch?

懵懂的女人 提交于 2019-12-09 13:29:50
问题 I've got a complicated batch application, and I want to test that my assumptions about flow are correct. Here's a much simplified version of what I'm working with: <beans> <batch:job id="job1"> <batch:step id="step1" next="step2"> <batch:tasklet ref="someTask1"/> </batch:step> <batch:step id="step2.master"> <batch:partition partitioner="step2Partitioner" step="step2" /> <batch:next on="*" to="step3" /> <batch:next on="FAILED" to="step4" /> </batch:step> <batch:step id="step3" next="step3">

Spring Batch Multi Threading - How to make each thread read unique records?

孤人 提交于 2019-12-09 13:11:38
问题 This question has been asked a lot of times in many forums. But I don't see an answer that fits me. I am trying to implement Multi-threaded Step in my spring batch implementation. Have a staging table with 100k records Want to process it in 10 threads of commit interval 300 per thread- so 3000 records at any point of time. I defined a task executor and referred it inside the step i wanted to multi thread My idea is that first I would get the thread pool size (10) and update the thread_id