spring-batch

How to use decider in Spring batch?

て烟熏妆下的殇ゞ 提交于 2019-12-10 12:18:27
问题 I'm new to Spring batch. I've created a decider which returns a FlowExecutionStatus as "YES" / "NO". Based on the FlowExecutionStatus, I need to call step2() or step3(). In my below code, step2() is getting called before decider. How to modify the code so that decider will be called and based on the "FlowExecutionStatus" returned bu the decider, either step2() or step3() should be called. Please help. @Autowired private NumberDecider decider; @Bean public Job NumberLoaderJob() throws

Spring Batch Footer Validation

独自空忆成欢 提交于 2019-12-10 11:55:52
问题 I am using Spring batch for processing a file with a header, detail and footer records. The footer contains the total number of records in the file. If the detail record count dosent match the count in the footer, the file should not be processed. I am using a Custom Line Tokenizer that processes the header, detail and footer record. When the footer record is encountered, if the count dosent match the detail record count, I am throwing an exception. But the problem I am facing is if the chunk

Create tables automatically by calling .sql file in Spring Batch?

牧云@^-^@ 提交于 2019-12-10 11:54:25
问题 I followed many links like Spring Batch Framework - Auto create Batch Table and https://docs.spring.io/spring-boot/docs/2.0.0.M7/reference/htmlsingle/#howto-initialize-a-spring-batch-database, but that doesn't satisfy my requirement In Spring Boot 2.0, how we can call sql file (created manually and have all the schema details) so that Spring Batch can create it manually for us and if schema is already present then skip the execution ? <!-- Create meta-tables --> <jdbc:initialize-database data

read complex json file with spring batch

こ雲淡風輕ζ 提交于 2019-12-10 11:16:32
问题 i have a complex json file( with nested json arrays) structure like this: {"persons":[ {"id":"1", "firstName": "X", "lastName": "X", "infos": [{"address":[{"city": "X", "country": "X"}]}]}, {"id":"2", "firstName": "Y", "lastName": "Y", "infos": [{"address":[{"city": "Y", "country": "Y"}]}]} ]} I want to read each line ( one person) separately So my spring batch configuration is like this <bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step"> <property

Can Spring Batch jobs be configured at run time with dynamic steps?

谁说我不能喝 提交于 2019-12-10 10:53:18
问题 I am looking at Spring Batch 2.0 to implement a pipeline process. The process is listening to some event, and needs to perform a set of transformation steps base on the event type and its content. Spring batch seem to be a great fit. However, going through the documentation, every example have them job and its steps configured in xml. Does the framework support creating jobs during run-time and configuring the steps dynamically? 回答1: the job configuration itself is set before the job runs,

JSR 352 Spring Batch vs. Java EE [closed]

孤人 提交于 2019-12-10 10:06:56
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 months ago . A couple of questions regarding JSR 352, Spring Batch, and Java 1) When would someone use Java to build a batch JSR-352 application over Spring Batch? My initial take is it would require more coding in Java than Spring Batch. 2) Did version 7 of Java EE implement JSR-352? Or did

SpringBatch does rollback though no-rollback-exception-classes are defined

痴心易碎 提交于 2019-12-10 09:55:47
问题 I got the following job: <batch:job id="importCardsJob" job-repository="jobRepository"> <batch:step id="importCardStep"> <batch:tasklet transaction-manager="transactionManager"> <batch:chunk reader="cardItemReader" writer="cardItemWriter" commit-interval="5" skip-limit="10"> <batch:skippable-exception-classes> <batch:include class="java.lang.Throwable" /> </batch:skippable-exception-classes> </batch:chunk> <batch:no-rollback-exception-classes> <batch:include class="job.batch.exceptions

MongoDb equivalent of writer in Spring Batch?

血红的双手。 提交于 2019-12-10 09:50:50
问题 I'm following Spring doc for creating batch service. It implements ItemWriter using JdbcBatchItemWriter , so could you please help me write the MongoDb equivalent of following code using MongoItemWriter ? I found two tutorials using MongoDb, but they use XML files to define beans & seem outdated. @Configuration @EnableBatchProcessing public class BatchConfiguration { // tag::readerwriterprocessor[] @Bean public ItemWriter<Person> writer(DataSource dataSource) { JdbcBatchItemWriter<Person>

Spring Batch how to process list of data before write in a Step

╄→尐↘猪︶ㄣ 提交于 2019-12-10 09:40:58
问题 I am trying to read client data from database and write processed data to a flat file. But I need to process whole result of the ItemReader before write data. For example, I am reading Client from database rows : public class Client { private String id; private String subscriptionCode; private Boolean activated; } But I want to count and write how many user are activated grouped by subscriptionCode : public class Subscription { private String subscriptionCode; private Integer

How can I prevent my Spring Boot Batch application from running when executing test?

半腔热情 提交于 2019-12-10 09:27:18
问题 I have a Spring Boot Batch application that I'm writing integration tests against. When I execute a test, the entire batch application runs. How can I execute just the application code under test? Here's my test code. When it executes, the entire batch job step runs (reader, processor, and writer). Then, the test runs. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = BatchApplication.class)) @TestExecutionListeners({ DependencyInjectionTestExecutionListener