0

In a spring batch project I have to implement multiple operations in a writer: call two different APIs and update a local database. The point is: if one of these operations fails I need to restart from the failed one, without repeating the previous.

Should I implement my own custom logic to track what has been done or not or is there anything that spring batch provides out of the box?

I'm aware that if I split these operations in separated steps Spring Batch already provides restartability, but I don't want to create thousands of 'single operations' steps.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Pirulino
  • 758
  • 1
  • 9
  • 20

1 Answers1

0

The closest to what you are looking for that Spring Batch provides is the CompositeItemWriter, which calls delegates in the order they are registered in. However, it does not provide an API to inspect the result of each invocation of the delegates and control their execution flow.

So in your case, you would need a custom writer.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50