spring-batch

Spring Batch MultiResourceItemReader resources reference from another class

送分小仙女□ 提交于 2019-12-12 23:03:52
问题 Is there a way to customize the MultiResourceItemReader Resources other than getting the value from JobParameters or using the Value tag? I tried the following but it did not work. <bean id="ItemReader" class="org.springframework.batch.item.file.MultiResourceItemReader" scope="step"> <property name="resources" ref="fileResources" /> <property name="delegate" ref="flatFileItemReader" /> </bean> <bean id="fileResources" class="com.app.batch.fileloader.file.FileResources" /> <bean id=

Spring Batch integration Java DSL and RunIdIncrementer not incrementing

拈花ヽ惹草 提交于 2019-12-12 22:14:44
问题 I have a spring boot/integration/batch which will run and poll files on SFTP. I'd like to be able to eventually relaunch a job (could be because application has been restarted or because for some reasons we received the same file again) with the same parameters (same file basically) using RunIdIncrementer defined on Job's Configuration. Unfortunately run.id=1 doesn't increment and I get a JobInstanceAlreadyCompleteException JOB configuration @Autowired private JobBuilderFactory jobBuilders;

Using JobLaunchingGateway with spring-batch and spring-integration throwing DestinationResolutionException

孤人 提交于 2019-12-12 21:13:52
问题 I want to scan a directory periodically for files matching a specific pattern and launch a job for the found file. @Configuration @EnableBatchProcessing public class BatchConfiguration { private final JobBuilderFactory jobBuilderFactory; private final StepBuilderFactory stepBuilderFactory; @Autowired public BatchConfiguration(final JobBuilderFactory jobBuilderFactory, final StepBuilderFactory stepBuilderFactory) { this.jobBuilderFactory = jobBuilderFactory; this.stepBuilderFactory =

Spring batch tables in a different schema

眉间皱痕 提交于 2019-12-12 20:25:19
问题 I want to use a different schema to save Spring Batch tables. I can see that my new datasource in set in the JobRepositoryFactoryBean . But still the tables are been created in the other shcema where I have business tables. I read soemwhere that I can use dataSource.setValidationQuery to alter the schema, but still doesn't work. I can solve this. Below is the JobRepositoryFactoryBean and Datasource prop. @Bean @Qualifier("batchDataSource") protected JobRepository createJobRepository() throws

Parsing several csv files using Spring Batch

偶尔善良 提交于 2019-12-12 18:39:30
问题 I need to parse several csv files from a given folder. As each csv has different columns, there are separate tables in DB for each csv. I need to know Does spring batch provide any mechanism which scans through the given folder and then I can pass those files one by one to the reader. As I am trying to make the reader/writer generic, is it possible to just get the column header for each csv, based upon that I am trying to build tokenizer and also the insert query. Code sample public

Spring Batch Reader for distributed DB2 database

人盡茶涼 提交于 2019-12-12 18:26:05
问题 I am trying to write a job using Spring batch framework. Job needs to get data from a clustered db2 database, call some logic on each fetched record and then store transformed data in same db ( different table than from where it was read). I am trying to write step1 as below, @Bean public Step step1(StepBuilderFactory stepBuilderFactory, ItemReader<RemittanceVO> reader, ItemWriter<RemittanceClaimVO> writer, ItemProcessor<RemittanceVO, RemittanceClaimVO> processor) { return stepBuilderFactory

Spring batch with scoped beans and AllowBeanDefinitionOverriding=false

China☆狼群 提交于 2019-12-12 16:30:36
问题 I want to use scoped spring batch beans <bean id="processor" class="com.example.Processor" p:type="#{jobParameters['type']}" scope="step"/> and AllowBeanDefinitionOverriding = false GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.setAllowBeanDefinitionOverriding(false); context.load("myResource.xml", "otherResource.xml"); context.refresh(); How to avoid BeanDefinitionStoreException with Spring version 4.2.4.RELEASE Exception in thread "main" org

spring batch: processor called twice after skip

怎甘沉沦 提交于 2019-12-12 16:28:59
问题 I have a defined a chunk with commit-interval as 10, skip-limit as 10. A processor class manipulates a field by applying some arithmetic operations. In processor class exception occurs for one of the records (say 6th record). After this, once again records from 1 to 5 are processed, 6th is skipped, 7-10 are processed and written to a XML (a custom XML writer class). Since the processor processes 1-5 records twice, the expected field value is wrong as it is calculated twice. Can you please

Spring Batch - late binding of commit interval not working with skip policy

倖福魔咒の 提交于 2019-12-12 16:20:28
问题 I'm trying to use the late binding on the commit-interval attribute of a chunk. When the chunk doesn't contain a skip-policy or retry-policy, it works fine but as soon as a skip-policy is added (or even a retry-policy), the commit-interval is not taken into account and the batch works as if the commit-interval is set to 1. The weird thing is, when the commit-interval is hard coded, it works fine... So this configuration works fine : <chunk reader="multiAccuseReceptionItemReader" processor=

Accessing Beans outside of the Step Scope in Spring Batch

自闭症网瘾萝莉.ら 提交于 2019-12-12 15:13:21
问题 Is it possible to access beans defined outside of the step scope? For example, if I define a strategy "strategyA" and pass it in the job parameters I would like the @Value to resolve to the strategyA bean. Is this possible? I am currently working round the problem by getting the bean manually from the applicationContext. @Bean @StepScope public Tasklet myTasklet( @Value("#{jobParameters['strategy']}") MyCustomClass myCustomStrategy) MyTasklet myTasklet= new yTasklet(); myTasklet.setStrategy