Reputation: 13
I'm newbie in spring batch and I can't determinate what pattern for reader I would need to use. I need to create the class WSRequestClass
and send it to SOAP web service.
public class WSRequestClass{
private String data1;
private String data2;
private String data3;
private String data4;
private List<ClassB> dataList;
}
To create WSRequestClass
is necessary:
data1
and data2
from table A.data3
and data4
from table B.The List<ClassB>
should be create from more complex flow. First I get data from query from table C, but the result of this query is a List<ClassA>
. I need process each item of List<ClassA>
and convert it to ClassB
, where some attributes are calculated from ClassA
. (Chunk pattern but without writer).
public class ClassA {
private Date date;
private BigDecimal amount1;
private BigDecimal amount2;
private String data;
//getters & setters
...
}
public class ClassB {
private Date date;
private BigDecimal amount1;
private BigDecimal amount2;
private BigDecimal amount3;
private BigDecimal amount4;
private String data1;
private String data2;
//getters & setters
...
}
I have found multiple examples for simples chunk pattern and tasklets, but none follows this structure. This job use java configuration and JdbcTemplate for queries. The development of the web service call it's done, my only issue is that I have to read from multiple tables and read efficiently the list, transform each item to ClassB
and set to WsRequestClass
.
Please guide me with the pattern to use, because common ItemReader
not work for me, and I don't know how implement the custom reader that allow me do what I want.
Upvotes: 1
Views: 2641
Reputation: 21503
I think you're going about this wrong. There is a pattern in batch processing called the driving query pattern. In it, your reader reads essentially the keys for the objects. You then use processors to fill in the additional information. You can read more about this pattern in the Spring Batch documentation here: https://docs.spring.io/spring-batch/trunk/reference/html/patterns.html#drivingQueryBasedItemReaders
Upvotes: 1