itemwriter

Spring Batch : One Reader, composite processor (two classes with different entities) and two kafkaItemWriter

不打扰是莪最后的温柔 提交于 2021-02-11 14:51:38
问题 ItemReader is reading data from DB2 and gave java object ClaimDto . Now the ClaimProcessor takes in the object of ClaimDto and return CompositeClaimRecord object which comprises of claimRecord1 and claimRecord2 which to be sent to two different Kafka topics. How to write claimRecord1 and claimRecord2 to topic1 and topic2 respectively. 回答1: Just write a custom ItemWriter that does exactly that. public class YourItemWriter implements ItemWriter<CompositeClaimRecord>` { private final ItemWriter

Spring Batch : One Reader, composite processor (two classes with different entities) and two kafkaItemWriter

笑着哭i 提交于 2021-02-11 14:51:05
问题 ItemReader is reading data from DB2 and gave java object ClaimDto . Now the ClaimProcessor takes in the object of ClaimDto and return CompositeClaimRecord object which comprises of claimRecord1 and claimRecord2 which to be sent to two different Kafka topics. How to write claimRecord1 and claimRecord2 to topic1 and topic2 respectively. 回答1: Just write a custom ItemWriter that does exactly that. public class YourItemWriter implements ItemWriter<CompositeClaimRecord>` { private final ItemWriter

How to write the output from DB to a JSON file using Spring batch?

可紊 提交于 2021-01-29 05:08:35
问题 I am new to spring batch and there is a requirement for me to read the data from DB and write in to JSON format. whats the best way to do this ? Any api's are there? or we need to write custom writer ? or i need to user JSON libraries such as GSON or JACKSON ? Please guide me... 回答1: To read data from a relational database, you can use one of the database readers. You can find an example in the spring-batch-samples repository. To write JSON data, Spring Batch 4.1.0.RC1 provides the

Error with Spring batch Classifier Composite Item Writer

三世轮回 提交于 2020-06-17 12:58:59
问题 I have to basically produce multiple xml files for each file_id per currency ( ie. usd,zar ect) these transactions are all in 1 DB table. Do I create a composite writer for each currency and on my Item Processor I filter for each different currency that I read from the DB. or Can I use multiple steps for each currency per file_id ? I have been struggling to find a Springbatch solution around this. The filename resource will be different for each file and currency. For example I can recieve

Error with Spring batch Classifier Composite Item Writer

落花浮王杯 提交于 2020-06-17 12:58:34
问题 I have to basically produce multiple xml files for each file_id per currency ( ie. usd,zar ect) these transactions are all in 1 DB table. Do I create a composite writer for each currency and on my Item Processor I filter for each different currency that I read from the DB. or Can I use multiple steps for each currency per file_id ? I have been struggling to find a Springbatch solution around this. The filename resource will be different for each file and currency. For example I can recieve

Error with Spring batch Classifier Composite Item Writer

ぃ、小莉子 提交于 2020-06-17 12:58:23
问题 I have to basically produce multiple xml files for each file_id per currency ( ie. usd,zar ect) these transactions are all in 1 DB table. Do I create a composite writer for each currency and on my Item Processor I filter for each different currency that I read from the DB. or Can I use multiple steps for each currency per file_id ? I have been struggling to find a Springbatch solution around this. The filename resource will be different for each file and currency. For example I can recieve

Spring-Batch: Item writer for Parent-Child relationship

泪湿孤枕 提交于 2020-04-17 22:53:20
问题 I have written a item processor which returns the list of Objects. This object needs to be split into 2 data base table (One parent and a child). One header row and for this corresponding header ID we have child rows associated in child table. I have used ListUnpackingItemWriter example to solve list problem. I have used CompositeItemWriter to split the result into 2 writer, Now I need to split each one for header and child table. Now each writer has same number of rows. IS there a better way

How to use Classifier with ClassifierCompositeItemWriter?

我只是一个虾纸丫 提交于 2020-01-10 06:08:08
问题 have trouble implementing a ClassifierCompositeItemwriter... I am reading a basic CSV File and i want to write them do a database. Depending on the data (Name + Name1) either write it to a simple ItemWriter or use a compositeItemwriter (that writes to two different Tables)... This is my : ClassifierCompositeItemwriter see > Error Message below public ClassifierCompositeItemWriter<MyObject> classifierCompositeItemWriter() { ClassifierCompositeItemWriter<MyObject> writer = new

Spring Batch: One reader, multiple processors and writers

无人久伴 提交于 2019-12-03 08:42:28
问题 In Spring batch I need to pass the items read by an ItemReader to two different processors and writer. What I'm trying to achieve is that... +---> ItemProcessor#1 ---> ItemWriter#1 | ItemReader ---> item ---+ | +---> ItemProcessor#2 ---> ItemWriter#2 This is needed because items written by ItemWriter#1 should be processed in a completely different way compared to the ones written by ItemWriter#2. Moreover, ItemReader reads item from a database, and the queries it executes are so computational

Spring Batch: One reader, multiple processors and writers

一曲冷凌霜 提交于 2019-12-02 22:28:41
In Spring batch I need to pass the items read by an ItemReader to two different processors and writer. What I'm trying to achieve is that... +---> ItemProcessor#1 ---> ItemWriter#1 | ItemReader ---> item ---+ | +---> ItemProcessor#2 ---> ItemWriter#2 This is needed because items written by ItemWriter#1 should be processed in a completely different way compared to the ones written by ItemWriter#2. Moreover, ItemReader reads item from a database, and the queries it executes are so computational expensive that executing the same query twice should be discarded. Any hint about how to achieve such