Saga Design Design Question around reusing a use-case

Hello,

We currently have a process that allows an employee in customer service to allow an order to be changed via a backend UI. When the change is completed an nservicebus event is fired ( OrderChangeCompleted Event ).

We have a new requirement in which another system is feeding in data that we would like to automatically perform the same change automatically using a saga without the involvement of a customer service user.

My First Idea, was to reuse the existing application layer service/use-case ( since it’s the same use-case, just automated ). This would allow me to reuse the same logic without duplicating code. My Saga could Send a command to the same nservicebus handler to make the change on the order and subscribe to the same event ( OrderChangeCompleted Event ).

Now comes the problem. If the customer service user is allowed to edit an order any time via the backend UI, how can i differentiate between when the OrderChangeCompleted event occured from the automated process (the saga starting and completing the change ) VS the manual process? For Example, I do not want my saga to execute logic when the manual flow occurs.

Hope this makes sense. Thanks

Hi @behrygood1982,

Welcome back, long time no see!

Assuming that the process the saga performs is more or less the same either it’s user-triggered or auto-triggered, I’d implement the thing using different messages (e.g., ChangeOrderByBackoffice and ChangeOrderByAutomation) to the same saga. Another option is to use the same messages with a property (e.g. bool IsFromAutomation), the downsides are a bunch of “if” statements in the code and the fact that you are effectively routing messages based on message data which can lead to suboptimal design decisions.

If the two processes are a bit different, though, I’d advise creating a different saga entirely.

.m