How to handle reversing the create command

92 views
Skip to first unread message

Lap Ming Lee

unread,
Apr 20, 2016, 12:53:35 AM4/20/16
to DDD/CQRS
I have a process manager that reverse commands if one of them fails during the process.  How should one typically handle reversing the create command since nothing is deleted.  

Would it be usual to simply lock (ie/ set a boolean that the aggregate is locked) the aggregate?  

Ramin

unread,
Apr 20, 2016, 3:34:20 AM4/20/16
to DDD/CQRS
Issue compensating commands to reverse the process (clean up), 
eg. to delete the aggregate. It will have been created by the process 
in an earlier step, maybe in a "locked" state. I am assuming you want 
to create  it in a locked state so it cannot be used by other components 
until the process is complete.

Rénald VENANT-VALERY

unread,
Apr 20, 2016, 7:09:48 AM4/20/16
to ddd...@googlegroups.com
Once, we did something like that, for a complex financial ​system with many constraints on data. What follows is not about distributed transactions, it is about rolling-back mistaken operations. The approach was the following :

As the system was young and immature (the company is a FinTech), business people were hesitating when managing business-rules, special use-cases, etc... in this situation, we had many problems to integrate this uncertainty into our accounting domain. In the accounting domain, it is not possible to change the already processed business events, you modify them by appending new events, that cancel the preceding ones. We implemented a basic (async) notifications system with a basic DB persisted event-store, with correlation ids to represent the distributed transaction. All handlers were implementing the command pattern Do()/Undo().

Given a sequence of mistaken notifications, we were able to go back in time based on the database timeline, and apply the "Undo()" method for every single notification associated with the correlation id.

It was twice the job to develop, because each command needed its own "nemesis". Doing this, we had to write sufficiently ACID "Do()" methods in the handler to ensure the "Undo()" to be possible. Once, it perfectly worked for a massive malfunction in the system.

Lap Ming Lee

unread,
Apr 20, 2016, 8:49:52 AM4/20/16
to ddd...@googlegroups.com
You insight is absolutely wonderful as my system is exactly as you described.   It makes me very happy to find out that I am on the right track.   Thank you very much!  All smiles. 

Sent from my iPad
--
You received this message because you are subscribed to a topic in the Google Groups "DDD/CQRS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dddcqrs/Yhw_4YIgYF8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages