How ACID works in a restful micro-service architecture

J Brain :

I'm pretty new at implementing microservice architecture and this question is breaking my mind

How a microservice architecture address transactional mechanism between different end-points calls.

An example is banking services based on a microservice architecture basically, the banking operation is for different calls to different services to complete a transaction, if one of them fails, then there is no way to eliminate the partial process, I do not know if there is any mechanism to solve this problem

create a payment

POST /payments/customer/10/payment/100/

debit money from the account

PUT /customers/10/accounts/20

Send a customer notification

POST /alerts/customers/10

Matt Timmermans :

The answer is that your API just doesn't expose any methods that let you create an invalid state.

Each method has to do a complete and valid transaction. Instead of having methods to add and remove money from accounts, for example, you have methods that transfer money between accounts. Any record keeping or notifications that must occur when you transfer money has to be done (or at least queued up) by those methods, too.

Sometimes this requires you to create special "valid" states for transactions that you might otherwise consider to be incomplete. When you're reserving seats in theater, for example, there is a state where your seats are reserved until some time (5 minutes or so) when you haven't paid for them.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=81185&siteId=1