spring-batch

Spring Batch documentation about chunk-oriented step versus reality?

为君一笑 提交于 2019-12-17 19:49:11
问题 On the documentation of Spring Batch for configuring a step a clear picture describes how the read process and write is performed. read process ... read process // until #amountOfReadsAndProcesses = commit interval write Corresponding (according to the doc): List items = new Arraylist(); for(int i = 0; i < commitInterval; i++){ Object item = itemReader.read() Object processedItem = itemProcessor.process(item); items.add(processedItem); } itemWriter.write(items); However when I debug and put a

Read one record/item and write multiple records/items using spring batch

筅森魡賤 提交于 2019-12-17 19:27:47
问题 I did some searching but couldn't find any sample/example. I've a requirement where geo coordinates from one table (input) are read, processed to generate POI's associated to coordinate. So one geo coordinate will result in one or more POI's that needs to be inserted into another table (output). I'm currently using a JdbcCursorItemReader and JdbcBatchItemWriter to read one item/record and write one item/record. There is also an ItemProcessor that generates the POI's for a give geo coordinate.

Multiple itemwriters in Spring batch

前提是你 提交于 2019-12-17 18:26:06
问题 I am currently writing a Spring batch where I am reading a chunk of data, processing it and then I wish to pass this data to 2 writers. One writer would simply update the database whereas the second writer will write to a csv file. I am planning to write my own custom writer and inject the two itemWriters in the customItemWriter and call the write methods of both the item writers in the write method of customItemWriter. Is this approach correct? Are there any ItemWriter implementations

Spring batch scope issue while using spring boot

谁都会走 提交于 2019-12-17 15:52:08
问题 I'm having Standalone spring batch job. This works perfectly fine when in JUNIT @RunWith(SpringJUnit4ClassRunner.class) //@SpringApplicationConfiguration(classes = KPBootApplication.class) @ContextConfiguration(locations={"classpath:kp-sb.xml"}) public class KPBootApplicationTests { private final static Logger LOG=LoggerFactory.getLogger(KPBootApplicationTests.class); @Autowired ApplicationContext context; @Autowired private JobLauncher jobLauncher; @Autowired private Job job; @Test public

Spring Batch skip exception for ItemWriter

元气小坏坏 提交于 2019-12-17 09:54:26
问题 I'm trying to use Spring Batch 2.2.5 with Java config. Here is the config that I have: @Configuration @EnableBatchProcessing public class JobConfiguration { @Autowired private JobBuilderFactory jobBuilder; @Autowired private StepBuilderFactory stepBuilder; @Bean @Autowired public Job processDocumentsJob() { return jobBuilder.get("processDocumentsJob") .start(procesingStep()) .build(); } @Bean @Autowired public Step procesingStep() { CompositeItemProcessor<File, DocumentPackageFileMetadata>

Spring Batch skip exception for ItemWriter

核能气质少年 提交于 2019-12-17 09:53:25
问题 I'm trying to use Spring Batch 2.2.5 with Java config. Here is the config that I have: @Configuration @EnableBatchProcessing public class JobConfiguration { @Autowired private JobBuilderFactory jobBuilder; @Autowired private StepBuilderFactory stepBuilder; @Bean @Autowired public Job processDocumentsJob() { return jobBuilder.get("processDocumentsJob") .start(procesingStep()) .build(); } @Bean @Autowired public Step procesingStep() { CompositeItemProcessor<File, DocumentPackageFileMetadata>

Spring Batch ORA-08177: can't serialize access for this transaction when running single job, SERIALIZED isolation level

故事扮演 提交于 2019-12-17 09:33:48
问题 I am getting this exception with SERIALIZED isolation level on JobRepository in Spring Batch: org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into DATAFEED_APP.BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction ; nested exception is java.sql.SQLException: ORA-08177: can't serialize access for this transaction at org.springframework.jdbc.support

Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/batch]

﹥>﹥吖頭↗ 提交于 2019-12-17 07:19:07
问题 Situation I am using Spring Batch to build an Accumulative Snapshot for our Data Warehouse and I am having a configuration roadblock that I cannot figure out. I have created a Simple Spring Batch Project with STS (SpringSource Tool Suite 2.8.1) using the Spring Template Project . These were my two xml configuration files created: launch-context.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema

Spring: Generic RowMapper for dynamic queries

混江龙づ霸主 提交于 2019-12-14 04:19:31
问题 I am using SpringBatch to read from Oracle and write into ElasticSearch. My code works fine for static query. Example: select emp_id, emp_name from employee_table I have a RowMapper class that maps the values from resultSet with the Employee POJO. My requirement is The query will be inputted by the user. So the query might be as follows select emp_id, emp_name from employee_table select cust_id, cust_name, cust_age from customer_table select door_no, street_name, loc_name, city from address

Spring Batch configuration exception

陌路散爱 提交于 2019-12-14 03:57:36
问题 I have next spring batch configuration class: @Configuration @EnableBatchProcessing public class BatchJobConfiguration { @Autowired private JobBuilderFactory jobBuilderFactory; @Autowired private StepBuilderFactory stepBuilderFactory; @Bean public Step step1() { return stepBuilderFactory.get("step1") .tasklet(new Tasklet() { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) { return null; } }) .build(); } @Bean public Job job(Step step1) throws Exception {