Transactions in microservices

后端 未结 6 1419
孤街浪徒
孤街浪徒 2021-02-07 00:52

I have read some articles about microservices architecture, but no one takes the topic of transaction. All that they says that this is hard to do it. Maybe someone can describe

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-07 01:38

    The first raw thing which came to my mind after reading this question is to create every add api with a delete api with ,lets say, an extra boolean flag delFlag.

    boolean flag delFlag;

    For POST, it will be 0. For DELETE, it will be 1.

    Now you maintain a Transaction Manager which is a super service to all your micro services. In this service maintain the calling queue of all the services and the APIs. As and when a service fails, get the calling api and call the delete method of that service and undone whatever u have done.

    PS- Just a raw thought. Correct me if you think it is wrong.

提交回复
热议问题