A transaction similar to the logic when using web services

There are several update strings that can be performed using web service calls. These items must be transactional; they must be done if and only if everything can be done.

I cannot change web services. I can try to change them all, if one of them doesn't work, I changed the previous ones. This simple slution is pretty ugly.

Is there a more elegant approach to this problem?

note: I am using JavaEE, SOAP, Spring MVC.

+3


source to share


2 answers


we have @TransactionAttribute for different purposes (method and class). If you apply this annotation to a class with the appropriate TransactionAttributeType (Constants), then this transaction strategy will apply to all methods within that class, that is, you can store all calls in your update statements in this class and inject this class where you have your webservices, so if even one update call fails it will rollback



+1


source


You can write a Transactional class that uses Apache HTTP utils to invoke these web services one by one. (This class must have @Transactional annotation)



+1


source







All Articles