We have implemented the ItemProcessListener and the SkipListener in the Batch job, which is using the Spring batch. We are able to log the skipped items in the database, without creating a separate transaction. But the when the onProcessError method is invoked in the ItemProcessListener, the transaction is rolled back, due to the corresponding Runtime Exception.
We used @Transactional and propagation as REQUIRES_NEW, on the service interface for DB update, but it still rolled back the transaction.
Our objective is to log the exception details in the database whenever there is an error in process or writer components and the batch fails. As explained above, the logging is not working when we fire a DB insert from the onProcessError method or onWriteError method in the overridden listener. The transaction is rolled back.
We tried creating a new transaction using annotation on onProcessError , but it failed. Kindly provide some inputs for the same.
Hope this makes the problem clear.