Message Passing Method, Device, Equipment and Storage Medium in a Test Environment
By analyzing message pull requests in the test environment of a distributed system, determining the environment type and querying messages in the benchmark environment and characteristic environment, intelligent routing of messages is realized, solving the problem that each test environment in the existing technology needs to independently configure and maintain message middleware, reducing costs and improving efficiency.
Patent Information
- Application Number
- CN202311708372.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2043-12-12
AI Technical Summary
In the testing environment of distributed systems, the prior art requires the establishment and maintenance of independent message middleware for each test environment, resulting in high configuration and maintenance costs.
By obtaining the message pull request in the test environment, parsing the request to determine the environment type and message attributes. If it is a benchmark environment, query messages in the benchmark environment and feature environment to realize intelligent routing of messages and avoid configuring and maintaining message middleware separately for each test environment.
It realizes intelligent routing of messages, reduces the cost of message delivery, avoids excessive dependence on message middleware, and improves message delivery efficiency in the test environment.
Smart Images

Figure CN117632546B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, specifically to the fields of asynchronous communication, distributed systems, microservices, information flow processing, etc., and particularly relates to a message passing method, apparatus, device, and storage medium in a test environment. Background Art
[0002] In a distributed system, message middleware is required for message passing between different services. Messages produced by a producer reach the message middleware, and the message middleware actively pushes the message to a consumer, or the consumer actively pulls the message from the message middleware.
[0003] Distributed systems can be applied to different test environments. To ensure accurate message passing in each test environment, a message middleware can be separately established under each test environment, and the message middleware under each test environment can be separately configured and maintained.
[0004] However, the cost of configuring and maintaining the message middleware in the above manner is relatively high. Summary of the Invention
[0005] The present disclosure provides a message passing method, apparatus, device, and storage medium in a test environment for reducing the cost of message passing.
[0006] According to a first aspect of the present disclosure, there is provided a message passing method in a test environment, including: obtaining a message pull request of a first service in a first test environment; parsing the message pull request to determine the environment type of the first test environment and the attribute information of the message to be pulled; if the environment type of the first test environment is a reference environment, querying to obtain a first message corresponding to the attribute information, the first message including messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed, all services in the distributed system are deployed in the reference environment, and some services in the distributed system are deployed in the characteristic environment; and sending the first message to the first service.
[0007] According to a second aspect of the present disclosure, there is provided a message passing device in a test environment, including: a pull request acquisition unit configured to acquire a message pull request of a first service in a first test environment; a pull request parsing unit configured to parse the message pull request to determine an environment type of the first test environment and attribute information of the message to be pulled; a first query unit configured to, if the environment type of the first test environment is a reference environment, query and obtain a first message corresponding to the attribute information, where the first message includes messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed, all services in the distributed system are deployed in the reference environment, and part of the services in the distributed system are deployed in the characteristic environment; and a first sending unit configured to send the first message to the first service.
[0008] According to a third aspect of the present disclosure, there is provided an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the message passing method in the test environment according to the first aspect.
[0009] According to a fourth aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause the computer to execute the message passing method in the test environment according to the first aspect.
[0010] According to a fifth aspect of the present disclosure, there is provided a computer program product, where the computer program product includes: a computer program stored in a readable storage medium, and at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the electronic device to execute the message passing method in the test environment according to the first aspect.
[0011] According to the technical solution provided by the present disclosure, obtain a message pulling request for a first service in a first test environment; parse the message pulling request to determine the environment type of the first test environment and the attribute information of the message to be pulled; if the environment type of the first test environment is a reference environment, query and obtain a first message corresponding to the attribute information, where the first message includes messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed; send the first message to the first service. In this way, based on the environment information of the test environment and the attribute information of the message to be pulled, intelligent routing of messages is achieved, and messages corresponding to the attribute information produced in the reference environment and in the characteristic environment where the first service is not deployed can be routed to the first service. There is no need to configure and maintain independent message middleware for each test environment, the dependence on message middleware for message transmission is eliminated, and the cost of message transmission is reduced.
[0012] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. Brief Description of the Drawings
[0013] The drawings are used to better understand the solution and do not constitute a limitation to the present disclosure. Among them:
[0014] Figure 1 is a schematic diagram of an application scenario applicable to the present disclosure;
[0015] Figure 2 is a schematic diagram according to the first embodiment of the present disclosure;
[0016] Figure 3 is a schematic diagram according to the second embodiment of the present disclosure;
[0017] Figure 4 is a schematic diagram according to the third embodiment of the present disclosure;
[0018] Figure 5 is an architecture example provided according to the above embodiments of the present disclosure Figure 1 ;
[0019] Figure 6 is an architecture example provided according to the above embodiments of the present disclosure Figure 2 ;
[0020] Figure 7 is an architecture example provided according to the above embodiments of the present disclosure Figure 3 ;
[0021] Figure 8 is a flowchart example of the message transmission method provided according to the above embodiments of the present disclosure;
[0022] Figure 9It is a schematic diagram according to the fourth embodiment of the present disclosure;
[0023] Figure 10 It is a schematic block diagram of an exemplary electronic device 1000 that can be used to implement the embodiments of the present disclosure. Detailed implementation manners
[0024] The following describes exemplary embodiments of the present disclosure with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, descriptions of well-known functions and structures are omitted for clarity and conciseness.
[0025] First, the application scenario and basic concepts are explained.
[0026] In a distributed system, a message queue can be used to implement message passing between services. Application scenarios of the message queue include, for example, asynchronous processing, traffic control (for example, when the pressure on the message consumer is too high, the message queue can control the message delivery speed so that the message delivery speed can match the consumption speed of the consumer), service decoupling (service a passes a message to the message queue, and the message queue then passes the message to service b to achieve decoupling between service a and service b), etc. Many business scenarios can use a message queue to implement asynchronous communication, such as post-publication processing (first passing the article to be published to the message queue, and after the article passes through processes such as verification and review, the consumer pulls the article from the message queue), deduction of times (after a user publishes an article, passing the deduction message of the publication times to the message queue, and after the article is successfully published, the deduction service pulls the deduction message from the message queue), modification of the write database (passing the modification message of the database to the message queue, and then the modification service pulls the modification message from the message queue), synchronization operation (passing the synchronization message of the data to the message queue, and then the synchronization service pulls the synchronization message from the message queue), change flow (passing the state change of each step of the article to the message queue to form a change flow, and after the material library receives the change flow, it changes the state of the article), etc.
[0027] Among them, the message queue can be implemented through message middleware.
[0028] The message middleware can adopt the push mode and / or the pull mode. Among them, the push mode is also called the delivery mode. When a message arrives, the message queue actively pushes the message to the consumer. It has good real-time performance, and the consumer can get the latest message in time. However, it is difficult to control the push efficiency, and message backlogs are likely to occur when the consumer has a high load and slow message processing speed. It is suitable for scenarios with a small amount of messages, strong consumption capabilities, and high real-time requirements. The pull mode is also called the retrieval mode. The consumer can actively pull messages from the message middleware according to its own processing capabilities and load conditions, avoiding excessive message processing pressure on the consumer. This method has lower real-time performance and message latency and is suitable for scenarios where message order and message delivery reliability need to be ensured.
[0029] Among them, the pull mode can include the subscription method based on the topic and the subscription method based on the queue. The comparison between the subscription method based on the topic and the subscription method based on the queue is shown in Table 1 below:
[0030] Table 1
[0031]
[0032] Among them, ack is the confirmation message, indicating that the data has been successfully pulled, and the data is the message.
[0033] Based on the above description, it can be seen that there are the following deficiencies in the message delivery based on the message middleware:
[0034] 1. In the actual test scenario, according to the dimension of the test environment, a separate message middleware is established, configured, and maintained for each test environment to achieve message isolation between different test environments. The pull mode can include the subscription method based on the topic and the subscription method based on the queue. In each set of environments, the creation, configuration, and maintenance of topics and queues are required. After the architecture of the distributed system is microservitized, the resources and human costs invested in the message middleware further increase.
[0035] 2. The message delivery is overly dependent on the message middleware developed within the organization. Once a failure occurs, the asynchronous communication link of the test service will be disconnected, and the test development work will be blocked and unable to proceed;
[0036] 3. The message middleware cannot implement intelligent routing of messages.
[0037] To address the above deficiencies, the present disclosure proposes a message passing method in a test environment, which relates to the field of computer technology, specifically to asynchronous communication, distributed systems, microservices, information flow processing, and other technical fields, and can be applied to application scenarios suitable for message queues (see the foregoing description for details). In this method, the test environment is divided according to the environment type, including a baseline environment and a feature environment. All services in the distributed system are deployed in the baseline environment, and some services in the distributed system are deployed in the feature environment. When a service requests to pull a message, an appropriate message can be found based on the type of the environment where the service is located and the attribute information of the message to be pulled, and sent to the service, realizing intelligent routing of messages. There is no need to deploy independent message middleware for different test environments, reducing resource investment and costs. The present disclosure can be implemented through a message passing service and does not rely on message middleware.
[0038] It should be noted that the present disclosure only improves the pull mode.
[0039] Figure 1 It is a schematic diagram of an application scenario applicable to the present disclosure. In this application scenario, there are a message passing service 110 and a distributed system 120. Multiple services are deployed in the distributed system 120, such as Figure 1 Service a, service b, service c, and service d in. For the distributed system 120, the test environment can include a baseline environment and a feature environment. All services in the distributed system 120 are deployed in the baseline environment, such as: service a, service b, service c, and service d; there can be one or more feature environments. Some services in the distributed system 120 can be deployed in one feature environment, such as Figure 1 Service a is deployed in feature environment A, service a and service b are deployed in feature environment B, and service c and service d are deployed in feature environment C. Specifically, the feature environment corresponds to the project, and the services to be tested in the project are deployed in the feature environment, that is, the services that need to be changed in the project.
[0040] In the joint debugging test of the distributed system 120, not only the services deployed in the feature environment are used, but also the services deployed in the baseline environment are used. For example, not only the services a and b deployed in feature environment B are used, but also services c and d are used. Services c and d are not deployed in feature environment B and need to multiplex services c and d deployed in the baseline environment.
[0041] The services deployed in the baseline environment can be either consumers or producers. The services deployed in the baseline environment can consume messages produced by other services in the baseline environment. Since the services deployed in the baseline environment will be multiplexed during the test process, the services deployed in the baseline environment can also consume messages produced by the services deployed in the feature environment where the service is not deployed. For example, as Figure 1As shown, when the message passing service 110 pulls a message for Service A in the baseline environment, it can send the message produced by Service B in the baseline environment to Service A in the baseline environment, or it can send the message produced by Service C in Feature Environment C to Service A in the baseline environment.
[0042] The services deployed in the feature environment can act as consumers or producers. The services deployed in the feature environment can consume the messages produced by other services in the same feature environment. For example, as Figure 1 shown, when the message passing service 110 pulls a message for Service A in Feature Environment B, it can send the message produced by Service B in Feature Environment B to Service A in Feature Environment B.
[0043] Among them, the distributed system can adopt a microservices architecture, and the service can refer to a microservice.
[0044] The embodiments of the present disclosure can be implemented on a terminal and / or a server. Among them, the terminal can be a personal digital assistant (PDA) device, a handheld device with wireless communication functions (such as a smart phone, a tablet computer), a computing device (such as a personal computer (PC)), a wearable device (such as a smart watch, a smart bracelet), and a smart home device (such as a smart speaker, a smart display device), etc. The server can be an independent server or a server cluster, and can be a local server or a cloud server.
[0045] The following uses specific embodiments to elaborate in detail on the technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of the present disclosure with reference to the accompanying drawings.
[0046] Figure 2 is a schematic diagram according to the first embodiment of the present disclosure. As Figure 2 shown, the message passing method in the test environment provided by the first embodiment of the present disclosure includes:
[0047] S201, obtain a message pull request of a first service in a first test environment.
[0048] Among them, the message pull request may include the environment information of the first test environment and the attribute information of the message to be pulled, so as to request to pull a message that conforms to the environment information of the first test environment and the attribute information of the message to be pulled. The environment information of the first test environment can reflect the environment type of the first test environment.
[0049] In this embodiment, a message pull request of a first service in a first test environment can be received, or a message pull request of a first service in a first test environment can be obtained from a message queue composed of multiple message pull requests. At this time, the first service in the first test environment is equivalent to a consumer of the message.
[0050] S202. Analyze the message pull request of the first service in the first test environment to determine the environment type of the first test environment and the attribute information of the message to be pulled.
[0051] In this embodiment, by analyzing the message pull request of the first service in the first test environment, the environment information of the first test environment and the attribute information of the message to be pulled can be obtained. Based on the environment information of the first test environment, the environment type of the first test environment information can be determined.
[0052] In a possible implementation manner, the environment information of the first test environment includes the environment type of the first test environment. By analyzing the message pull request of the first service in the first test environment, the environment type of the first test environment and the attribute information of the message to be pulled are obtained.
[0053] In another possible implementation manner, the environment information of the first test environment includes the environment identifier of the first test environment. By analyzing the message pull request of the first service in the first test environment, the environment identifier of the first test environment and the attribute information of the message to be pulled are obtained. The environment identifier of the first test environment is compared with the environment identifiers of multiple test environments to determine that the environment type of the first test environment is the environment type of the test environment whose environment identifier is the same as that of the first test environment. Among them, different test environments correspond to different environment identifiers. Determining the environment type of the first test environment based on the environment identifier can improve the accuracy of determining the environment type of the first test environment.
[0054] S203. If the environment type of the first test environment is a reference environment, query and obtain the first message corresponding to the attribute information. The first message includes the message produced in the reference environment and the message produced in the characteristic environment where the first service is not deployed. All services in the distributed system are deployed in the reference environment, and some services in the distributed system are deployed in the characteristic environment.
[0055] Among them, the baseline environment and the feature environment are test environments based on a distributed system. In the case where the distributed system adopts a microservices architecture, the baseline environment and the feature environment are test environments based on microservices and are test environments that support multiplexing. The baseline environment can also be called the base environment, and a baseline environment can be built based on all services in the distributed system; the feature environment can also be called the feature environment, and corresponding feature environments can be built for multiple projects respectively. The services to be tested in the project are deployed in the feature environment corresponding to the project, that is, the services to be changed (such as to be upgraded) in the project. For the services that do not need to be changed in the project, the services deployed in the baseline environment can be reused during project testing.
[0056] In this embodiment, if the environment type of the first test environment is the baseline environment, then the first service can pull the messages produced in the first test environment to implement message routing in the same environment; since for the services not deployed in the feature environment, the services deployed in the baseline environment can be reused during the test process, the first service can also pull the messages produced in the feature environment where the first service is not deployed. In addition, the messages pulled by the first service also need to conform to the attribute information of the messages to be pulled. Therefore, based on the environment types corresponding to multiple messages and the attribute information corresponding to multiple messages respectively, messages corresponding to the corresponding attribute information produced in the baseline environment and messages corresponding to the corresponding attribute information produced in the feature environment where the first service is not deployed can be queried and obtained from the multiple messages to obtain the first message. The environment type corresponding to a message refers to the environment type of the test environment where the producer of the message is located when producing the message.
[0057] Optionally, if the environment type of the first test environment is the baseline environment, then the first message corresponding to the corresponding attribute information can be queried and obtained in the message database. The message database can store the message content of the message, the attribute information of the message, and the environment information corresponding to the message. The environment information corresponding to the message reflects the environment type of the test environment where the producer of the message is located. Thus, based on the message database, the first message can be accurately queried, improving the accuracy of message transmission.
[0058] S204, send the first message to the first service.
[0059] In this embodiment, after the first message is queried, the first message is sent to the first service to implement routing the first message from the producer (the service in the baseline environment or the service in the feature environment where the first service is not deployed) to the consumer (i.e., the first service).
[0060] In the embodiments of the present disclosure, a message passing method in a pull mode is provided. In a first test environment, a first service actively requests to pull messages through a message pull request. When the environment type of the first test environment is a benchmark environment, messages corresponding to attribute information produced in the benchmark environment and messages corresponding to attribute information produced in a characteristic environment where the first service is not deployed are sent to the first service. On the one hand, accurate message passing in the benchmark environment is achieved; on the other hand, considering the multiplexing of services deployed in the benchmark environment during testing, for services not deployed in the characteristic environment, the service deployed in the benchmark environment can pull messages produced in that characteristic environment. In this way, intelligent routing of messages in the same and different test environments is achieved. The embodiments of the present disclosure can be implemented through a message passing service or a message middleware. Different types of test environments can share the same message passing service or message middleware, eliminating the need to separately configure and maintain message middleware for each test environment, thus reducing costs.
[0061] Figure 3 It is a schematic diagram according to the second embodiment of the present disclosure. As Figure 3 shown, the message passing method in the test environment provided by the second embodiment of the present disclosure includes:
[0062] S301, obtain a message pull request of a first service in a first test environment.
[0063] Among them, the implementation principle and technical effect of S301 can be referred to the foregoing embodiments and will not be elaborated here.
[0064] In a possible implementation manner, a message pull request of a first service in a first test environment can be received through a message pull interface. The message pull interface is an interface for requesting to pull messages, and the first service can call this interface to implement the call of the message passing method provided in this embodiment.
[0065] S302, analyze the message pull request of the first service in the first test environment to determine the environment type of the first test environment and the attribute information of the message to be pulled.
[0066] Among them, the implementation principle and technical effect of S302 can be referred to the foregoing embodiments and will not be elaborated here.
[0067] In a possible implementation manner, the message header in the message pull request includes the environment information of the first test environment and the attribute information of the message to be pulled. The message header in the message pull request can be analyzed to obtain the environment information of the first test environment and the attribute information of the message to be pulled, and the environment type of the first test environment can be determined according to the environment information of the first test environment. Thus, the environment type of the first test environment and the attribute information of the message to be pulled are obtained through the analysis of the message header.
[0068] Further, the environmental information of the first test environment includes the environmental type of the first test environment. The message header in the message pulling request can be parsed to obtain the environmental type of the first test environment and the attribute information of the message to be pulled.
[0069] Further, the environmental information of the first test environment includes the environmental identifier of the first test environment. The message header in the message pulling request can be parsed to obtain the environmental identifier of the first test environment and the attribute information of the message to be pulled; compare the environmental identifier of the first test environment with the environmental identifiers of multiple test environments to determine that the environmental type of the first test environment is the environmental type of the test environment whose environmental identifier is the same as that of the first test environment. Thus, based on the environmental identifier of the first test environment, the accuracy of determining the environmental type of the first test environment is improved.
[0070] S303, if the environmental type of the first test environment is the benchmark environment, then query to obtain the messages produced in the benchmark environment and the messages produced in the feature environment where the first service is not deployed as candidate messages.
[0071] In this embodiment, if the environmental type of the first test environment is the benchmark environment, among the multiple messages produced in the benchmark environment, query to obtain the messages produced in the benchmark environment; in the feature environment, query to obtain the feature environment where the first service is not deployed, and obtain the messages produced in the feature environment where the first service is not deployed. The messages produced in the benchmark environment and the messages produced in the feature environment where the first service is not deployed are determined as candidate messages.
[0072] In a possible implementation manner, based on the correspondence between the first service and the feature environment, query in the feature environment to obtain the feature environment where the first service is not deployed. Among them, the correspondence between the first service and the feature environment may include the environmental identifier of the feature environment where the first service is deployed corresponding to the first service or the environmental identifier of the feature environment where the first service is not deployed corresponding to the first service.
[0073] In another possible implementation manner, querying the messages produced in the feature environment where the first service is not deployed includes: obtaining the service deployment information corresponding to the feature environment, where the service deployment information includes the service identifiers of all services deployed in the feature environment; according to the service deployment information corresponding to the feature environment, query in the feature environment to obtain the feature environment where the first service is not deployed; obtain the messages produced in the feature environment where the first service is not deployed. Thus, based on the service deployment information corresponding to the feature environment, the accuracy of querying the feature environment where the first service is not deployed is improved.
[0074] Among them, there can be multiple characteristic environments, and each of the multiple characteristic environments can correspond to service deployment information. The service deployment information corresponding to a characteristic environment can be a service list or a service set corresponding to the characteristic environment, and the service identifiers of all services deployed in the characteristic environment are included in the service list or the service set.
[0075] In this implementation manner, the service identifier of the first service can be included in the message pull request. Based on the service deployment information corresponding to the characteristic environment, the service identifier of the first service can be matched with the service identifiers of all services deployed in the characteristic environment, and based on the matching result, the characteristic environment in which the first service is not deployed can be queried in the characteristic environment. Furthermore, the messages produced in the characteristic environment where the first service is not deployed are obtained.
[0076] In this implementation manner, optionally, obtaining the service deployment information corresponding to the characteristic environment includes: searching for the service deployment information corresponding to the characteristic environment in the cache space. Thus, the service deployment information corresponding to the characteristic environment can be stored in the cache space in advance to improve the acquisition efficiency of the service deployment information.
[0077] Furthermore, if the service deployment information corresponding to the characteristic environment is not stored in the cache space, the service deployment information corresponding to the characteristic environment can be obtained by calling the environment query interface, and the service deployment information is stored in the cache space so that the service deployment information can be directly obtained from the cache space subsequently, without querying the service deployment information through the environment query interface every time, thereby improving the efficiency.
[0078] Furthermore, the environment query interface can include a first sub-interface and a second sub-interface. First, the environment identifier corresponding to the characteristic environment can be obtained by calling the first sub-interface, and the environment identifier corresponding to the characteristic environment is input into the second sub-interface, and the service deployment information corresponding to the environment identifier is obtained by calling the second sub-interface. In this way, the service deployment information corresponding to the characteristic environment can be obtained.
[0079] S304, in the candidate messages, filter out the first message corresponding to the attribute information.
[0080] In this embodiment, after obtaining the candidate messages, the attribute information of the message to be pulled is used as the filtering condition, and the first message is filtered out from the candidate messages. Among them, the attribute information of the message to be pulled is different according to different message pull modes. The message pull modes include the subscription method based on the subject and the subscription method based on the queue. The attribute information of the message to be pulled in the subscription method based on the subject is different from the attribute information of the message to be pulled in the subscription method based on the queue. The corresponding implementation manners are provided below.
[0081] In a possible implementation, the attribute information of the message to be pulled may include the topic name corresponding to the message to be pulled (which can be referred to as the pipe name) and the message sequence number corresponding to the message to be pulled (i.e., the subscription point corresponding to the message to be pulled). At this time, the message pulling mode is a topic-based subscription method. S304 may include: among the candidate messages, determining the first message as the message whose topic name is the same as the topic name corresponding to the message to be pulled and whose message sequence number is the same as the message sequence number corresponding to the message to be pulled. Thus, based on the topic name and the message sequence number, the accuracy of screening the first message from the candidate messages is improved.
[0082] In another possible implementation, the attribute information of the message to be pulled includes the topic name corresponding to the message to be pulled and the queue name corresponding to the message to be pulled (which can be referred to as the queue name). At this time, the message pulling mode is a queue-based subscription method. S304 may include: among the candidate messages, determining the first message as the message whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and which has not been successfully received by the service in the distributed system. Thus, based on the topic name, the message sequence number, and whether the candidate message has been successfully received, the accuracy of screening the first message from the candidate messages is improved.
[0083] Among them, in the queue-based subscription method, the queue name is bound to the topic name, and one topic name can be bound to multiple queue names. Therefore, when pulling messages, it is necessary to provide not only the topic name corresponding to the message to be pulled but also the queue name corresponding to the message to be pulled to accurately pull the message.
[0084] In this embodiment, in the queue-based subscription method, messages are consumed competitively. After a message is successfully received by a service, a corresponding successful reception mark (such as an ack mark) can be added to the message, or the reception mark corresponding to the message can be set to a first value. When the reception mark is the first value, it indicates that the message has been successfully received by the service, and when the reception mark is a second value, it indicates that the message has not been successfully received by the service. Therefore, among the candidate messages, it is possible to find and obtain the message whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and which does not have a successful reception mark, or among the candidate messages, it is possible to find and obtain the message whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and whose reception mark value is the second value. In this way, the first message is obtained.
[0085] S305, send the first message to the first service.
[0086] Among them, the implementation principle and technical effect of S305 can refer to the foregoing embodiments and will not be elaborated here.
[0087] In an embodiment of the present disclosure, when the environment type of the first test environment is a benchmark environment, first query to obtain the messages produced in the benchmark environment and the messages produced in the characteristic environment where the first service is not deployed, to obtain candidate messages, and then screen the first messages with corresponding attribute information from the candidate messages, and send the first messages to the first service. Through staged screening, the accuracy of the first messages is improved, and intelligent routing of messages in the same and different test environments is achieved. The embodiment of the present disclosure can be implemented through a message passing service or a message middleware. Different types of test environments can share the same message passing service or message middleware, and there is no need to separately configure and maintain the message middleware for each test environment, reducing costs.
[0088] In some embodiments, candidate messages corresponding to the attribute information can be queried and obtained based on the attribute information of the message to be pulled; from the candidate messages corresponding to the attribute information, the messages produced in the benchmark environment and the messages produced in the characteristic environment where the first service is not deployed are screened out. Alternatively, based on the attribute information of the message to be pulled and the environment type of the first test environment, the query of the message can be synchronized to obtain the messages corresponding to the attribute information produced in the benchmark environment and the messages corresponding to the attribute information produced in the characteristic environment where the first service is not deployed. Details are not described one by one here.
[0089] Figure 4 is a schematic diagram according to the third embodiment of the present disclosure. As Figure 4 shown, the message passing method in the test environment provided by the third embodiment of the present disclosure includes:
[0090] S401, obtain a message pull request of the first service in the first test environment.
[0091] S402, parse the message pull request of the first service in the first test environment to determine the environment type of the first test environment and the attribute information of the message to be pulled.
[0092] S403, determine whether the environment type of the first test environment is a benchmark environment.
[0093] Wherein, if the environment type of the first test environment is a benchmark environment, then execute S404, otherwise execute S406. The implementation principles and technical effects of S401 to S403 can be referred to the foregoing embodiments and will not be elaborated herein.
[0094] S404, query and obtain the first messages corresponding to the attribute information of the message to be pulled, where the first messages include the messages produced in the benchmark environment and the messages produced in the characteristic environment where the first service is not deployed.
[0095] S405, send the first messages to the first service.
[0096] Among them, the implementation principles and technical effects of S404 to S405 can be referred to the foregoing embodiments and will not be elaborated herein.
[0097] S406, query for a second message that obtains the attribute information of the message to be pulled, where the second message includes messages produced in the first test environment.
[0098] In this embodiment, when the first test environment is not the benchmark environment, among multiple messages, according to the attribute information of the message to be pulled and the production environments corresponding to the multiple messages, a message produced in the first test environment (i.e., the production environment is the first test environment) and corresponding to the attribute information of the message to be pulled can be queried, that is, the second message is obtained. Specifically, messages produced in the first test environment can be first queried, and then messages corresponding to the attribute information can be filtered out from the messages produced in the first test environment; alternatively, messages corresponding to the attribute information can be first queried, and then messages produced in the first test environment can be filtered out from the messages corresponding to the attribute information.
[0099] In a possible implementation manner, by parsing the message pull request of the first service in the first test environment, the environment identifier of the first test environment and the attribute information of the message to be pulled can be obtained. The environment identifier of the first test environment can reflect the environment type of the first test environment: the environment identifier of the first test environment can be compared with the environment identifier of the benchmark environment to determine whether the first test environment is the benchmark environment. Messages produced in the characteristic environment and the environment identifier of the characteristic environment can be stored in the message database. If the first test environment is not the benchmark environment, then based on the environment identifier of the first test environment, messages produced in the first test environment can be queried from the message database; then messages corresponding to the attribute information can be filtered out from the messages produced in the first test environment to obtain the second message. Thus, based on the environment identifier and the attribute information, the accuracy of querying the second message is improved.
[0100] Among them, the attribute information of the message to be pulled is different according to different message pull modes. The message pull modes include a subscription method based on the subject and a subscription method based on the queue. The attribute information of the message to be pulled in the subscription method based on the subject is different from the attribute information of the message to be pulled in the subscription method based on the queue. The corresponding implementation manners are provided below.
[0101] In a possible implementation, the attribute information of the message to be pulled may include the topic name corresponding to the message to be pulled and the message sequence number corresponding to the message to be pulled. At this time, the message pulling mode is a subscription method based on the topic. Screening for messages corresponding to the attribute information from the messages produced in the first test environment may include: among the messages produced in the first test environment, determining that the second message is a message whose topic name is the same as the topic name corresponding to the message to be pulled and whose message sequence number is the same as the message sequence number corresponding to the message to be pulled. Thus, based on the topic name and the message sequence number, the accuracy of screening for the second message from the messages produced in the first test environment is improved.
[0102] In another possible implementation, the attribute information of the message to be pulled includes the topic name corresponding to the message to be pulled and the queue name corresponding to the message to be pulled. At this time, the message pulling mode is a subscription method based on the queue. Screening for messages corresponding to the attribute information from the messages produced in the first test environment may include: among the messages produced in the first test environment, determining that the second message is a message whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and which has not been successfully received by the service in the distributed system. Thus, based on the topic name, the message sequence number, and whether the candidate message has been successfully received, the accuracy of screening for the second message from the messages produced in the first test environment is improved.
[0103] Among them, in the subscription method based on the queue, the queue name is bound to the topic name. One topic name can be bound to multiple queue names. Therefore, when pulling messages, it is necessary to provide not only the topic name corresponding to the message to be pulled but also the queue name corresponding to the message to be pulled to accurately pull the message.
[0104] In this embodiment, in the subscription method based on the queue, messages are consumed competitively. After a message is successfully received by a service, a corresponding successful reception mark (such as an ack mark) can be added to the message, or the reception mark corresponding to the message can be set to a first value. When the reception mark is the first value, it means that the message has been successfully received by the service. When the reception mark is the second value, it means that the message has not been successfully received by the service. Therefore, in the messages produced in the first test environment, it is possible to search for messages whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and which do not have a successful reception mark, or in the messages produced in the first test environment, it is possible to search for messages whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and whose reception mark value is the second value.
[0105] S407, send the second message to the first service.
[0106] In this embodiment, after obtaining the second message, the second message is sent to the first service, so as to implement routing the second message from the producer in the feature environment to the consumer in the same feature environment.
[0107] In the embodiments of the present disclosure, intelligent message routing in the feature environment and the baseline environment is realized: Messages produced by services deployed in the feature environment can be routed to other services deployed in the same feature environment, or can be routed to services deployed in the baseline environment but not in this feature environment; Messages produced by services deployed in the baseline environment can be routed to other services deployed in the baseline environment. The accuracy of message transmission in different types of test environments is improved. The embodiments of the present disclosure can be implemented through a message transmission service or a message middleware. Therefore, different types of test environments can share the same message transmission service or message middleware, without the need to separately configure and maintain message middleware for each test environment, nor to rely too much on message middleware, reducing the message transmission cost.
[0108] As an example, Table 2 below gives an example of the message routing policy of the embodiments of the present disclosure:
[0109] Table 2
[0110]
[0111]
[0112] Among them, the f environment represents the feature environment, and the b environment represents the baseline environment. For services A and B deployed in the same feature environment, the message produced by service A can be consumed by service B; for service A deployed in the baseline environment and service B deployed in the feature environment, the message produced by service A cannot be consumed by service B; for service A deployed in the feature environment and service B deployed in the baseline environment, if service B is not deployed in the feature environment where service A is located, then service B in the baseline environment can consume the message produced by service A in the feature environment. If service B is deployed in the feature environment where service A is located, then service B in the baseline environment cannot consume the message produced by service A in the feature environment, but the message produced by service A in this feature environment is consumed by service B in the same feature environment; for service A and service B deployed in the baseline environment, service B can consume the message produced by service A. Among them, the above routing ignores the screening of attribute information.
[0113] Next, based on any of the foregoing embodiments, some extended embodiments are provided.
[0114] In some embodiments, a message publishing request of a second service in a second test environment may be obtained; the message publishing request of the second service is parsed to determine the environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published; the environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published are stored. Thus, for the messages published in the test environment, the environment type of the test environment, the attribute information of the message to be published, and the message content of the message to be published are stored, so that when other services pull messages, they can accurately query and obtain the messages suitable for being passed to other services based on these stored contents, improving the accuracy of message transmission.
[0115] Among them, the second test environment is the production environment of the message to be published. The second test environment can be a baseline environment or a feature environment. The second service is a service deployed in the second test environment.
[0116] In this embodiment, the message publishing request of the second service in the second test environment can be parsed to obtain the environment information of the second test environment, the attribute information of the message to be published, and the message content of the message to be published. Based on the environment information of the second test environment, the environment type of the second environment information can be determined. The environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published are stored in the message database. In this way, multiple pieces of message publishing data corresponding to different test environments can be stored in the message database. The message publishing data corresponding to a test environment includes the environment type of the test environment, the attribute information of the message produced in the test environment (i.e., the message to be published in the test environment), and the message content of the message produced in the test environment.
[0117] In a possible implementation manner, a message publishing request of a second service in a second test environment may be received through a message publishing interface. Among them, the message publishing interface is an interface for requesting to publish a message.
[0118] In a possible implementation manner, the message header in the message publishing request includes the environment information of the second test environment, the attribute information of the message to be published, and the message content of the message to be distributed. The message header in the message publishing request can be parsed to obtain the environment information of the second test environment, the attribute information of the message to be published, and the message content of the message to be published. According to the environment information of the second test environment, the environment type of the second test environment is determined. Thus, through parsing the message header, the environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published are obtained.
[0119] In a possible implementation manner, the environment information of the second test environment includes the environment type of the second test environment. The message publishing request of the second service in the second test environment is parsed to obtain the environment type of the second test environment and the attribute information of the message to be pulled.
[0120] In yet another possible implementation, the environment information of the second test environment includes the environment identifier of the first test environment. Parse the message publishing request of the second service in the second test environment to obtain the environment identifier of the second test environment and the attribute information of the message to be published. Compare the environment identifier of the second test environment with the environment identifiers of multiple test environments to determine that the environment type of the second test environment is the environment type of the test environment whose environment identifier is the same as that of the second test environment.
[0121] Optionally, store the environment information of the second test environment, the attribute information of the message to be published, and the message content of the message to be published in the message database. The environment information of the second test environment can reflect the environment type of the second test environment. In particular, based on the environment identifier of the second test environment, the attribute information of the message to be published and the message content of the message to be published can be stored in the message publishing data corresponding to the second test environment in the message database.
[0122] Optionally, periodically clean up the expired data in the message database to avoid excessive data in the message database and reduce waste of storage resources. Expired data includes, for example, the attribute information and message content of messages to be published that have been stored for too long, or, in the case of a queue-based subscription method, the attribute information and message content of messages marked as successfully received by the service.
[0123] Optionally, in the database, the structure design of the database table may include: message ID, the environment identifier of the production environment corresponding to the message, the topic name corresponding to the message, the message body (i.e., the message content of the message), the creation time of the message, the reception mark corresponding to the message (for example, a reception mark of 0 indicates that the message has not been successfully received by the service, and a reception mark of -1 indicates that the message has been successfully received by the service), and extended information (other information other than the above information).
[0124] As an example, assume that the embodiments of the present disclosure are implemented through a message passing service. Since the message middleware is operated through a software development kit (SDK) or an application programming interface (API), the business side mainly calls the message middleware through the API method, that is, calls the message middleware through the hypertext transfer protocol (HTTP) method. The message passing service provided by the embodiments of the present disclosure also uses the API method to operate. In the topic-based subscription method and the queue-based subscription method, message publishing and subscription can be implemented by calling the corresponding API.
[0125] Among them, in the topic-based subscription method, the specific process is as follows:
[0126] Step 1, the producer publishes a message: The producer can trigger a message publishing request by calling the message publishing interface (in the topic-based subscription method, the message publishing interface is, for example, the publish interface, and specifically, the publish interface can be called by inputting " / rest / pipe / $pipe_name"). The message publishing request carries a message header (header). Among them, $pipe_name is the topic name of the message to be published, and the topic name can be preset through a configuration file.
[0127] Step 2, in the message delivery service: Parse the environment identifier and topic name in the message header, and persistently store the environment identifier, topic name, and the message content of the message to be published in the database.
[0128] Step 3, the consumer pulls the message: The consumer can trigger a message pulling request by calling the message pulling interface (in the topic-based subscription method, the message pulling interface is, for example, the fetch interface, and specifically, the fetch interface can be called by inputting " / rest / pipe / $pipe_name"). The message pulling request carries a message header, and $pipe_name is the topic name of the message to be pulled.
[0129] Step 4, in the message delivery service: Parse the environment identifier, topic name, and subscription point in the message header of the message pulling request. Based on the environment identifier, topic name, and subscription point, query the messages that meet the conditions from the database and return them to the consumer.
[0130] Among them, in the queue-based subscription method, the specific process is as follows:
[0131] Step 1, the producer publishes a message: The producer can trigger a message publishing request by calling the message publishing interface (in the queue-based subscription method, the message publishing interface is, for example, the publish interface, and specifically, the publish interface can be called by inputting " / rest / pipe / $pipe_name"). The message publishing request carries a message header (header). Among them, $pipe_name is the topic name of the message to be published, and the topic name can be preset through a configuration file.
[0132] Step 2, in the message delivery service: Parse the environment identifier and topic name in the message header, and persistently store the environment identifier, topic name, and the message content of the message to be published in the database.
[0133] Step 3, the consumer pulls messages: The consumer can trigger a message pull request by calling a message pull interface (in the topic-based subscription method, the message pull interface is, for example, the receive interface, and specifically, the receive interface can be called by inputting " / rest / receive / $queue_name?pipename=xxx"). The message pull request carries a message header. Among them, pipe_name is the topic name of the message to be pulled, queue_name is the queue name, and one pipe_name can be bound to multiple queue_name.
[0134] Step 4, in the message delivery service: Parse the environment identifier, topic name, and queue name in the message header of the message pull request. Based on the environment identifier, topic name, and queue name, query in the database for messages that have not been successfully received by the service, such as messages with a receive flag (such as an ack flag) of 0, and return the queried messages to the consumer.
[0135] From the above two processes, it can be seen that the above two processes achieve the transparent transmission of the environment identifier, and route the message to the service in the accurate test environment through the environment identifier.
[0136] As an example, assume that the embodiments of the present disclosure are implemented through a message delivery service. Figure 5 is an architecture example provided according to the above embodiments of the present disclosure Figure 1 , as Figure 5 shown, the producer can publish messages in an http manner; Consumer 1 can pull messages through a topic-based subscription method. In this method, Consumer 1 pulls messages through a first interface (such as the fetch interface); Pulling Consumer 2 can pull messages through a queue-based subscription method. In this method, Consumer 2 can pull messages through a second interface (such as the receive interface). After the pull is successful, an ack message can also be returned to the message delivery service to indicate that the message pull is successful.
[0137] As Figure 5As shown in the figure, the message passing service includes, from top to bottom: a routing layer, a logic layer, a parsing layer, dependent services, and a storage layer. In the routing layer, it includes the http call method in the topic-based subscription method and the http call method in the queue-based subscription method, such as rest / pipe and rest / queue. In the logic layer, it includes logics such as publishing, topic subscription, queue subscription, and confirmation. Among them, publishing corresponds to the message publishing logic for implementing message publishing. Topic subscription corresponds to the message pulling logic in the topic-based subscription method for implementing message pulling in the topic-based subscription method. Queue subscription corresponds to the message pulling logic in the queue-based subscription method for implementing message pulling in the queue-based subscription method. Confirmation is the logic for replying to successfully received messages in the queue-based subscription method. In the parsing layer, it includes the parsing of message headers and queue names (the queue names here can include topic names and queue names). In the dependent services, it includes open APIs and scheduled tasks. The service deployment information corresponding to the test environment can be obtained by calling the open APIs, and data can be periodically cleared through the scheduled tasks. In the storage layer, it includes a database and a cache space. The database is used to store message publishing data, and the service deployment information corresponding to the test environment can be stored in the cache space.
[0138] As an example, Figure 6 is an architecture example provided according to the above embodiments of the present disclosure Figure 2 , such as Figure 6 As shown in the figure, in the topic-based subscription method, the overall architecture may include a producer, a message passing service, and a consumer: In the producer, it includes Service A deployed in Feature Environment 1, Service A deployed in Feature Environment 2, and Service A deployed in Feature Environment 3. The consumer includes Service B deployed in the baseline environment, Service B deployed in Feature Environment 1, and Service B deployed in Feature Environment 2. The message passing service includes a message database, which stores messages corresponding to each topic in the baseline environment, messages corresponding to each topic in Feature Environment 1, messages corresponding to each topic in Feature Environment 2, and messages corresponding to each topic in Feature Environment 3. During the message pulling process, Service B in the baseline environment can consume the messages produced by Service A in the baseline environment. If Service B is not deployed in Feature Environment 3, then Service B in the baseline environment can consume the messages produced by Service A in Feature Environment 3. Service B in Feature Environment 1 can consume the messages produced by A in Feature Environment 1. Service B in Feature Environment 2 can consume the messages produced by A in Feature Environment 2.
[0139] As an example, Figure 7 is an architecture example provided according to the above embodiments of the present disclosure Figure 3 , such as Figure 7As shown, in the queue-based subscription method, the overall architecture may include a producer, a messaging service, and a consumer: the producer includes Service A deployed in Feature Environment 1, Service A deployed in Feature Environment 2, and Service A deployed in Feature Environment 3; the consumer includes Service B deployed in the baseline environment, Service B deployed in Feature Environment 1, and Service B deployed in Feature Environment 2; the messaging service includes a message database, and the message database stores messages corresponding to each queue in the baseline environment, messages corresponding to each queue in Feature Environment 1, messages corresponding to each queue in Feature Environment 2, and messages corresponding to each queue in Feature Environment 3. During the message pulling process, Service B in the baseline environment can consume the messages produced by Service A in the baseline environment. If Service B is not deployed in Feature Environment 3, then Service B in the baseline environment can consume the messages produced by Service A in Feature Environment 3; Service B in Feature Environment 1 can consume the messages produced by Service A in Feature Environment 1; Service B in Feature Environment 2 can consume the messages produced by Service A in Feature Environment 2. Taking Feature Environment 1 as an example, the topic in Feature Environment 1 can be bound to one or more queues ( Figure 7 taking one as an example). After Service B in Feature Environment 1 successfully pulls a message from the queue corresponding to Feature Environment 1, it can reply with an ACK message to the queue corresponding to Feature Environment 1 and the topic corresponding to Feature Environment 1, respond to the message, and add an ACK flag to the corresponding message in the message database to indicate that the message has been successfully received by the service.
[0140] As an example, Figure 8 is a flowchart example of the messaging method provided according to the above embodiments of the present disclosure. As Figure 8 shown, taking Service B in the baseline environment as the consumer as an example, the process of the messaging service routing messages for Service B in the baseline environment includes:
[0141] S801, obtain a message set according to the topic name corresponding to the message to be pulled.
[0142] S802, traverse the environment identifiers corresponding to each message in the message set.
[0143] S803, for the message traversed, if the environment identifier corresponding to the message is the environment identifier of the baseline environment, retain the message as the target message to be sent to Service B in the baseline environment.
[0144] S804, for the message traversed, if the environment identifier corresponding to the message is the environment identifier of the feature environment, filter the message, and retain the filtered message as the target message to be sent to Service B in the baseline environment.
[0145] Among them, filtering the message means determining whether the message meets the retention conditions. Meeting the retention conditions means that the message can be retained as the target message, otherwise it means that the message cannot be retained as the target message.
[0146] Among them, the process of determining whether the message meets the retention conditions includes S8041 to S8046:
[0147] S8041, determine whether there is service deployment information of the characteristic environment corresponding to the message in the cache space. If there is no service deployment information of the characteristic environment corresponding to the message in the cache space, execute S8042, otherwise execute S8043.
[0148] S8042, call the environment query interface to obtain the service deployment information of the characteristic environment corresponding to the message, and store the service deployment information of the characteristic environment corresponding to the message into the cache space.
[0149] S8043, obtain the service deployment information of the characteristic environment corresponding to the message from the cache space.
[0150] S8044, query whether the service deployment information of the characteristic environment includes Service B.
[0151] If the service deployment information of the characteristic environment includes Service B, it means that Service B is deployed in this characteristic environment, execute S8045, otherwise it means that Service B is not deployed in this characteristic environment, execute S8046.
[0152] S8045, determine that the message does not meet the retention conditions.
[0153] S8046, determine that the message meets the retention conditions.
[0154] S805, determine whether all the messages in the message set have been traversed.
[0155] If not all the messages in the message set have been traversed, it can continue to switch to execute S802.
[0156] Finally, the message transfer service returns the target message to Service B in the benchmark environment.
[0157] Figure 9 It is a schematic diagram of the fourth embodiment of the present disclosure. As Figure 9 shown, the message transfer device 900 in the test environment provided by the fourth embodiment of the present disclosure includes:
[0158] The pull request acquisition unit 901 is used to acquire the message pull request of the first service in the first test environment;
[0159] The pull request parsing unit 902 is used to parse the message pull request to determine the environment type of the first test environment and the attribute information of the message to be pulled;
[0160] A first query unit 903, configured to query and obtain a first message corresponding to attribute information if the environment type of the first test environment is a benchmark environment. The first message includes messages produced in the benchmark environment and messages produced in a characteristic environment where the first service is not deployed. All services in the distributed system are deployed in the benchmark environment, and some services in the distributed system are deployed in the characteristic environment;
[0161] A first sending unit 904, configured to send the first message to the first service.
[0162] In some embodiments, the first query unit 903 includes: a candidate message query module (not shown in the figure), configured to query and obtain messages produced in the benchmark environment and messages produced in a characteristic environment where the first service is not deployed as candidate messages; a message screening module (not shown in the figure), configured to screen and obtain the first message corresponding to the attribute information from the candidate messages.
[0163] In some embodiments, the candidate message query module includes: a service deployment acquisition sub-module (not shown in the figure), configured to acquire service deployment information corresponding to the characteristic environment, where the service deployment information includes service identifiers of all services deployed in the characteristic environment; an environment query sub-module (not shown in the figure), configured to query and obtain a characteristic environment where the first service is not deployed in the characteristic environment according to the service deployment information corresponding to the characteristic environment; a message acquisition sub-module (not shown in the figure), configured to acquire messages produced in the characteristic environment where the first service is not deployed.
[0164] In some embodiments, the service deployment acquisition sub-module is specifically configured to: search for service deployment information corresponding to the characteristic environment in the cache space; if the service deployment information is not stored in the cache space, obtain the service deployment information by calling an environment query interface, and store the service deployment information in the cache space.
[0165] In some embodiments, the attribute information includes a topic name and a message sequence number. The message screening module includes: a first screening sub-module (not shown in the figure), configured to determine, from the candidate messages, that the first message is a message whose topic name is the same as the topic name of the message to be pulled and whose message sequence number is the same as the message sequence number of the message to be pulled.
[0166] In some embodiments, the attribute information includes a topic name and a queue name. The message screening module includes: a second screening sub-module (not shown in the figure), configured to determine, from the candidate messages, that the first message is a message whose topic name is consistent with the topic name of the message to be pulled, whose queue name is consistent with the queue name of the message to be pulled, and that has not been successfully received by a service in the distributed system.
[0167] In some embodiments, the message passing device further includes: a second query unit (not shown in the figure), configured to query and obtain a second message corresponding to the attribute information if the environment type of the first test environment is a characteristic environment, where the second message includes messages produced in the first test environment; and a second sending unit (not shown in the figure), configured to send the second message to the first service.
[0168] In some embodiments, the message passing device further includes: a publishing request acquisition unit (not shown in the figure), configured to acquire a message publishing request of a second service in a second test environment; a publishing request parsing unit, configured to parse the message publishing request to determine the environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published; and a storage unit (not shown in the figure), configured to store the environment type, the attribute information, and the message content.
[0169] Figure 9 The message passing device in the provided test environment can execute the steps involved in the terminal in the corresponding method embodiments described above. The implementation principles and technical effects are similar and will not be elaborated here.
[0170] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the solution provided in any of the above embodiments.
[0171] According to an embodiment of the present disclosure, the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause a computer to execute the solution provided in any of the above embodiments.
[0172] According to an embodiment of the present disclosure, the present disclosure further provides a computer program product, which includes: a computer program stored in a readable storage medium. At least one processor of an electronic device can read the computer program from the readable storage medium, and when the at least one processor executes the computer program, the electronic device is caused to execute the solution provided in any of the above embodiments.
[0173] Figure 10FIG. 0 is a schematic block diagram of an exemplary electronic device 1000 that may be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, for example, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as, for example, personal digital assistants, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementations of the present disclosure described and / or claimed herein.
[0174] As Figure 10 shown, the electronic device 1000 includes a computing unit 1001 that may perform various appropriate actions and processes in accordance with a computer program stored in a read only memory (ROM) ( Figure 10 taking ROM 1002 as an example) or a computer program loaded from a storage unit 1008 into a random access memory (RAM) ( Figure 10 taking RAM 1003 as an example). In the RAM 1003, various programs and data required for the operation of the electronic device 1000 may also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface ( Figure 10 taking I / O interface 1005 as an example) is also connected to the bus 1004.
[0175] Multiple components in the electronic device 1000 are connected to the I / O interface 1005, including: an input unit 10010, such as, for example, a keyboard, a mouse, etc.; an output unit 1007, such as, for example, various types of displays, speakers, etc.; a storage unit 1008, such as, for example, a magnetic disk, an optical disk, etc.; and a communication unit 1009, such as, for example, a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the electronic device 1000 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0176] The computing unit 1001 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphic processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1001 executes the various methods and processes described above, such as the message passing method in the test environment. For example, in some embodiments, the message passing method in the test environment can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 1008. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the message passing method in the test environment described above can be executed. Alternatively, in other embodiments, the computing unit 1001 can be configured to execute the message passing method in the test environment by any other suitable means (e.g., by means of firmware).
[0177] The various embodiments of the systems and techniques described above in this article can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard parts (ASSPs), system on a chip (SOC) systems, complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs, which can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special or general programmable processor, and can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0178] The program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program codes cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0179] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0180] In order to provide interaction with a user, the systems and techniques described herein may be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, speech input, or tactile input).
[0181] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN), and the Internet.
[0182] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS" for short). The server can also be a server of a distributed system, or a server combined with blockchain.
[0183] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitations are imposed herein.
[0184] The above specific embodiments do not constitute a limitation on the protection scope of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the protection scope of this disclosure.
Claims
1. A message passing method in a test environment, including: Obtaining a message pull request of a first service in a first test environment; Parsing the message pull request to determine the environment type of the first test environment and the attribute information of the message to be pulled; If the environment type of the first test environment is a reference environment, querying to obtain a first message corresponding to the attribute information, the first message including messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed, all services in the distributed system are deployed in the reference environment, and some services in the distributed system are deployed in the characteristic environment; wherein, different types of test environments share the same message passing service or message middleware; Sending the first message to the first service; Querying for messages produced in a characteristic environment where the first service is not deployed, including: Searching for service deployment information corresponding to the characteristic environment in a cache space; If the service deployment information is not stored in the cache space, obtaining the service deployment information by calling an environment query interface and storing the service deployment information in the cache space, the service deployment information including service identifiers of all services deployed in the characteristic environment; According to the service deployment information, querying in the characteristic environment to obtain a characteristic environment where the first service is not deployed; Obtaining messages produced in a characteristic environment where the first service is not deployed.
2. The message passing method in a test environment according to claim 1, wherein, The querying to obtain the first message corresponding to the attribute information includes: Querying to obtain messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed as candidate messages; Filtering in the candidate messages to obtain the first message corresponding to the attribute information.
3. The message passing method in a test environment according to claim 2, wherein, The attribute information includes a topic name and a message sequence number, and the filtering in the candidate messages to obtain the first message corresponding to the attribute information includes: In the candidate messages, determining the first message as a message whose topic name is the same as the topic name corresponding to the message to be pulled and whose message sequence number is the same as the message sequence number corresponding to the message to be pulled.
4. The message passing method in a test environment according to claim 2, wherein, The attribute information includes a topic name and a queue name, and the filtering in the candidate messages to obtain the first message corresponding to the attribute information includes: In the candidate messages, determining the first message as a message whose topic name is consistent with the topic name corresponding to the message to be pulled, whose queue name is consistent with the queue name corresponding to the message to be pulled, and which has not been successfully received by the services in the distributed system.
5. After parsing the message pull request in the message passing method in a test environment according to claim 1, it further includes: If the environment type of the first test environment is a characteristic environment, querying to obtain a second message corresponding to the attribute information, the second message including messages produced in the first test environment; Send the second message to the first service.
6. The message passing method in the test environment according to claim 1, further comprises: Obtain a message publishing request of a second service in a second test environment; Parse the message publishing request to determine the environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published; Store the environment type, the attribute information, and the message content.
7. A message passing device in a test environment, comprises: A pull request acquisition unit, configured to obtain a message pull request of a first service in a first test environment; A pull request parsing unit, configured to parse the message pull request to determine the environment type of the first test environment and the attribute information of the message to be pulled; A first query unit, configured to, if the environment type of the first test environment is a reference environment, query and obtain a first message corresponding to the attribute information, where the first message includes messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed, all services in the distributed system are deployed in the reference environment, and some services in the distributed system are deployed in the characteristic environment; wherein, different types of test environments share the same message passing service or message middleware; A first sending unit, configured to send the first message to the first service; The first query unit includes: a candidate message query module, and the candidate message query module includes: a service deployment acquisition sub-module, configured to obtain service deployment information corresponding to the characteristic environment, where the service deployment information includes service identifiers of all services deployed in the characteristic environment; An environment query sub-module, configured to query and obtain a characteristic environment where the first service is not deployed in the characteristic environment according to the service deployment information corresponding to the characteristic environment; A message acquisition sub-module, configured to obtain messages produced in the characteristic environment where the first service is not deployed; The service deployment acquisition sub-module is specifically configured to: Search for the service deployment information corresponding to the characteristic environment in the cache space; If the service deployment information is not stored in the cache space, obtain the service deployment information by calling an environment query interface, and store the service deployment information in the cache space.
8. The message passing device in the test environment according to claim 7, wherein, The first query unit includes: A candidate message query module, specifically configured to query and obtain messages produced in the reference environment and messages produced in a characteristic environment where the first service is not deployed as candidate messages; A message screening module, configured to screen and obtain the first message corresponding to the attribute information from the candidate messages.
9. The message passing device in the test environment according to claim 8, wherein, The attribute information includes a topic name and a message sequence number, and the message screening module includes: A first screening sub-module, configured to determine, from the candidate messages, that the first message is a message whose topic name is the same as the topic name of the message to be pulled and whose message sequence number is the same as the message sequence number of the message to be pulled.
10. The message passing device in the test environment according to claim 8, wherein, the attribute information includes a topic name and a queue name, and the message screening module includes: A second screening sub-module, configured to determine, among the candidate messages, that the first message is a message whose topic name is the same as the topic name corresponding to the message to be pulled, the queue name is the same as the queue name corresponding to the message to be pulled, and has not been successfully received by the service in the distributed system.
11. The message passing device in the test environment according to claim 7, further comprising: A second query unit, configured to query and obtain a second message corresponding to the attribute information if the environment type of the first test environment is a feature environment, and the second message includes messages produced in the first test environment; A second sending unit, configured to send the second message to the first service.
12. The message passing device in the test environment according to claim 7, further comprising: A publishing request acquisition unit, configured to acquire a message publishing request of a second service in a second test environment; A publishing request parsing unit, configured to parse the message publishing request to determine the environment type of the second test environment, the attribute information of the message to be published, and the message content of the message to be published; A storage unit, configured to store the environment type, the attribute information, and the message content.
13. An electronic device, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the message passing method in the test environment according to any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein, the computer instructions are used to cause the computer to execute the message passing method in the test environment according to any one of claims 1 to 6.
15. A computer program product, comprising a computer program, and when the computer program is executed by a processor, the steps of the message passing method in the test environment according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Message passing method and device under multii-test environment
CN113254235A
Service invocation request routing methods, service creation methods and devices
CN114938396A