records for springbatch - about one read two different processor and insertOrUpdate to two different writer
Where is the answer about this title?
How to make a great construct for this title?
The answer is:
One reader
One Processor but return a super class Object of A type and B type data
the one processor translate one data to two different values
but classifier this values to different writers
Like the code blows here:
public List<SuperMonitor> process(T item){
List<SuperMonitor> superList = new ArrayList<>();
Future<List<BarMonitor>> barList = translateA(item);
Future<List<FooMonitor>> fooList = translateB(item);
superList.addAll(barList);
superList.addAll(fooList);
return superList;
}
And through the Classifier writers to dispatching the superMonitorList
The classifier instance should be like this blows:
obj instance of BarMonitor -> insert update to bar table
obj instance of FooMonitor -> insert update to foo table
Or
Use the Classifier writer by spring batch provided
SuperClass or SubClass classifier modules
本文来自博客园,作者:ukyo--夜王,转载请注明原文链接:https://www.cnblogs.com/ukzq/p/15340272.html