Question

I am currently writing my first saga and I am a bit puzzled with the read model. Let's explain it with an example :

I have three bounded context : programming, contractor and control. Each of them has its specific read model.

worflow :

  • programming send an event "JobScheduled"
  • Saga receives this event and tell contractor to "schedule the Work".
  • When done the Contractor send an event "JobDone".
  • The Saga receives this event and tell Control to "Start Control Period".

Everything turns out to be fine here. We are on the write side so we are passing vital information for the process to go on.

My question comes with unnecessary information. Let's say that the event "JobScheduled" has a note field : "test note", and before this job is done this field is changed to "test note important". This change is of no importance to the workflow as described, but it is important that the contractor might see the change in the field when looking at the read model of the contractor bounded context.

Am I to give to the saga the event NoteChanged and process it or should I create a projection which directly listens to this event in my contractor bounded context?

To give it to the saga looks to me like unnecessary work because I am only updating readmodel here there is no domain involved in the change.

On the other hand, making a direct coupling between the two bounded context removes one of the assets of sagas which is the possibilty of modifying the interactions the bounded context have between each other in the workflow.

Thanks for your reading,

Was it helpful?

Solution

If changing the note is important, it should be modelled explicitly. This can be accomplished by introducing an Event just like you already did.

If said Event has any relevancy to the process, it can be handled by a Saga. If it only needs to be represented in different Read Models, then just handling it in their respective projections should be fine.

One context may very well listen to and handle the events of another one, even across application boundaries. At least this is how cross-context integration should work in an event centric architecture.

OTHER TIPS

Personally I would send a command "Change note", because I see it like an information that have to be saved in the event stream of your aggregate. Than if your saga don't "feel" to tell anyone about this command, or simply give the information to an handler that quietly update your read model I guess is fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top