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

posted @ 2021-09-26 21:46  ukyo--夜王  阅读(57)  评论(0编辑  收藏  举报