views:

25

answers:

2

Hi, 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

+1  A: 

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.

Bozho
A: 

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.

Michael Borgwardt
I finally fixed using the JTA classes XAResource, Xid and XConnection =)
Wando