Using SAGA pattern with Synchronous HTTP request

1.5k views Asked by At

I was looking to understand how Saga Pattern using orchestration works.

In all references that I have found, It seems that each step needs to communicate using a asynchronous communication, like a queue or a event stream hub.

I was thinking if this is really necessary to use asynchronous communication between each step, or could I use a Http synchronous just garanteening that each step is idempotent?

E.g.

I receive a http request that is store in a queue or event stream hub, like Kafka. Then a single consumer, consumes the message and execute a series of synchronous idempotent steps, like a SAGA orchestration mechanism. If one of these steps fail, the message will eventually be reprocessed, so I can compensate a step, if it has failed.

1

There are 1 answers

0
chalda On

For sure the saga pattern does not require the asynchronous communication. For data consistency is important the steps being idempotent (or the framework happens to hide that but the fact holds true) as you declared.

If you want to study one of the synchronous saga pattern implementation which works mostly with HTTP synchronous calls you can read about LRA (Long Running Actions) which is a MicroProfile specification here: https://github.com/eclipse/microprofile-lra/blob/master/spec/src/main/asciidoc/microprofile-lra-spec.adoc

Or/and the blogpost about the spec implementation withing Narayana project: https://jbossts.blogspot.com/2017/12/narayana-lra-implementation-of-saga.html , https://jbossts.blogspot.com/2021/07/how-to-use-long-running-actions-between.html