This question has been asked in an interview.
The task is we need to do the following -
1. persisting some data to mysql db
2. persisting same data to oracle db
3. calling third party webservice using same data.
And the condition is either all the three should happen or none . If one fails, we need to roll back all others.
The question was in which layer you will do the implementation.
I told DAO layer for first 2 tasks (persisting to db) and calling webservice from Service layer. But in this case if webservice fails, we cannot rollback db transactions.
So what will be the preferred way of achieving the same and which all layers will be used?