Enode is an application development framework that provides developers with a complete set of solutions based on the Ddd+cqrs+es+eda architecture style. Enode from release 1.0 to now for almost two years, I've been updating my design or implementation code almost every week. So that never a stable version can be provided to everyone, very ashamed. But I believe that with the passage of time and the accumulation of my efforts, Enode will surely become more stable and mature. I think I am very happy at the moment because I have my own interest and have the opportunity to fight for my own interests in my spare time.
Enode Open Source Address: Https://github.com/tangxuehua/enode
Today is a happy day, because I finally used Enode developed a more convincing real case, an online meeting location management and ordering system. This case is consistent with Microsoft's Microfost CQRS journey case, but is done with enode development. The aim is to demonstrate:
- How to use Enode to support the implementation of the DDD domain layer;
- How to use Enode to implement the Cqrs+es architecture;
- How to use Enode to implement event-driven architecture (EDA);
In addition, in the case development process, also constantly found Enode, equeue a lot of problems. So, by doing this case, also help Enode, Equeue perfect a lot. Really want to practice to progress Ah!
Enode Architecture Introduction
The current architecture of Enode has been significantly different from the original version 1.0. For example, without a dependency on Redis, the command store design was added. The latest version of the Enode frame composition is as follows:
People who are familiar with the CQRS architecture should be unfamiliar with the diagram. There are two points to emphasize:
- In the new version of the architecture diagram, domain aggregate is resident memory; The responsibility of the aggregation root is to encapsulate the state, business rules, and generate domain events;
- A command Store has been added to enable the command to be idempotent;
For an introduction to the rest of the diagram, see the article on the Enode series that I wrote earlier.
Enode Key Features
- It realizes the CQRS architecture, supports the distributed, queue-based horizontal expansion, and considers the horizontal expansion of each node of the architecture at the beginning of the framework design;
-
For high concurrency design, architecture level, fully consider how to solve concurrency problems, through the use of Equeue to implement message routing between servers, through a single machine to achieve similar actor mailbox design, so as to avoid the generation of concurrency. Improves the overall write throughput of the C-side of the CQRS architecture, supports automatic optimistic detection and automatically retries even in some extreme cases, and also, at the architectural level, specifies that a command can only involve a modification of an aggregate root. In order to standardize the application developers must strictly follow the message-driven thinking to achieve complex business processes, and can not use the way the work unit, the transaction to achieve strong consistency of data;
- Rigorous message power processing support; Because Enode is a message-driven architecture, the idempotent handling of messages is an important aspect of the framework's focus and is supported at the architectural level. This makes it unnecessary for application developers to worry about the problem of repetitive processing of messages.
- Domain aggregate resident memory; This design can improve the processing performance of C-terminal command. Because we don't have to take the aggregate root out of the db like the traditional way, then modify it and save it back.
- The framework shows developers how to better implement sagas, in the CQRS architecture, sagas refers to message-driven business processes; A saga consists of several aggregation roots and one (usually) process Manager , the state of all participant objects in the root maintenance process and the state of the process itself, the process manager is responsible for defining and implementing the process control logic, stateless; The process manager realizes the message-driven process by responding to events, exceptions, application-level messages, and then sending the corresponding commands;
- Using the event Sourcing (es) method to persist the aggregation root state, the restoration of aggregation root state through ES and the common concurrency control, the optimistic concurrency control is realized by aggregating the root id+ event version number as a unique index;
- In addition to command, domain event, the message also supports exception message, application message, both of which we need to use when we encounter some messages that are not suitable for domain event expression. , such as aggregation sometimes we want to modify a state before the business rules to check the judgment, if illegal, usually throw an exception, and then this exception we want to let the process manager know, so that the process manager can do the back of the rollback or compensation measures, in addition, we may sometimes at the application level (command Handler) interacting with other external systems, the result of the interaction, the use of the application layer of the message is more reasonable, enode at the architectural level, the above messages have been unified support;
- The framework provides support for returning the results of a single command execution and blocking the execution of a command, which is very helpful when developers want to synchronize the command and know the result of the command execution, so the developer doesn't have to rotation.
- In addition to the power of the message processing support, Enode to the domain event order Processing, also do the full consideration and support, to ensure that when the C-side generated domain event synchronization to the Q end, the Q-side processing, the framework level can ensure that the Q end of the processing sequence will not be disorderly. Thus ensuring that the data at both ends of the C,Q is final and consistent;
- Ensure that the message can be processed at least once; the main idea is to ensure that the message is: 1) persisted; 2) the message is not considered to be consumed until it is ack;
- Supporting one aggregate root at a time can result in multiple domain event, although in most cases an aggregate root produces only one domain event at a time, but some scenarios may result in two or more. At this point, these events will apply to the current aggregate root in the same way as an event flow, and at the Q end, the framework will ensure the correctness of the sequence of events in the event stream, along with the user code, with the necessary means;
- The distributed Message Queuing equeue used by Enode, referring to Ali's ROCKETMQ architecture, has high performance, scalability, and lightweight features that support message stacking capabilities that are not limited to machine memory size and are pure C # development. It also provides a simple and practical management console that allows us to manage message queues with ease. For example, it is convenient to dynamically add, disable, enable, delete queues, query message content, message consumption progress, and other information; At present, Equeue has been through a number of iterations, and has been used by real users, the basic functions tend to mature and stable.
Conference Case Brief
Conference is a Microsoft-developed, Ddd+cqrs+es-based open source project. Project home:Cqrsjourney. Github.io
This project is very helpful for all of us to learn about the DDD field-driven design and cqrs+es architecture.
- The case from the business, the realization of a typical e-commerce system Key Link: commodity management, inventory management, order, reduce inventory, payment;
- This case is technically good at demonstrating the benefits of the CQRS architecture. For example, the Q-side can be customized to different views to meet the different query requirements;
- This case shows us how to divide the domain, divide the boundary context (bounded context), and how to use different architectural techniques to achieve different contexts, which is very valuable for learning.
It is because of the above advantages of this project that I am interested in using Enode as a technical support system to achieve the same function. In the process of rewriting, all non-technical things are preserved, such as boundary context Division, domain layer, etc., and all technical related parts are replaced by Enode.
Conference Open Source project with Enode address: https://github.com/tangxuehua/conference
Demo address, backstage: http://www.enode.me/conference, front desk: http://www.enode.me/registration
Interested students, you can download the source code for research. The quickest way to understand Enode is to start with the case code. If you want to communicate, you can add QQ Group: 185916873, always welcome interested in the Tao friends to join.
Finally, post a sagas flowchart for order Processing in a conference case:
It's not too early to write it down.
Enode 2.6 Architecture and design brief and new case sharing