Lately I participated in advanced CQRS training conducted by Greg Young. For about 300€ we spent three days on learning integration patterns and coding under the watchful eye of the author of CQRS pattern. This time, in opposed to his “not advanced” training, the focus was on the long running processes – sagas. To keep post short I’ll only briefly write what we’ve learned.


As I mentioned above, the main part of this training was about sagas. Strictly speaking document sagas. This kind of process will be chosen when we are interested in changes inside one document. If you have a status in your document and have to update it after updating the document then this kind of sagas is definitely for you. It is very important that the document is not an object. It is schema. It’s not strictly structured and doesn’t have to be readable as a whole by every process working on it. It has to be immutable outside the process too.

Each document has its own saga. Saga listens to the end of one subprocess and passes the document to the next subprocesses according to its state and the current state of the received document. It is responsible for the whole document path. Saga handles timeouts too. It can do it by sending an event to itself in the future. Then one of the two events will always arrive as first: the end of the subprocess or the timeout. After the timeout, saga can change process and send the document to a different subprocesses. When the main process finishes the document reaches its final state and is saved in read-only mode.

In this approach every subprocess is independent and has no idea about other subprocesses. We can change the main process without the need of changing subprocesses. We can even introduce many main processes based on document state using the same subprocesses. We can also add parallel processing of documents using queues and special dispatchers which will distribute documents to different instances of one subprocess.


I must say that this was one of the best trainings I’ve ever attended. It was planned very good. Each new information was helpful to implement some solution in future cases. We not only listened to the lecture but also wrote code in pairs. We could check if we understood everything right. Greg had time to ask everybody about their progress and always helped if there were any doubts. If you have any possibility to attend Greg Young’s training don’t hesitate and buy a ticket. It’s definitely worth it!

Categories: Trainings

Leave a Reply