elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.45k stars 1.19k forks source link

How to implement Saga pattern using Elsa ? #304

Open zhichkin opened 4 years ago

zhichkin commented 4 years ago

Hi! Would you, please, provide an example on how it is possible to implement Saga pattern using Elsa to orchestrate a couple of web services ?

sfmskywalker commented 4 years ago

I will - it's on my TODO list! I'm a little busy at the moment, so it will take a while before I get to it. But it's very important Elsa supports the Saga pattern and that it's documented.

weare8 commented 4 years ago

I am also interested in that, how can we help and/or start to understand how to add compensate transactions?

jeffdoolittle commented 4 years ago

@sfmskywalker are you saying Elsa already supports this and it just needs to be documented? Or that it also needs to be implemented?

sfmskywalker commented 4 years ago

@jeffdoolittle It's not supported yet; I suspect there are some things that will have to be added to Elsa in order to support the Saga model. For instance, I don't think there's currently a convenient means where one could easily specify what events/messages to block on before continuing. In fact, there are some primitives missing in order to model a workflow as a proper state machine. I haven't put too much thought into it yet, but I was playing with the idea of updating the Connection model to include a list of events to block on. Then if a matching event comes in, execution continues to the connected activity. This is a little bit different than the way things currently work: right now, an activity can suspend workflow execution, and resume when the appropriate event comes in. But in a state machine model, you actually want to suspend workflow execution on a given "state" activity, and not on all of its sibling nodes it connects to.

Long story short, I need to do some thinking. And if anyone has any suggestions, I'm always happy to hear it.

sfmskywalker commented 3 years ago

With 2.0, you can now implement state machine workflows that wait for messages to be received, which should allow you to orchestrate web service invocations and of course sending messages.

sfmskywalker commented 3 years ago

Reopening because we do need a guide for this.

iskandersierra commented 2 years ago

With 2.0, you can now implement state machine workflows that wait for messages to be received, which should allow you to orchestrate web service invocations and of course sending messages.

@sfmskywalker Is there any current example / documentation / guide on implementing state machines? I'm still very new to Elsa libraries and going through the docs and examples yet. I'm very interested on using it on a greenfield project and I'm still gathering all the features and capabilities of different orchestrators to be able to decide which one to use and under which conditions.

Thanks for the huge work you and your community have done here!