Suppose we have a need to receive data from front-end and insert them into three tables, and they have this "foreign key"
relationship.
If we provide front-end three separate POST methods, and they submit all the data in one “submit” action. And these three methods don’t have a step by step work flow like this one
How can we ensure the transaction between the three POST calls?
I’ve checked eXtended Architecture, is there an alternative to do this?
For instance, we have a back-end and front-end like this.
// backend
"/api/insert1"
"/api/insert2"
"/api/insert3"
// frontend
function submit(){
insert1(data1,"/api/insert1")
insert2(data2,"/api/insert2")
insert3(data3,"/api/insert3")
}
If one of the three insert actions fails, what can we do to undo them all?
If we code three extra methods to undo these, it would be a huge work consider it may actually be 100 methods in total. And there’s a chance the user close the app/page before it all finished.
If we use XA three stages we need to store the sqlsession
which also a considerable workload to server.
I feel wrong to put all these data into one POST method.