Implementing distributed transactions with Sagas
To organize the order creation process as a saga, we will be introducing additional functionality in the form of an SEC. These are the items we will be building or modifying to accomplish this task:
- We will update the
ddd
andam
packages so that they include the new Command and Reply message types - We will create a new
sec
package that will be the home for an orchestrator and saga definitions and implementations
Now, let’s dive into the existing packages to add those new types of messages.
Adding support for the Command and Reply messages
The Command and Reply additions to the ddd
package are nearly exact copies of the Event definitions and implementations that we can expand on later. Here are the interfaces and implementations for Reply:
Figure 8.7 – The new Reply definitions in the ddd package
The ones for the Command message will be like the Event and Reply definitions...