Copyl Logo

Saga pattern for microservices

Use this pattern and our tool to manage transactions that spans over multiple services.

What is Saga pattern for microservices?

A Saga can rollback a transaction even if it spans over multiple independent microservices. Learn more about the saga pattern and how Copyl Microservice Management helps you with this best practise.

Microservice Saga Pattern described

Design the saga in Copyl's graphical workflow interface. Set up each local transaction and a corresponding compensating transaction that will roll back the state of the object if needed.

A dynamic saga in Copyl will automatically give you a SignalR/websocket connection that sends a signal to your user's browser with status when the saga has finished. This can take milliseconds or hours, depending on your logic.

Copyl Saga Management is a low-code development platform (LCDP) to orchestrate the distributed transactions.

Error Management for Microservices

Configure what should happen when one of your API's method reports an error. Choose between rollback, retry, stop or choose another method.

Timout handling

Just like handling errors you can also set timeouts on your microservice methods and handle what to upon timeout.

Keep the client updated on progress

Copyl communicates with the user in all the steps of an transaction in your Saga. You configure the status in the API and Copyl transports it to the user.

Design considerations for Microservice Sagas

The Microservice Saga process in Copyl

Each step in the Saga transaction has a compensating action that starts upon error in the transaction.

When designing the API and the Saga structure there are some things to consider.

The Saga will do each request anonymously. You can add headers to the request but cannot run as a user request with jwt.

The Saga will have inparameters and then keep track of all data that are returned from each request in the transaction. This data can be used for other requests in the same transaction. You need to plan for all the data that is needed in the requests and their compensating actions when you design the api.