Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between workflows and sagas

What exactly is the difference between workflows and sagas? What are the pros and cons of each?

Thanks!

like image 930
Ben Avatar asked Jan 16 '23 08:01

Ben


1 Answers

For reference, I'm using the NServiceBus Saga definition here: https://docs.particular.net/nservicebus/sagas/

At the highest level, workflows tend to be modeled as a set of activities invoked in some sequence where the completion of one activity flows directly into the start of the next activity.

Sagas tend to be modeled as a statefull "object" where changes to that state are triggered by discrete messages - the completion of handling one message does not flow directly into the handling of another message.

While both sagas and workflows can be used to model various types of processes, sagas tend to shine when it comes to long-running processes as well as those processes requiring a high degree of consistency (like in a collaborative environment).

like image 118
Udi Dahan Avatar answered Mar 15 '23 21:03

Udi Dahan