'Considerations for writing data to database in SpringBatch ItemProcessor

We have a batch application which would reuse existing code to write data to database and it's easy to put this code in ItemProcessor if we don't want to write custom ItemWriter. As all reader/processor/writer logic are actually in one transaction for one data chunk, it seems this is doable. And actually this has another benifit that it's easy to handle exceptions with using try/catch in processor logic. The questions are about this design pattern -- writing data to db in ItemProcess logic:

  1. is this pattern prohibited or allowed?
  2. what's the considerations for this kind of design? e.g. considerations related with transactions, retry comparing with putting writing logic in ItemWriter.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source