I have a Spring Batch application. My Spring batch application consists of 2 steps.
- Extract csv data, add into Records tbl
- Extract Records tbl rows, parse into Food tbl based on data validation.
Step 2 is done using tasklets.
I need to process Records row tbl and no matter whether it is validated or not, the current DateTime would be added back into the Records row.
a. Fails validation, DateTime + error code would also be added into the Records row.
b. Passes validation, DateTime added into Records row. Row would also be added into Food tbl.
In step 2, I have a databaseReader and a databaseWriter. Where do I implement my business logic to check whether validation is pass/fail? It would be calling from my service classes.
I was thinking that my databaseWriter could call add/update/delete methods from my service class. If there's any error, my databaseWriter would catch it. Based on the error thrown by my service class, my databaseWriter would decide what error code + DateTime to parse back into the Record row.
What are your thoughts? Is this a good implementation?