Microservices dual-write problem made easy with Oracle Transaction Manager


ABSTRACT*

The article discusses how to solve the microservices dual-write problem using the Oracle Transaction Manager. Dual writing can lead to data inconsistencies and conflicts, which the author notes as a common issue in microservice architectures. With the help of Oracle Transaction Manager, developers can ensure data integrity and reliability across multiple writes. The article provides an in-depth guide on how to implement this solution, making it a useful resource for developers.

(*) Generated by Cohere command-R

CONTENT

Suppose we have a supermarket stores chain and he TPV app has two tasks to complete:

  • Store the ticket in the operational database
  • Send the ticket to a queue for further processing in the data lake

We want consistency, so different kind of solutions can be found in the micro-services patterns literature. But those solutions based in outbox, sagas, CDC and other stuff are complex and pushes the programmer to resolve a transactional problem that should be covered by the application architecture.

For that reason we have Oracle Transaction Manager for Microservices, a component that simplifies the solution.

When the ticket() service is called, the first task it does is telling OTM that a new transaction has started. Then the child services are called by ticket() and transaction information is passed to them transparently. Then, child services register the transaction in OTM as well.

When the parent service evaluates that everything is correct, a commit action is sent to OTM, that consequently sends commit actions to the child services enlisted in the transaction:

In case of something wrong, the parent service sends a rollback action to OTM that echoes the action to children telling them to rollback the operations:

In next post we’ll test some examples.

That’s all folks!!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.