SagaData usage for business data

Hello,

Gone through article https://docs.particular.net/nservicebus/sagas/ about Saga, have some query about using SataData.

As per understanding, we can store some unique-id & status property related to saga & different message handled by saga can update SagaData property to update saga state & ultimately close saga once process get completed.

Can we store some business data(like date,int,string columns) which required to send data from saga to other handler for processing ?

Can we store business data containing multiple fields in Json format ? scenario for this is,
we are using aggregator pattern (https://www.enterpriseintegrationpatterns.com/patterns/messaging/Aggregator.html) to aggregate Json data(which added as SagaData property) from multiple message & aggregate them & send one message from saga

Note : 1. In any of the case we are not intent to query saga data from outside the saga
2. Once saga completed, we don’t intent to store that data for any future use so its OK if we loose all SagaData once saga get completed.
3. Using NSB 7 & SQL transport, using SQL for saga persistence
.

Hi @Nirav

Some comments below

  • Yes and if you want to complete Saga (clear Saga instance) you have to call this.MarkAsComplete() method
  • Sure, this is the Saga purpose, self-sufficient component making some part of business policy.
  • I think you have at least two options:

    1. Store all needed data as separate Saga data property:
    SagaData
        int Item1
        string Item2
        bool ItemN
    
    1. Store all needed data as JSon’s in string Saga data properties:
    SagaData
        string JSon1
        string JSon2
        string JSonN
    

    but you have to test if it’s good for your scenario.

  • :+1:
  • It’s depends on the scenario. If there is no need Saga data anymore when policy finished (as in your scenario) then it’s good (and often) practice to complete Saga (remove Saga instance data). Sometimes data could by store for some history reports and sometimes Saga can live forever but this depends on the design of the policy.

Hope this help.