Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Transactions to ensure consistency across 2 REST services?

I have 2 REST apis where I "persist" data, in a "transaction". I'm curious to hear suggestions on how to ensure that if the 2nd one has trouble the first one could be "rolled back".

I currently have a retry loop and if that fails I send a delete to the first call.

It works fine, I was just curious if it is possible to use spring transactions to handle this.

For that matter, are there other options?

like image 473
Douglas Ferguson Avatar asked Sep 28 '12 12:09

Douglas Ferguson


1 Answers

It would be very interesting and useful if something like this was possible, but I don't think it could be possible since there is no standard API for commits/rollbacks with REST APIs as there is with the JDBC API. With Spring, you could never simply mark a method as @Transactional since Spring would have no idea how to "roll back" anything you did over a REST call without having to explicitly state it.

like image 103
matt b Avatar answered Oct 06 '22 06:10

matt b