Announcement Announcement Module
Collapse
No announcement yet.
Decide the writer at runtime based on the data of current record being processed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Decide the writer at runtime based on the data of current record being processed

    Hello, I'm relatively new to Spring Batch. I used version 1.X on a Java project for importing flat files into a database. Now I'm using version 2.X to do the same on a different project. Now I have a totally new requirement for importing a flat file into the database. The file has the following format:

    A,10001,Red
    D,30023,Blue
    D,20012,Black

    What is special about this file is the first field. A denotes the record needs to be added to the database. D if it needs to be removed.

    I was digging in the docs trying to find the best way to do it with configuration only but was unsuccessful. Speed on processing the files is important as it will be sort of big so I thought of configuring two jobs, one for the As and one for the Ds but that wouldn't be efficient.

    I did this with Kettle very easy (Kettle is off the table) but ignore if Spring Batch has some way to configure this kind of scenario without writing code.

    Can you please recommend a way to accomplish this using Spring Batch?

  • #2
    .................................................. .................................................. ...........
    How about read the file and split it into three parts D's A's and U's
    Now read each file and Batch delete add and update
    .................................................. .................................................. ........

    Comment


    • #3
      Or you can use dynamic sql based on the operation type in the writer.....but you are doing the write one by one anyways..I will not use Spring Batch.

      Comment

      Working...
      X