Micro-service dividing method based on bound context
1. A micro-service partitioning method based on bound context is characterized in that: the method comprises the following steps:
1) analyzing a service scene;
2) describing by using an illustration, and modeling by using the illustration through a unified modeling language;
3) extracting context, namely extracting the context of business activity through semantic and functional correlation analysis;
4) and extracting candidate micro-services, determining context boundaries and naming to obtain the candidate micro-services.
2. The method of claim 1, wherein the method comprises: the step 1) is as follows:
the method comprises the steps of comprehensively collecting information of the legacy system by reading a development document of the legacy system and fully communicating with developers and field experts, clearing and participating roles Who, business activities What and business values Why, combing processes and completion sequences of role and event interaction, namely main business processes of the system, and abstracting different business scenes on the basis of the business processes, wherein the business scenes are composed of a plurality of business activities.
3. The method of claim 1, wherein the method comprises: the step 2) is as follows:
on the basis of different service scenes determined in the step 1), analyzing the scenes by using a case analysis method of field scene analysis to identify service activities, wherein one service activity is a case, Modeling the service scenes by using a Unified Modeling Language (UML) case diagram, and determining the relationship among the cases to obtain a case diagram model of a certain service scene.
4. The method of claim 1, wherein the method comprises: the step 3) is as follows:
on the basis of the case model established in the step 2), cases with the same characteristics are classified, and the cases are clustered through the following two aspects of analysis:
1) semantic relevance analysis
Analyzing the use case description of the business activity from the semantic perspective, and if some use cases have the same semantic meaning, the use cases can be used as the classified characteristics;
2) functional correlation analysis
Functional relevance refers to the cohesion of responsibility, strong relevance is equal to high cohesion, functional relevance uses a high cohesion low coupling design principle to analyze whether business activities are related and dependent with each other from the functional point of view, if the related and dependent exist between use cases, the related and dependent functions can be used as a characteristic of classification, if two functions must exist simultaneously or one function is lacked, the other function is incomplete, the two functions are strongly related, otherwise, the two functions are weakly related,
in this case, the case of grouping into one type is actually a microservice.
5. The method of claim 1, wherein the method comprises: the step 4) is as follows:
naming the identified micro-services to obtain candidate micro-services, identifying common characteristics of all business activities, and expressing the characteristics by accurate nouns.
Background
In the enterprise reconfiguration process of the system, the first problem is to divide the legacy system into micro-services. The micro-service partitioning technology is a great challenge currently facing the field and is a research hotspot in academia and industry. The demand analysis is an early stage of software development, which determines the trend of software development and is a very important step. At present, no micro-service division method specially aiming at the early stage of software micro-service is found.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the micro-service partitioning method based on the bound context solves the problem that an architect excessively depends on intuition and experience in the micro-service partitioning process.
The technical scheme adopted by the invention is as follows: a micro-service partitioning method based on bound context comprises the following steps:
1) analyzing a service scene;
2) describing by using an illustration, and modeling by using the illustration through a unified modeling language;
3) extracting context, namely extracting the context of business activity through semantic and functional correlation analysis;
4) and extracting candidate micro-services, determining context boundaries and naming to obtain the candidate micro-services.
Specifically, the step 1) is as follows:
by reading legacy system development documents and by fully communicating with developers and domain experts, legacy system information is comprehensively collected, participating roles (Who), business activities (What) and business values (Why) are cleared, and the processes and orders of completion of role and event interactions, i.e., the main business processes of the system, are combated. Different business scenes are abstracted on the basis of business processes, and the business scenes consist of a plurality of business activities. Gathering information is a very critical step due to the lack of knowledge of the structure of legacy systems.
Specifically, the step 2) is as follows:
on the basis of obtaining service scenes, analyzing the scenes by using a use case analysis method of field scene analysis to identify service activities, wherein one service activity is a use case, Modeling the service scenes by using a Unified Modeling Language (UML) use case diagram, and determining the relationship among the use cases to obtain a use case diagram model of a certain service scene. Since functional dependency analysis relies on relationships between use cases, it is briefly introduced first. The basic relationships between use cases include Generalization, containment and extension, the Generalization relationship (Generalization) represents general and special relationships; the inclusion relation (Include) is that one use case contains behaviors that other use cases have and takes the behaviors as part of the use case; extended relationships (Extend) are incremental extensions of the basic use case.
Specifically, the step 3) comprises two aspects of analysis:
1) semantic relevance analysis
And analyzing the use case description of the business activity from the semantic perspective, wherein if some use cases have the same semantic meaning, the use cases can be used as the characteristic of classification, and the semantic relevance mainly comes from the object for describing the business activity. For example, if cases are obtained to query commodities, collect commodities and share commodities, the cases have the semantics of "commodities", and based on the characteristics of semantic relevance, the cases can be considered to be classified into the same category.
2) Functional correlation analysis
Functional relevance refers to the cohesion of responsibility, and a strong correlation equates to high cohesion. The functional correlation uses a high-cohesion low-coupling design principle to analyze whether business activities are related and dependent on each other from the functional perspective, and if the related and dependent exist among the use cases, the business activities can be used as the classified characteristics. If two functions must exist simultaneously or one function is lacked and the other function is incomplete, the two functions are strongly related, otherwise, the two functions are weakly related. The method of the invention judges the strength of the functional correlation through the relationship between the use cases, if the use cases are in the inclusion relationship, the functional correlation is strong; if the use cases are in an extended relationship, the functional relevance is weak.
Specifically, the step 4) is as follows:
and synthesizing the semantic and function related analysis results, determining the context boundary and naming to obtain the candidate micro-service. The division of the bounding context is an iterative process, so this step can be viewed as a verification process of the adequacy of the refined context.
The invention has the beneficial effects that: the micro-service partitioning method based on the bound context solves the problem that an architect excessively depends on intuition and experience in the micro-service partitioning process, and can provide objective decision suggestions for companies needing to reconstruct a system.
Drawings
FIG. 1 is a schematic view of the present invention in its entirety;
FIG. 2 is a Jpetstore use case modeling diagram;
FIG. 3 is a diagram of extracting Jpetstore candidate microservice.
Detailed Description
The invention is further described below with reference to the accompanying drawings and specific embodiments.
Example (b): as shown in fig. 1-3, a micro-service partitioning method based on bound context includes the following steps:
1) analyzing a service scene;
2) describing by using an illustration, and modeling by using the illustration through a unified modeling language;
3) extracting context, namely extracting the context of business activity through semantic and functional correlation analysis;
4) and extracting candidate micro-services, determining context boundaries and naming to obtain the candidate micro-services.
The specific implementation process is as follows:
in the embodiment, a proposed method is subjected to case study by using an open source project Jpetstore on Github, wherein the Jpetstore is an electronic commerce platform for providing pet purchasing service for customers. The platform mainly comprises functions of browsing pets, adding shopping carts, ordering and purchasing and the like, and the case is applied to the research of service splitting for many times by researchers and has better representativeness. According to the proposed splitting method, the MA system jpeg store is split into microservices step by step.
Further, the step 1) is specifically as follows:
users purchase pets on the Jpetstore platform, and need to fill in information to register Jpetstore platform accounts, and the registered accounts can log in the system, inquire and modify account information, browse and purchase commodities. Through the analysis, two service scenes of registering, logging in and purchasing commodities can be obtained.
Further, the step 2) is specifically as follows:
according to the analysis of business scenes, the scenes are analyzed through a use case analysis method, and the recognition of use cases is driven by a participant (Actor). The method can obtain use case registration accounts, login accounts, account information inquiry, account information modification, commodity search, commodity browsing, shopping cart adding, shopping cart removing, shopping cart updating, order placing and order checking.
Further, the step 3) is specifically as follows:
1) semantic relevance analysis
According to the semantic correlation analysis rule, the registered account, the login account, the account information inquiry and the account information modification all have the same 'account' semantic, and the use cases can be classified into one type; the search goods and the browse goods have the semantics of 'goods', and the use cases can be classified into one category; the shopping cart adding, shopping cart removing and shopping cart updating cases all have the same 'shopping cart' semantic meaning, and the cases can be classified into one class; the order placing and order checking use cases have the same order semantics, the use cases can be classified into one type, the account information query and account information modification have the same information semantics, and the two use cases can be classified into one type.
2) Functional correlation analysis
According to the functional relevance rule, the login account use cases comprise login account use cases, account information inquiry use cases and account information modification use cases, have strong relevance and can be classified into one type; the searched commodity cases comprise browsed commodity cases, have strong correlation and can be classified into one type; the order placing case comprises checking orders, has strong correlation and can be classified into one type; adding a shopping cart case includes removing a shopping cart and updating the shopping cart, has strong correlation, and can be classified into one category.
Further, the step 4) is specifically as follows:
according to the context extraction, a registered account, a login account, account information inquiry and account information modification can be obtained as a bound context, and the bound context is named as an account service; searching and browsing the commodity as a limit context, and naming the limit context as commodity service; adding a shopping cart, removing the shopping cart and updating the shopping cart into a bound context, and naming the bound context as shopping cart service; order placement, order view, and a clearance context are named order service. FIG. 3 is a diagram illustrating a method for extracting four micro-services of an account, a commodity, a shopping cart and an order by using a dashed line.
While the present invention has been described in detail with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, and various changes can be made without departing from the spirit of the present invention within the knowledge of those skilled in the art.