Business interaction method, nonvolatile storage medium and electronic equipment
By determining the state record information and querying the target topic to generate target messages, the problems of high coupling of the business architecture and unsatisfactory business code adjustment efficiency are solved, and the decoupling of the business module and the maintainability and flexibility of the code are realized.
Patent Information
- Application Number
- CN202411863479.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, the business architecture is highly coupled and the business code adjustment efficiency is not ideal, resulting in difficulty in code changes and high limitations in business adjustment.
By determining the status record information, querying the target topic according to the status record information, and generating target messages in the target topic, asynchronous communication and decoupling between business modules are achieved.
It realizes mutual decoupling of business modules, promotes the reuse and maintainability of business code, and improves the efficiency of business code adjustment.
Smart Images

Figure CN119718723A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed application systems, and in particular to a business interaction method, a non-volatile storage medium, and an electronic device. Background Art
[0002] Modular programming is becoming more and more important. It is a method of dividing large applications into independent, reusable components or modules, which improves the maintainability, reusability and scalability of the code and reduces the dependency and coupling between codes. Related technologies usually use design patterns such as responsibility chain to call each module, and there will be a large number of static hard-coded configurations in the code. If you need to add or delete a module, you usually need to stop the application, modify the code and restart it. This not only increases the system memory pressure but also is not conducive to the dynamic expansion of the business. There are problems such as difficulty in code changes and high limitations on business adjustments.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a business interaction method, a non-volatile storage medium, and an electronic device to at least solve the technical problems existing in the related art that the business architecture has high coupling and the business code adjustment efficiency is not ideal.
[0005] According to one aspect of an embodiment of the present application, a business interaction method is provided, including: determining status record information, wherein the status record information is determined based on the current execution status of a first business module among multiple business modules; querying according to the status record information to determine a target topic corresponding to the status record information; controlling generation of a target message in the target topic, wherein the target message is obtained by a second business module that has subscribed to the target topic, the second business module executes the corresponding business process according to the target message, and the second business module belongs to multiple business modules.
[0006] Optionally, determining the status record information includes: intercepting the status record method when it is detected that the status record method has been called, wherein the status record method is used by the first business module to record the status in the database; and determining the status record information based on the status record method.
[0007] Optionally, controlling generation of a target message in a target topic includes: determining a delay time for controlling message sending; and controlling generation of the target message in the target topic after waiting for the delay time.
[0008] Optionally, the method also includes: receiving abnormal prompt information, wherein the abnormal prompt information includes information indicating that the target message has not been successfully generated, or information indicating that the target message has not been consumed within a predetermined time period; based on the abnormal prompt information, controlling the regeneration of the target message in the target topic.
[0009] Optionally, querying according to the status record information to determine the target subject corresponding to the status record information includes: querying according to the status record information based on a predetermined mapping relationship to determine the target subject, wherein the mapping relationship is configured on a configuration center server.
[0010] According to another aspect of an embodiment of the present application, a business interaction method is provided, including: a first business module among multiple business modules generates status record information based on a current execution status; an aspect program determines the status record information; a query is performed according to the status record information to determine a target topic corresponding to the status record information; generation of a target message in the target topic is controlled; a second business module among multiple business modules obtains a target message by subscribing to a target topic; and a corresponding business process is executed according to the target message.
[0011] Optionally, a query is performed according to the status record information to determine the target subject corresponding to the status record information, including: the aspect program queries the configuration center server according to the status record information; the configuration center server performs query processing based on a predetermined mapping relationship, determines the target subject, and feeds back the target subject to the aspect program.
[0012] Optionally, the method also includes: configuring the central server to determine the mapping relationship between different status information and corresponding message topics based on business interaction requirements; in the event that the business interaction requirements change, adjusting the message topics subscribed by multiple business modules based on the changed business interaction requirements; adjusting the mapping relationship based on the changed business interaction requirements to obtain an adjusted mapping relationship.
[0013] According to another aspect of an embodiment of the present application, a non-volatile storage medium is provided, wherein the non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing any one of the service interaction methods.
[0014] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement any one of the business interaction methods.
[0015] In the embodiment of the present application, by determining the status record information, wherein the status record information is determined based on the current execution status of the first business module among multiple business modules; querying according to the status record information, determining the target topic corresponding to the status record information; controlling the generation of the target message in the target topic, wherein the target message is obtained by the second business module subscribed to the target topic, the second business module executes the corresponding business process according to the target message, and the second business module belongs to multiple business modules. The purpose of decoupling business modules from each other is achieved, and the technical effect of promoting the reuse and maintainability of business codes and improving the efficiency of business code adjustment is achieved, thereby solving the technical problems of high coupling of business architecture and unsatisfactory efficiency of business code adjustment existing in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 is a first flow chart of an optional service interaction method provided according to an embodiment of the present application;
[0018] Figure 2 is a second flow chart of an optional service interaction method provided according to an embodiment of the present application;
[0019] Figure 3 is a schematic diagram of an optional service interaction method provided according to an embodiment of the present application;
[0020] Figure 4 It is a schematic diagram of an optional service interaction device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0023] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0024] Message queue, a distributed high-throughput message queue system, works in publish-subscribe mode and can be used to implement message passing and communication between modules.
[0025] Aspect programming is a software development technology that implements interception and processing of specific methods or processes by inserting additional logic code (aspects) at specific locations in the original code.
[0026] Hot plugging is the ability to dynamically add, remove, or replace modules. With hot plugging technology, modules can be dynamically added to the system at runtime without restarting the entire application.
[0027] The configuration center server is used to manage the configuration information of the distributed system. The configuration center can be used to uniformly manage the configuration information of different modules, and can support dynamic configuration and real-time updates to achieve module hot swapping.
[0028] Modular programming is a method of dividing large applications into independent, reusable components or modules. Doing so helps improve the maintainability, reusability and scalability of the code and reduces the dependencies and coupling between codes.
[0029] Topic is a concept in message queues, which is used to logically group messages for the convenience of selective consumption or publishing of messages.
[0030] Message consumption refers to the process in which a consumer reads, processes, and confirms messages from a message queue in a message queue or message middleware system. In this application, multiple business modules can be consumers. In a distributed system, message consumption is a key link in achieving asynchronous communication and decoupling between different components.
[0031] The traditional system architecture provided by related technologies usually uses design patterns and static loading to introduce and use modules, which often leads to tight coupling between modules. As business needs increase, the code redundancy becomes higher and higher, and the repetitive code also increases. Moreover, if a business module is abandoned or added, the code needs to be modified and restarted. In addition, when there is a large amount of data, the interaction time between modules may be long.
[0032] In a business module, it is often necessary to call the business processes of other business modules. At this time, the business module will interact with the called business module through the business interface. However, in actual applications, due to the large changes in the business needs and business logic of the enterprise, when the business needs change, the related business processes will change a lot. At this time, the business interface of the business module will also be changed to update the business logic. However, the change of the business interface will directly affect the business process of the business module that calls the business interface. Therefore, after the business interface is changed, the related business process needs to be updated to ensure that the business module that calls the business interface can accurately execute the business process. However, if the business interface changes frequently, the related business processes also need to be updated frequently, resulting in low interaction efficiency and interaction flexibility between business modules, affecting the development efficiency and development effect of the business module.
[0033] In response to the above problems, an embodiment of the present application provides an embodiment of a method for business interaction. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0034] Figure 1 is a first flow chart of a service interaction method according to an embodiment of the present application, such as Figure 1 As shown, the execution subject may be a section program, and the method includes the following steps:
[0035] Step S102, determining status record information, wherein the status record information is determined based on the current execution status of the first business module among the multiple business modules;
[0036] It can be understood that recording the current execution status of the first business module provides a decision basis for subsequent steps through the determination of the status record information, ensuring the orderly execution of the business process and the correct interaction between modules. By binding the status information with the execution of the business module, dynamic control of the business process is achieved.
[0037] Optionally, the business module is the underlying business logic unit. Depending on the business functions, the business module can be a business form, business process, business report, business report, business interface, etc. It is determined according to the application scenario without specific limitation.
[0038] In an optional embodiment, determining the status record information includes: intercepting the status record method when it is detected that the status record method has been called, wherein the status record method is used by the first business module to perform status record in the database; and determining the status record information based on the status record method.
[0039] It can be understood that when the first business module completes its business logic and is ready to update the status in the database, it will call a specific method to perform status recording, namely the status recording method. In the AOP framework, these status recording methods can be "intercepted" by defining join points and aspects. This means that when the business module updates and records the current execution status, the AOP framework will first execute the predefined aspect logic to obtain the status recording information.
[0040] Step S104, querying according to the status record information to determine the target subject corresponding to the status record information;
[0041] It can be understood that after determining the status of the first business module, the aspect program will query the configuration center server (which can be referred to as the configuration center) to find the target topic corresponding to the current execution state. By querying the mapping relationship between the current execution state and the target topic, the aspect program can automatically select the correct topic (i.e., topic) in the message queue for message publishing according to the current business state. In this way, the dependence on hard coding is reduced, the flexibility and scalability of the business code are improved, and the adjustment of business processes is easier.
[0042] Optionally, the above configuration center server has the ability of real-time configuration, allowing the application configuration to be modified dynamically at runtime without restarting the application, and the configuration update takes effect immediately. Provide a unified interface and tools to manage configurations across multiple environments and applications, which is convenient for centralized monitoring and adjustment. Support configuration versioning, you can view historical versions, roll back configurations, and manage the change history of configurations. Support grayscale release of configurations, you can first release new configurations to a part of applications or environments, and then release them to the whole system after verification.
[0043] For ease of understanding, an example is given. For example, assuming that the current execution status is "First payment successful" and has been completed, find the target topic related to "Upload ticket agency file" from the configuration center. The target topic is subscribed to by the next business module such as "Agent Ticket Agency File Module", and the target file generated in the target topic can be received.
[0044] Step S106, controlling the generation of a target message in the target topic, wherein the target message is acquired by a second business module subscribed to the target topic, and the second business module executes a corresponding business process according to the target message, and the second business module belongs to multiple business modules.
[0045] It can be understood that once the target topic is determined, the aspect will generate and publish a target message to the topic. This message will be obtained by the second business module that subscribes to the topic. For example, the system may send a message containing the unique identifier of the incentive plan to the "Upload File" topic, and the subscriber of the topic (i.e., the second business module) will perform the file upload operation based on this message. By generating and publishing the target message, asynchronous communication and decoupling between business modules are achieved. The second business module can independently respond to messages and execute its business processes without being directly called by the first business module, which reduces the coupling between modules and allows each business module to be independently developed and maintained.
[0046] The business module calls the status recording method, which can be used to record and update the current execution status in the database. The interaction between the business module, the database and the aspect program is the core mechanism for realizing system modularization, dynamic configuration and asynchronous communication. When executing its business logic, the business module (such as the "first incentive issuance module") may need to interact with the database to update the data status. This interaction is achieved by calling database operation methods, such as query, update, insert status and other operations. The status update operation in the business module is particularly important. These operations will change the status value recorded in the database, thereby affecting the subsequent business process. The aspect program uses aspect programming technology (AOP) to dynamically insert additional logic in the process of interaction between the business module and the database. The aspect program listens to the status recording method in the business module (such as the method for updating the incentive issuance status) and triggers the aspect's after-returning advice logic when the status recording method is executed (that is, when the status recording method returns normally). The after-returning advice logic is responsible for querying the configuration in the configuration center to determine the target topic corresponding to the module that should be triggered next.
[0047] The aspect program does not directly modify the code logic of the business module or directly operate the database, but indirectly affects the behavior of the business module by defining the join point and aspect logic. The join point defines the specific locations or method calls to be intercepted, while the aspect defines the logic to be executed at these interception points. This design enables the aspect program to be loosely coupled with the business module and the database, that is, changes to the business module and the database will not directly affect the function of the aspect program, and changes to the aspect program will not directly destroy the core logic of the business module, improving the maintainability and scalability of the system.
[0048] As a component of configuration management, the configuration center works closely with the aspect program. The aspect program obtains dynamic configuration from the configuration center, such as the mapping relationship between the state value (i.e., the current execution state) and the target subject. The dynamic nature of the configuration of the configuration center server enables the system to support hot-swapping of modules, that is, dynamically adding, deleting, or replacing modules at runtime without restarting the entire system. When the status update of a business module triggers the post-notification of the aspect, the aspect program will determine the next business module to communicate based on the acquired status record information, and publish the message through a message.
[0049] Through the message queue, the communication between business modules is decoupled. When the aspect program generates a new message in the topic of the message queue through the message queue, the business module (such as the second business module) that subscribes to the main topic receives the message and continues to execute its business logic. Through the above method, the direct dependency between modules is reduced, and a close and flexible interaction mode is formed between the business modules, databases, aspect programs and configuration centers. As an intermediary, the aspect program ensures the coordination between the status update of the business module and the message publishing of the message queue. At the same time, the dynamic configuration of the configuration center is used to support the hot plugging of modules, realizing efficient, stable and flexible control of business processes. This interaction mechanism is a key component in building modern distributed and modular systems, which helps to improve the overall performance and maintainability of the system.
[0050] Optionally, the generation of the target message and its delivery in the target subject are based on changes in the business state. When a key state in the business process (such as the incentive issuance state) changes, the aspect program is triggered, the message body is constructed according to the new state information, and the target subject corresponding to the current state is obtained by querying the configuration center. The message body contains a unique identifier of the business state, such as the incentive issuance ID, status code, etc., which is set according to the specific business scenario to ensure the accuracy and traceability of the message. Once the target subject is determined, the message body will be sent to the target subject to achieve asynchronous communication between modules and state-driven process control. Not only does it ensure the orderly delivery of messages, but it also enhances the responsiveness and reliability of the system through the high throughput characteristics of the message queue.
[0051] In an optional embodiment, controlling generation of a target message in a target topic includes: determining a delay time for controlling message sending; and controlling generation of the target message in the target topic after waiting for the delay time.
[0052] It can be understood that a delay mechanism is added in the process of controlling the message to be sent to the target topic, and the configuration center server or the aspect program determines a delay duration according to business requirements or system policies. After determining the target topic (i.e., the message topic subscribed by the next business module) and the message content, the message will not be sent immediately, but will wait for the preset delay duration. This waiting process is to meet certain specific requirements, such as providing a time window for the system to process other tasks, waiting for certain conditions to mature, or avoiding a sudden increase in system load caused by an instantaneous influx of messages. By introducing a delay mechanism, delayed sending can provide a buffer time for performing other necessary operations related to the current business process, such as data verification, logging, notification sending, etc., to ensure the integrity and consistency of business logic. The introduction of a delay mechanism can also provide additional flexibility for system design, and the delay duration can be dynamically adjusted according to different business requirements and operating environments to adapt to different scenarios, such as low-latency transaction scenarios, high-concurrency data processing scenarios, etc.
[0053] Optionally, the delay time can be a fixed value set according to a predetermined time threshold, or can be dynamically calculated according to a certain type of data obtained in real time, and adjusted according to different business scenarios or system load conditions. The specific data type and specific dynamic calculation method are set according to different business scenarios and are not specifically limited.
[0054] In an optional embodiment, the method further includes: receiving abnormal prompt information, wherein the abnormal prompt information includes information indicating that the target message has not been successfully generated, or information indicating that the target message has not been consumed within a predetermined time period; based on the abnormal prompt information, controlling the regeneration of the target message in the target topic.
[0055] It can be understood that in the process of using message queues for communication between business modules, there are situations where messages fail to be successfully generated or are not consumed within the scheduled time. When the producer of the message queue tries to send a message to a specific topic (target topic), if a network failure, topic unavailability, permission problems or other errors are encountered, the producer will receive an exception prompt message indicating that the target message failed to be successfully generated. Similarly, if the consumer fails to consume the expected message within the scheduled time, an exception prompt message may also be generated, indicating that the message is delayed or lost. Once the aspect program detects the above exception prompt message, it will take corresponding recovery measures according to the specific cause of the exception. For example, if the target message fails to be successfully generated, the system will try to regenerate the message in the target topic to ensure that the subsequent modules can receive the correct information and continue to execute the business process. If the message is not consumed within the scheduled time, the system may increase the number of message retries or republish the message in the target topic to avoid business interruption caused by message loss.
[0056] Through the above processing, the message transmission process based on the message queue can be managed and controlled more effectively, ensuring that the business process can run stably and continuously in a complex and changeable distributed environment. By detecting and processing abnormal prompt information, failures in message transmission can be detected and recovered, avoiding business process interruptions caused by message sending or consumption failures, and significantly improving the reliability of communication between modules in distributed systems. Even in the event of component failures, network fluctuations or other unforeseen abnormal situations, the system can automatically recover, reducing the impact of failures on business processes and improving the fault tolerance and stability of the overall system.
[0057] Through the above step S102, the state record information is determined, wherein the state record information is determined based on the current execution state of the first business module among multiple business modules; step S104, query according to the state record information, and determine the target topic corresponding to the state record information; step S106, control the generation of the target message in the target topic, wherein the target message is obtained by the second business module subscribed to the target topic, and the second business module executes the corresponding business process according to the target message, and the second business module belongs to multiple business modules. The purpose of decoupling business modules from each other can be achieved, and the technical effect of promoting the reuse and maintainability of business codes and improving the efficiency of business code adjustment is achieved, thereby solving the technical problems of high coupling of business architecture and unsatisfactory efficiency of business code adjustment existing in related technologies.
[0058] A service interaction method is also provided in an embodiment of the present application. The service interaction system provided in an embodiment of the present application is introduced below. Figure 2 is a second flow chart of the business interaction method according to an embodiment of the present application, and the execution body may include: a first business module, a second business module, and a section program, such as Figure 2 As shown, the method comprises the following steps:
[0059] Step S202, a first business module among the multiple business modules generates state record information based on the current execution state;
[0060] It can be understood that as one of the multiple business modules, the first business module will generate status record information reflecting the current execution status after executing its business logic. The status record information is the basis for subsequent process control. By recording the execution status of the module, it can be determined how the next business process should proceed, thus realizing state-driven dynamic process control.
[0061] Step S204, the aspect program determines the state record information; performs a query according to the state record information to determine the target topic corresponding to the state record information; and controls the generation of the target message in the target topic;
[0062] It can be understood that the aspect program obtains the status record information, and then determines the target topic based on the query of the status record information, so that the business module is decoupled from the subsequent processing link, and there is no need to hard-code the call to the next business module, which improves the flexibility and maintainability of the business code. The aspect program realizes asynchronous communication between the business module and the downstream module by controlling the generation of the target message in the target topic. Dynamic configuration and hot plugging: The aspect program uses the dynamically configured configuration center to determine the target topic, so that the system can dynamically adjust the process sequence or add new modules at runtime, supports hot plugging of modules, and enhances the scalability of the system.
[0063] In an optional embodiment, a query is performed according to the status record information to determine the target subject corresponding to the status record information, including: the aspect program queries the configuration center server according to the status record information; the configuration center server performs query processing based on a predetermined mapping relationship, determines the target subject, and feeds back the target subject to the aspect program.
[0064] It can be understood that the configuration center server, as the central configuration manager of the system, can perform query processing based on predetermined mapping relationships. Even at runtime, the mapping relationship between states and topics can be quickly adjusted according to changes in business needs without modifying the application code. This dynamic configuration capability enables the system to respond more flexibly to changes in business processes, such as module additions, deletions, or changes in the order of communication between modules. By querying the target topic from the configuration center server through the aspect program, the business module does not need to directly hard-code the topic name, which further reduces the coupling between modules. As an intermediary, the aspect program is responsible for obtaining the target topic from the configuration center and controlling the sending of messages, so that each module can run and maintain more independently, improving scalability and maintainability.
[0065] Optionally, the query processing logic of the configuration center server may include an error handling mechanism, for example, when a corresponding topic cannot be found or the server fails, a default topic may be returned or the query may be retried with a delay.
[0066] Optionally, introducing a configuration center server helps optimize the load balancing of the message queue and avoids excessive load on a single topic by properly allocating and managing topics.
[0067] In an optional embodiment, the method also includes: configuring a central server to determine a mapping relationship between different status information and corresponding message topics based on business interaction requirements; in the event that the business interaction requirements change, adjusting the message topics subscribed to by multiple business modules based on the changed business interaction requirements; adjusting the mapping relationship based on the changed business interaction requirements to obtain an adjusted mapping relationship.
[0068] It can be understood that the configuration center server is used to dynamically adjust the message topic mapping relationship between modules to adapt to changes in business interaction requirements. The configuration center server can determine the mapping relationship between different state information (such as the execution status of the business module) and the corresponding message topic based on the current business interaction requirements. The association between the state and the topic can be flexibly defined and adjusted according to different business scenarios without modifying the code of the business module. When the business interaction requirements change, the configuration center can respond to these changes immediately and adjust the mapping relationship. Such real-time update capabilities can quickly adapt to changes in business processes, such as the addition of new modules, the adjustment of module order, or the removal of abandoned modules, without affecting the normal operation of the system. The configuration center server not only adjusts the mapping relationship, but also dynamically adjusts the subscription relationship of the business module. If the business interaction requirements cause the business module to subscribe to new topics or no longer subscribe to certain topics, the configuration center can update this information in real time to ensure that the list of topics subscribed by each module is consistent with the latest business process requirements.
[0069] By adjusting the mapping relationship based on the changed business needs, the system where multiple business modules are located can easily cope with the evolution of business logic, such as process optimization, integration of new business, etc. This flexibility reduces the number of times the system is restructured or redeployed, and reduces maintenance costs.
[0070] Optionally, the ability to dynamically adjust subscription relationships supports hot swapping of modules. New modules can be added to the system and automatically subscribe to the required message topics without interrupting existing business processes. Similarly, modules that are no longer needed can be removed and their subscribed topics are updated accordingly from the configuration, enabling smooth upgrades and expansions of the system.
[0071] Step S206: The second business module among the multiple business modules obtains the target message through the subscribed target topic; and executes the corresponding business process according to the target message.
[0072] It can be understood that the second business module subscribes to the target topic determined by the first business module. Once the target message is sent, the second business module can automatically receive the message and perform responsive processing without active polling, which reduces business interaction resource consumption and delay. It should be noted that the standardization and structuring of messages (i.e., target messages) ensure the consistency and comprehensibility of communication between business modules. Each module only needs to pay attention to the message format of its subscribed topic, which simplifies the complexity of interaction between modules.
[0073] Through the above step S202, the first business module among the multiple business modules generates state record information based on the current execution state; step S204, the aspect program determines the state record information; performs a query according to the state record information to determine the target topic corresponding to the state record information; controls the generation of the target message in the target topic; step S206, the second business module among the multiple business modules obtains the target message through the subscribed target topic; and executes the corresponding business process according to the target message. The purpose of decoupling business modules from each other can be achieved, and the technical effect of promoting the reuse and maintainability of business codes and improving the efficiency of business code adjustment can be achieved, thereby solving the technical problems of high coupling of business architecture and unsatisfactory efficiency of business code adjustment existing in related technologies.
[0074] Based on the above embodiments and optional embodiments, the present application proposes an optional implementation method, which uses message queues to implement asynchronous communication between modules, supports high throughput and data persistence, and ensures reliable message delivery. Through AOP (Aspect-Oriented Programming) technology, aspect logic is dynamically inserted after the business module method call to monitor state changes and trigger message sending. Dynamic configuration management is provided to allow the configuration information of module interactions to be updated at runtime, such as the mapping between state record information and message topics.
[0075] Assuming that the application scenario of "issuing incentives to agents" is a distributed system business process, the business process is subdivided into four key steps, and each step is handled by an independent module. The four business modules of the above application scenario include: the first incentive issuance module, the agent ticket file upload module, the second incentive issuance module, and the full processing completion module. The above processing process is not a commercial method, but only an example based on common business in the field of financial technology, and can also be other business processes.
[0076] Figure 3 is a schematic diagram of an optional service interaction method provided according to an embodiment of the present application, such as Figure 3As shown in the figure, the business requirement is the agent incentive issuance process. The modules in each stage are developed independently, and loosely coupled asynchronous communication is carried out through message queues. The configuration center dynamically manages the mapping relationship between the modules in each stage and the message topics, and supports changes in the process sequence and the addition and deletion of modules. The aspect monitors the module status update. When the current execution status of the business module changes, the message is automatically triggered to achieve orderly communication between modules.
[0077] Step S1, configure the mapping relationship between the state record information and the target subject to the configuration center.
[0078] Step S2, scheduled task polling processing, the status of the scheduled task is updated to the start of issuance, the aspect program is triggered, the mapping relationship between the status record information and the message topic in the configuration center is queried, and the message is generated in the corresponding message topic. By subscribing to the message topic, the first incentive issuance module can receive the above-mentioned generated message.
[0079] Step S3, the first incentive issuance module receives the message, processes and updates the status to the first issuance is successful, triggers the aspect program to query the configuration center, triggers the generation of a message in the corresponding message topic, and similarly, through the subscription-consumption mechanism of the message queue, the ticket upload file module can receive the message.
[0080] The first incentive payment module is responsible for starting the entire incentive payment process, and automatically or manually triggers the first incentive payment to agents based on preset conditions or rules (such as when the agent's performance reaches a certain standard). The first incentive payment module will check the initial conditions for incentive payment, generate incentive payment tasks, and update the current execution status to the database. When the status recording method call is completed, the post-notification of the aspect program is triggered, and then the aspect program sends the message to the next processing module (the agent ticket file upload module) through the message queue according to the mapping relationship stored in the configuration center.
[0081] Step S4, the ticket upload file module receives the message, processes the file upload, and updates the status to the successful file upload, triggering the post-notification of the aspect program. Similarly, through the subscription-consumption mechanism of the message queue, the second incentive issuance module can receive the message. The ticket upload file module is responsible for uploading and verifying the file to ensure that all necessary files have been submitted and passed the review. After the file is successfully uploaded and verified, the ticket upload file module will update the status to the database, and also trigger the aspect program to send the message to the next business module, that is, the second incentive issuance module, by querying the mapping relationship in the configuration center.
[0082] Step S5, the second incentive issuance module, based on the file upload and verification results of the previous module (the ticket file upload module), processes the subsequent incentive issuance. If multiple incentive issuances are required according to specific rules or time points after the first incentive issuance, such as quarterly or annual additional rewards. The second incentive issuance module will check all preconditions (such as the task status of the previous module, file verification results, etc.), and according to the mapping relationship of the configuration center server, through the subscription and consumption mechanism of the message queue, the next module (i.e., the module that completes all processing) obtains information through the subscribed message topic.
[0083] Step S6, the full processing completion module is responsible for monitoring and confirming the completion status of the entire incentive issuance process. The full processing completion module will update the final completion status record to the database as the final record of the entire incentive issuance process for auditing, reporting or subsequent business processing. The status record method call of the full processing completion module also triggers the aspect program. Since the corresponding target subject cannot be found in the configuration center, the process processing will be terminated.
[0084] The above optional implementation methods achieve at least the following effects: The modular interaction method using aspects supports the independent development of modules, promotes code reuse and maintainability, and by defining aspects and pointcuts and weaving them into the module methods, dynamic injection of aspect logic can be achieved without repeatedly changing the module code. Message queues are used as message middleware to implement asynchronous communication between modules, and loose coupling is achieved between modules, achieving independent interaction, increasing throughput, and improving interaction efficiency. Combined with the real-time configuration feature of the configuration center, the configuration can be managed dynamically, and the interaction order of modules can be switched, added, deleted, etc. in real time, so that the system can be easily expanded by adding or deleting modules without affecting the overall system function.
[0085] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0086] In this embodiment, a service interaction device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the terms "module" and "device" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0087] According to an embodiment of the present application, a device embodiment for implementing a service interaction method is also provided. Figure 4is a schematic diagram of a service interaction device according to an embodiment of the present application, such as Figure 4 As shown, the above-mentioned service interaction device includes: a state determination module 402, a query module 404, and a message queue processing module 406. The device is described below.
[0088] A state determination module 402, used to determine state record information, wherein the state record information is determined based on a current execution state of a first business module among the multiple business modules;
[0089] A query module 404, connected to the status determination module 402, is used to query according to the status record information to determine the target subject corresponding to the status record information;
[0090] The message queue processing module 406 is connected to the query module 404 and is used to control the generation of a target message in the target topic, wherein the target message is obtained by the second business module that subscribes to the target topic, and the second business module executes the corresponding business process according to the target message. The second business module belongs to multiple business modules.
[0091] In a business interaction device provided by an embodiment of the present application, a state determination module 402 is set to determine state record information, wherein the state record information is determined based on the current execution state of the first business module among multiple business modules; a query module 404 is connected to the state determination module 402, and is used to query according to the state record information to determine the target topic corresponding to the state record information; a message queue processing module 406 is connected to the query module 404, and is used to control the generation of a target message in the target topic, wherein the target message is obtained by the second business module that subscribes to the target topic, and the second business module executes the corresponding business process according to the target message, and the second business module belongs to multiple business modules. The purpose of decoupling business modules from each other is achieved, and the technical effect of promoting the reuse and maintainability of business codes and improving the efficiency of business code adjustment is achieved, thereby solving the technical problems of high coupling of business architecture and unsatisfactory efficiency of business code adjustment existing in related technologies.
[0092] It should be noted that the above modules can be implemented by software or hardware. For example, for the latter, it can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.
[0093] It should be noted that the above-mentioned state determination module 402, query module 404, and message queue processing module 406 correspond to steps S102 to S106 in the embodiment, and the examples and application scenarios implemented by the above-mentioned modules and corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment. It should be noted that the above-mentioned modules can be run in a computer terminal as part of the device.
[0094] It should be noted that the optional or preferred implementation of this embodiment can refer to the relevant description in the embodiment, which will not be repeated here.
[0095] The above-mentioned business interaction device may also include a processor and a memory. The state determination module 402, the query module 404, the message queue processing module 406, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to implement corresponding functions.
[0096] The processor includes a kernel, which retrieves the corresponding program unit from the memory. There can be one or more kernels. The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0097] An embodiment of the present application provides a non-volatile storage medium on which a program is stored, and when the program is executed by a processor, a business interaction method is implemented.
[0098] The embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program stored in the memory and can be run on the processor. When the processor executes the program, the following steps are implemented: determining status record information, wherein the status record information is determined based on the current execution status of the first business module among multiple business modules; querying according to the status record information to determine the target topic corresponding to the status record information; controlling the generation of a target message in the target topic, wherein the target message is obtained by the second business module that subscribes to the target topic, and the second business module executes the corresponding business process according to the target message, and the second business module belongs to multiple business modules. The device in this article can be a server, a PC, etc.
[0099] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the following method steps: determining status record information, wherein the status record information is determined based on the current execution status of a first business module among multiple business modules; querying according to the status record information to determine a target topic corresponding to the status record information; controlling the generation of a target message in the target topic, wherein the target message is obtained by a second business module that has subscribed to the target topic, and the second business module executes the corresponding business process according to the target message, and the second business module belongs to multiple business modules.
[0100] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0104] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0105] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0106] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0107] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0108] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0109] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A business interaction method, characterized in that: include: Determining state record information, wherein the state record information is determined based on a current execution state of a first business module among the multiple business modules; Searching according to the status record information to determine the target subject corresponding to the status record information; Controlling generation of a target message in the target topic, wherein the target message is acquired by a second business module subscribed to the target topic, the second business module executes a corresponding business process according to the target message, and the second business module belongs to the multiple business modules.
2. The method according to claim 1, characterized in that The determination status record information includes: When it is detected that the status recording method is called, the status recording method is intercepted, wherein the status recording method is used for the first business module to record the status in the database; Based on the status recording method, the status recording information is determined.
3. The method according to claim 1, characterized in that The controlling generates a target message in the target topic, comprising: Determine the delay length used to control message sending; After waiting the delay period, control generates the target message in the target topic.
4. The method according to claim 1, characterized in that The method further comprises: Receiving abnormal prompt information, wherein the abnormal prompt information includes information indicating that the target message has not been successfully generated, or information indicating that the target message has not been consumed within a predetermined time period; Based on the abnormal prompt information, control is performed to regenerate the target message in the target topic.
5. The method according to any one of claims 1 to 4, characterized in that: The querying according to the status record information to determine the target subject corresponding to the status record information includes: According to the state record information, a query is performed based on a predetermined mapping relationship to determine the target subject, wherein the mapping relationship is configured on a configuration center server.
6. A business interaction method, characterized in that: include: A first business module among the multiple business modules generates state record information based on a current execution state; The aspect procedure determines the state record information; Search according to the state record information to determine the target topic corresponding to the state record information; control the generation of a target message in the target topic; The second business module among the multiple business modules obtains the target message by subscribing to the target topic; and executes the corresponding business process according to the target message.
7. The method according to claim 6, characterized in that The querying according to the status record information to determine the target subject corresponding to the status record information includes: The aspect program queries the configuration center server according to the status record information; The configuration center server performs query processing based on a predetermined mapping relationship, determines the target subject, and feeds back the target subject to the aspect program.
8. The method according to claim 7, characterized in that The method further comprises: The configuration center server determines the mapping relationship between different status information and corresponding message topics based on business interaction requirements; When the business interaction requirements change, adjusting the message topics to which the multiple business modules are subscribed respectively based on the changed business interaction requirements; Based on the changed business interaction requirements, the mapping relationship is adjusted to obtain an adjusted mapping relationship.
9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the service interaction method described in any one of claims 1 to 8.
10. An electronic device, characterized in that: include: One or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the business interaction method described in any one of claims 1 to 8.
Citation Information
Cited By
Business linkage processing method and device of enterprise information system, computer program product and readable storage medium
CN121764519A