Spring batch Job read from multiple sources

后端 未结 3 1550
借酒劲吻你
借酒劲吻你 2020-11-29 07:30

How can I read items from multiples databases? I already know that is possible from files.
the following example works for read from multiples files

...
         


        
3条回答
  •  难免孤独
    2020-11-29 08:09

    I suggest a simple workaround that may not be suitable to all cases, but will be useful in many:

    Simply define:

    • 2 readers, one for each database
    • 2 steps
    • one job that contains both 2 steps

    The 2 steps are nearly identical, they reference the same processor and writer, but they have different readers. They will be called consecutively.

    Whether this setup works will depend on the processor and writer (whether they still work correctly when called in different steps). In my case, it was sufficient to set appendAllowed=true to the writer, such that both steps can write to the same file.

提交回复
热议问题