Reputation: 133
i'm starting to work with Services in Java, and i've been googleing for a while but i still have no clue when is need to handle transactions y several services, e.g. if creating a client uses 3 services, and the third service crash, how can i roll back the 2 previous services? any link, or explanation could help
Upvotes: 0
Views: 204
Reputation: 346270
For this you need distributed transations, which is exactly what the Java Transaction API is for. Application servers like Spring or Java EE's EJB container support JTA and make it very easy to use via annotations or declarative configuration.
Upvotes: 0
Reputation: 597076
If a client needs to call multiple service methods transactionally, then you'd better create a facade class which executes the 3 operations, transactionally.
If the operations require user input in between - don't do it. Such long-running transactions are prime candidates for performance problems and deadlocks.
Upvotes: 1