Project plan optimization method, system, readable storage medium and computer
By building dynamic code in virtual institutions and combining hades rule engine and nacos configuration files, the problem of large Java microservice projects changing and optimizing code without affecting business continuity and data consistency is solved, and smooth business logic enhancement and code replacement are achieved.
Patent Information
- Application Number
- CN202411397221.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-10-09
AI Technical Summary
When large Java microservice projects replace business logic vulnerabilities or solutions, it is difficult to replace and restart code without affecting business continuity and data consistency, especially in a massive active user environment.
Build dynamic code through virtual institutions, and build project dependency parameters in the project to be optimized, introduce configuration management interfaces and nacos configuration files, dynamically update the code in the configuration files, and use the hades rule engine to achieve project optimization.
It realizes optimization of business logic and code replacement without shutting down, ensuring business continuity and data consistency, simplifying operational processes and improving efficiency.
Smart Images

Figure CN118897671B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a project solution optimization method, system, readable storage medium and computer. Background Art
[0002] At present, large-scale Java microservice projects developed based on springboot can support the daily use of tens of thousands or even hundreds of millions of active users through modular design, independent deployment, horizontal expansion, load balancing and other methods. However, such large-scale projects also have the characteristics of numerous business units, complex business logic, and very high requirements for business continuity, data consistency and integrity. Therefore, once the system is found to have major business logic vulnerabilities or wants to temporarily replace a better solution, R&D personnel often modify the code immediately. After the R&D environment is tested, the operation and maintenance personnel replace the latest code package and upload it to each server and restart the background code. However, for large projects with a large number of active users, the project cannot be restarted at will, because large projects often require 24-hour uninterrupted operation. Restarting the project rashly will cause irreparable losses to the project's business continuity and data consistency.
[0003] The existing technology of changing packages and restarting and upgrading has the following main disadvantages:
[0004] 1. Any interruption of service may have a significant impact on business operations, resulting in customer dissatisfaction, data loss or financial loss.
[0005] 2. Large Java projects usually contain multiple microservices, databases, cache systems, message queues and other components, which are interconnected through complex network topologies and dependencies. Restarting a project may require restarting multiple services at the same time and ensuring that they can correctly re-establish connections and synchronize status, which increases the complexity and risk of operations.
[0006] 3. During the restart process, it is necessary to ensure that the integrity and consistency of all data are not destroyed. This includes the integrity of database transactions, the consistency of cached data, and the accurate processing of messages in the message queue. Any data loss or inconsistency may lead to business logic errors or system crashes. Summary of the invention
[0007] Based on this, the purpose of the present invention is to provide a project plan optimization method, system, readable storage medium and computer to at least solve the deficiencies in the above-mentioned technology.
[0008] The present invention proposes a project scheme optimization method, comprising:
[0009] Using a virtual machine to construct a corresponding dynamic code, and based on the dynamic code, constructing a corresponding project dependency parameter in the project to be optimized;
[0010] A management interface is configured in the project to be optimized, and a corresponding configuration file is introduced according to the configuration center of the project to be optimized, and the dynamic code is introduced into the configuration file to update the data of the configuration file;
[0011] The management interface of the project to be optimized is called, and the configuration file after data update is accessed by using the management interface to achieve project optimization of the project to be optimized.
[0012] Furthermore, the steps of constructing corresponding dynamic codes using a virtual machine, and constructing corresponding project dependency parameters in the project to be optimized based on the dynamic codes include:
[0013] Obtain a local IDE environment, and use a virtual machine to build corresponding dynamic code in the local IDE environment;
[0014] Corresponding project management data is generated according to the dynamic code, and corresponding project dependency parameters are created in the project to be optimized using the project management data.
[0015] Furthermore, the steps of configuring a management interface in the project to be optimized and introducing a corresponding configuration file according to the configuration center of the project to be optimized include:
[0016] Customize the configuration management interface in the project to be optimized to achieve real-time acquisition of configuration adjustment of the project to be optimized;
[0017] A nacos configuration file is introduced to ensure that the project to be optimized and the nacos configuration file remain connected.
[0018] Furthermore, the step of introducing the dynamic code into the configuration file to update the data of the configuration file includes:
[0019] Introducing the dynamic code into the configuration file, creating the data ID information required by the project to be optimized, and updating the editing code of the data ID information;
[0020] Create corresponding data ID parameters under the name domain and implant logic beans to update the data in the configuration file.
[0021] The present invention also proposes a project solution optimization system, comprising:
[0022] A parameter construction module, used to construct corresponding dynamic codes using a virtual machine, and to construct corresponding project dependency parameters in the project to be optimized based on the dynamic codes;
[0023] A data update module, used to configure a management interface in the project to be optimized, introduce a corresponding configuration file according to the configuration center of the project to be optimized, introduce the dynamic code into the configuration file, and update the data of the configuration file;
[0024] The project optimization module is used to call the management interface of the project to be optimized, and use the management interface to access the configuration file after the data is updated, so as to achieve project optimization of the project to be optimized.
[0025] Furthermore, the parameter construction module includes:
[0026] A code building unit, used to obtain a local IDE environment and use a virtual machine to build corresponding dynamic code in the local IDE environment;
[0027] A parameter construction unit is used to generate corresponding project management data according to the dynamic code, and use the project management data to create corresponding project dependency parameters in the project to be optimized.
[0028] Furthermore, the data updating module includes:
[0029] An interface configuration unit, used to customize the configuration management interface in the project to be optimized, so as to achieve real-time acquisition of configuration adjustment of the project to be optimized;
[0030] The file introduction unit is used to introduce the nacos configuration file to achieve the connection between the project to be optimized and the nacos configuration file.
[0031] Furthermore, the data updating module includes:
[0032] A code editing unit, used to introduce the dynamic code into the configuration file, create the data ID information required by the project to be optimized, and update the editing code of the data ID information;
[0033] The data updating unit is used to create corresponding data ID parameters under the name domain and implant the logic bean to update the data of the configuration file.
[0034] The present invention also provides a readable storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned project solution optimization method is implemented.
[0035] The present invention also proposes a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned project solution optimization method when executing the computer program.
[0036] The project solution optimization method, system, readable storage medium and computer of the present invention use a virtual machine to construct a corresponding dynamic code, and use the dynamic code to construct corresponding project dependency parameters in the project to be optimized, introduce the dynamic code into the configuration file of the project to be optimized to update the data of the configuration file, and access the updated configuration file by calling the management interface of the project to be optimized to achieve project optimization of the project to be optimized. The hades rule engine is combined with nacos to solve the problem that should be solved by shutting down and restarting the project. After simple configuration, it can achieve smooth enhancement of the original business logic pain points, and the configuration is flexible, simple and the effect response is fast. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A flowchart of a project solution optimization method in a first embodiment of the present invention;
[0038] Figure 2 for Figure 1 Detailed flow chart of step S101;
[0039] Figure 3 for Figure 1 Detailed flow chart of step S102;
[0040] Figure 4 for Figure 1 A flowchart of another implementation of step S102;
[0041] Figure 5 It is a structural block diagram of a project solution optimization system in a second embodiment of the present invention;
[0042] Figure 6 FIG. 4 is a structural block diagram of a computer in a third embodiment of the present invention.
[0043] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0044] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0046] Embodiment 1
[0047] See also Figure 1 , which shows a project solution optimization method in a first embodiment of the present invention, and the method specifically includes steps S101 to S105:
[0048] S101, using a virtual machine to construct a corresponding dynamic code, and constructing a corresponding project dependency parameter in the project to be optimized based on the dynamic code;
[0049] For further information, see Figure 2 , the step S101 specifically includes steps S1011~S1012:
[0050] S1011, obtaining a local IDE environment, and using a virtual machine to build a corresponding dynamic code in the local IDE environment;
[0051] S1012: Generate corresponding project management data according to the dynamic code, and use the project management data to create corresponding project dependency parameters in the project to be optimized.
[0052] Suppose a scenario: Large-scale project A usually sends tens of thousands of text messages per second. Tencent Cloud was previously purchased as the channel for sending text messages. During the project operation, it was discovered that there were major logical problems in the code logic of SMS billing, which had a wide impact and directly affected the company's finances and the cost settlement of Tencent Cloud vendors. The R&D personnel immediately modified the code, but there were dozens of servers online that were clustered, so they could not easily shut down for package changes.
[0053] In the specific implementation, develop the specific code implementation in the local IDE: this method needs to implement the same interface as the code before modification and rewrite the sending method. Hades is based on Groovy implementation. It should be noted that Hades cannot use lombok and Java lambda expressions.
[0054] Furthermore, the need to implant hades was considered at the beginning of project design, so hades-related Maven dependencies were first introduced into the project.
[0055] S102, configuring a management interface in the project to be optimized, introducing a corresponding configuration file according to a configuration center of the project to be optimized, and introducing the dynamic code into the configuration file to update data in the configuration file;
[0056] For further information, see Figure 3 , the step S102 specifically includes steps S1021~S1022:
[0057] S1021, customizing the configuration management interface in the project to be optimized to achieve real-time acquisition of configuration adjustment of the project to be optimized;
[0058] S1022, introducing a nacos configuration file to ensure that the project to be optimized and the nacos configuration file remain connected.
[0059] In the specific implementation, the custom BaseHadesBaseConfig class implements the HadesBaseConfig interface to realize the logic of obtaining configuration and real-time configuration notification, paving the way for the subsequent real-time acquisition of dynamic change logic code.
[0060] Furthermore, the nacos configuration file is introduced to ensure that the project is connected to nacos after startup (the original project used nacos as the configuration center and registration center).
[0061] For further information, see Figure 4 , the step S102 further includes steps S1121-S1122:
[0062] S1121, introducing the dynamic code into the configuration file, creating the data ID information required by the project to be optimized, and updating the editing code of the data ID information;
[0063] S1122, create corresponding data ID parameters under the name domain, and implant the logic bean to update the data of the configuration file.
[0064] During the specific implementation, add hades related configuration to the project's configuration file so that this configuration can be referenced by the project later.
[0065] hades.enabled=true
[0066] hades.config.name=hades
[0067] The hades.config.name in this part actually refers to the dataId of nacos.
[0068] Furthermore, create a dataId named tencentSendService, in which the text is filled with the already written code:
[0069] public List <smsrecord>send(SmsParam smsParam)
[0070] {
[0071] SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS" );
[0072] String currentTime =dateFormat.format(new Date());
[0073] SmsRecord smsRecord =new SmsRecord();
[0074] smsRecord.setMsgContent(currentTime + "---Call Tencent Cloud to send SMS method: tencentSendService.send method----Code version: V2.0
[0075] List <smsrecord>list = new ArrayList<>();
[0076] list.add(smsRecord);
[0077] return list;
[0078] }
[0079] Specifically, create a dataId named hades under the hades namespace, where the text is:
[0080] {
[0081] "instanceNames": [
[0082] "tencentSendService"
[0083] ],
[0084] "updateTime": 1723113670411
[0085] }
[0086] Specifically, the logic bean to be implanted: tencentSendService is registered in the springIOC container. The following is the log printed in the background:
[0087] Groovy parsing: class=[tencentSendService] syntax passed
[0088] bean:[tencentSendService] already exists in the system, so let's replace it.
[0089] #handler.service.TencentSendService] has been registered in Spring I0C.
[0090] S103, calling the management interface of the project to be optimized, and using the management interface to access the configuration file after data update, so as to achieve project optimization of the project to be optimized.
[0091] In the specific implementation, this interface is called through Postman, as shown in the following code, which shows the logic of the latest solution. From now on, the solution of updating code logic without stopping the machine has been introduced:
[0092] "data":"2024-08-09 17:08:03.063---Call Tencent Cloud to send SMS method: tencentSendservice.send method----code version V2.0".
[0093] Further expansion: In addition to repairing the original code logic without stopping the server, you can also add another completely different code logic. For example, if you find that Alibaba Cloud is more favorable for sending SMS, you can write a specific implementation class for Alibaba Cloud and implement the same interface and methods as the Tencent Cloud implementation class. Using Hades combined with Nacos can also automatically inject it into the Spring container without stopping the server. Therefore, the code for sending SMS is designed as follows:
[0094] applicationContext.getBean(sendSms.getBeanName()).send(smsParam); sendSms.getBeanName() is the value obtained from the database, which corresponds to the name of the springbean. You only need to replace the value in the database with the bean name of the Alibaba Cloud implementation class (the database does not need to be restarted to update the field value). This will smoothly change the channel provider for sending SMS messages from Tencent Cloud to Alibaba Cloud. The background printout of the new solution is as follows (compared to the previous replacement of the original code, there is one less replacement information):
[0095] Groovy parsing: class=[tencentSendServicel syntax
[0096] seConfig - beans:[com.test.handler,script,impl,TencentSendservice] have been registered in Spring I0c.
[0097] Specifically, if there are new changes to the rules later, you can modify updateTime to dynamically modify its logic again.
[0098] In summary, the project solution optimization method in the above embodiment of the present invention uses a virtual machine to construct the corresponding dynamic code, and uses the dynamic code to construct the corresponding project dependency parameters in the project to be optimized, and introduces the dynamic code into the configuration file of the project to be optimized to update the data of the configuration file, and accesses the updated configuration file by calling the management interface of the project to be optimized to achieve project optimization of the project to be optimized. The hades rule engine is combined with nacos to solve the problem that should be solved by shutting down and restarting the project. After simple configuration, it can achieve the pain points of smooth enhancement of the original business logic. The configuration is flexible, simple, and the results are fast.
[0099] Embodiment 2
[0100] Another aspect of the present invention is to provide a project plan optimization system, please refer to Figure 5 , shown is a project solution optimization system in a second embodiment of the present invention, the system comprising:
[0101] A parameter construction module 11 is used to construct corresponding dynamic codes using a virtual machine, and to construct corresponding project dependency parameters in the project to be optimized based on the dynamic codes;
[0102] Furthermore, the parameter construction module 11 includes:
[0103] A code building unit, used to obtain a local IDE environment and use a virtual machine to build corresponding dynamic code in the local IDE environment;
[0104] A parameter construction unit is used to generate corresponding project management data according to the dynamic code, and use the project management data to create corresponding project dependency parameters in the project to be optimized.
[0105] A data updating module 12 is used to configure a management interface in the project to be optimized, introduce a corresponding configuration file according to the configuration center of the project to be optimized, introduce the dynamic code into the configuration file, and update the data of the configuration file;
[0106] Furthermore, the data updating module 12 includes:
[0107] An interface configuration unit, used to customize the configuration management interface in the project to be optimized, so as to achieve real-time acquisition of configuration adjustment of the project to be optimized;
[0108] The file introduction unit is used to introduce the nacos configuration file to achieve the connection between the project to be optimized and the nacos configuration file.
[0109] Furthermore, the data updating module 12 includes:
[0110] A code editing unit, used to introduce the dynamic code into the configuration file, create the data ID information required by the project to be optimized, and update the editing code of the data ID information;
[0111] The data updating unit is used to create corresponding data ID parameters under the name domain and implant the logic bean to update the data of the configuration file.
[0112] The project optimization module 13 is used to call the management interface of the project to be optimized, and use the management interface to access the configuration file after the data is updated, so as to achieve project optimization of the project to be optimized.
[0113] The functions or operation steps implemented when the above modules and units are executed are generally the same as those in the above method embodiments, and will not be repeated here.
[0114] The project plan optimization system provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0115] Embodiment 3
[0116] The present invention also provides a computer, see Figure 6 , shown is a computer in the third embodiment of the present invention, including a memory 10, a processor 20, and a computer program 30 stored in the memory 10 and executable on the processor 20, and when the processor 20 executes the computer program 30, the above-mentioned project solution optimization method is implemented.
[0117] The memory 10 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 10 may be an internal storage unit of a computer, such as a hard disk of the computer. In other embodiments, the memory 10 may also be an external storage device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Further, the memory 10 may also include both an internal storage unit of the computer and an external storage device. The memory 10 may be used not only to store application software and various types of data installed in the computer, but also to temporarily store data that has been output or is to be output.
[0118] Among them, in some embodiments, the processor 20 can be an electronic control unit (Electronic Control Unit, abbreviated as ECU, also known as a vehicle computer), a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor or other data processing chip, used to run the program code stored in the memory 10 or process data, such as executing access restriction programs, etc.
[0119] It should be pointed out that Figure 6 The structure shown does not constitute a limitation on the computer. In other embodiments, the computer may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0120] The embodiment of the present invention further provides a readable storage medium having a computer program stored thereon, which implements the project solution optimization method as described above when the program is executed by a processor.
[0121] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0122] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0123] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0124] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0125] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.< / smsrecord> < / smsrecord>
Claims
1. A project plan optimization method, characterized in that: include: Using a virtual machine to construct a corresponding dynamic code, and based on the dynamic code, constructing a corresponding project dependency parameter in the project to be optimized; A management interface is configured in the project to be optimized, and a corresponding configuration file is introduced according to the configuration center of the project to be optimized, and the dynamic code is introduced into the configuration file to update the data of the configuration file; wherein the steps of configuring a management interface in the project to be optimized and introducing the corresponding configuration file according to the configuration center of the project to be optimized include: Customize the BaseHadesBaseConfig class to implement the HadesBaseConfig interface to achieve real-time acquisition of configuration adjustments for the project to be optimized; Introduce a nacos configuration file to ensure that the project to be optimized and the nacos configuration file remain connected; The management interface of the project to be optimized is called, and the configuration file after data update is accessed by using the management interface to achieve project optimization of the project to be optimized.
2. The project solution optimization method according to claim 1, characterized in that: The steps of using a virtual machine to construct corresponding dynamic codes, and constructing corresponding project dependency parameters in the project to be optimized based on the dynamic codes include: Obtain a local IDE environment, and use a virtual machine to build corresponding dynamic code in the local IDE environment; Corresponding project management data is generated according to the dynamic code, and corresponding project dependency parameters are created in the project to be optimized using the project management data.
3. The project solution optimization method according to claim 1, characterized in that: The step of introducing the dynamic code into the configuration file to update the data of the configuration file includes: Introducing the dynamic code into the configuration file, creating the data ID information required by the project to be optimized, and updating the editing code of the data ID information; Create corresponding data ID parameters under the name domain and implant logic beans to update the data in the configuration file.
4. A project plan optimization system, characterized in that: include: A parameter construction module, used to construct corresponding dynamic codes using a virtual machine, and to construct corresponding project dependency parameters in the project to be optimized based on the dynamic codes; A data update module is used to configure a management interface in the project to be optimized, introduce a corresponding configuration file according to the configuration center of the project to be optimized, introduce the dynamic code into the configuration file, and update the data of the configuration file, wherein the data update module includes: An interface configuration unit, used to customize the BaseHadesBaseConfig class to implement the HadesBaseConfig interface, so as to achieve real-time acquisition of configuration adjustment of the project to be optimized; A file import unit, used for importing a nacos configuration file, so as to achieve a connection between the project to be optimized and the nacos configuration file; The project optimization module is used to call the management interface of the project to be optimized, and use the management interface to access the configuration file after the data is updated, so as to achieve project optimization of the project to be optimized.
5. The project solution optimization system according to claim 4, characterized in that: The parameter building module includes: A code building unit, used to obtain a local IDE environment and use a virtual machine to build corresponding dynamic code in the local IDE environment; A parameter construction unit is used to generate corresponding project management data according to the dynamic code, and use the project management data to create corresponding project dependency parameters in the project to be optimized.
6. The project solution optimization system according to claim 4, characterized in that: The data updating module comprises: A code editing unit, used to introduce the dynamic code into the configuration file, create the data ID information required by the project to be optimized, and update the editing code of the data ID information; The data updating unit is used to create corresponding data ID parameters under the name domain and implant the logic bean to update the data of the configuration file.
7. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the project solution optimization method as described in any one of claims 1 to 3 is implemented.
8. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the project solution optimization method as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
CSS code optimization method based on front-end vue project and related equipment
CN112685013A
Project dependence management method and device, equipment and storage medium
CN116954702A