I learn a lot of the general ways that developers develop / archive a domain-driven application (still trying to understand the concept as a whole). Some of the examples I saw included using events through an event aggregator. I liked the concept, because it really supports different elements / domains of the application.
I have a problem: how do you roll back an operation in case of an error?
For instance:
Let's say I have an order application that should save the order in the database, as well as save a copy of the order in pdf format for CMS. The application fires the event created by the new order, and the pdf service that subscribes to this event saves the PDF file. Meanwhile, when making an order change to the database, an exception is thrown. The problem is that the pdf was saved, but they did not match the database record.
Do I have to cache previously processed events and fire a new error event that looks at the cache for undo operations? Use something like a command template for this?
Or ... an event aggregator is not a good example for this.
Edit
I am starting to think that perhaps events should be used for less "critical" elements, such as emailing and logging.
My initial thought was to limit dependencies using an event aggregator pattern.
Chris source share