A message processing system
By automatically determining the test environment and business type through the producer and consumer servers, the error problem caused by TOPIC synchronization failure is solved, automatic TOPIC adjustment without human intervention is achieved, and the accuracy of message processing is improved.
Patent Information
- Application Number
- CN202411381303.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-09-30
AI Technical Summary
In the message processing system, if the consumer server fails to update the TOPIC correspondence with the producer server in a timely manner, the consumer server will not be able to obtain the correct message and an error will occur.
The producer and consumer servers determine their corresponding test environments and business types respectively, automatically update TOPIC, and ensure dynamic adjustment and synchronization of TOPIC in the message processing system.
The TOPIC of the producer and consumer servers can be automatically synchronized without human intervention, avoiding errors and improving the accuracy and reliability of message processing.
Smart Images

Figure CN119211179B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a message processing system. Background Art
[0002] The test system includes multiple producer servers, a message center server, and multiple consumer servers. The producer server is used to produce messages that carry TOPICs and store the produced messages in the message center server. The consumer server is used to obtain messages with TOPICs it has subscribed to from the message center server and process them.
[0003] The above-mentioned related technologies have the following problems: if the R&D personnel need to produce messages through producer server A and process the messages through consumer server B, the consumer server B and producer server A are pre-set to have the same TOPIC; if the R&D personnel changes "consumer server B consumes messages produced by producer server A" to "consumer server C consumes messages produced by producer server A", but the R&D personnel fail to change "consumer server B and producer server A have the same TOPIC" to "consumer server C and producer server A have the same TOPIC", it will cause consumer server B to obtain messages produced by producer server A from the message center server, and cause consumer server C to not obtain messages produced by producer server A from the message center server, resulting in an error. Summary of the Invention
[0004] In view of the above problems, this application provides a message processing system. The specific solution is as follows:
[0005] A first aspect of the present application provides a message processing system, comprising:
[0006] The producer server is configured to determine a first test environment corresponding to the producer server; search for a first environment number corresponding to the first test environment from a preset correspondence between test environments and environment numbers; determine a first service type corresponding to the producer server; search for a first service number corresponding to the first service type from a preset correspondence between service types and service numbers; obtain a first TOPIC including the first environment number and the first service number; generate a message carrying the first TOPIC; and send the message to a message center server;
[0007] The message center server is configured to store storage spaces corresponding to a plurality of TOPICs respectively; and store the message in the storage space corresponding to the first TOPIC;
[0008] A consumer server is used to determine a second test environment corresponding to the consumer server; search for a second environment number corresponding to the second test environment from a preset correspondence between the test environment and the environment number; determine a second business type corresponding to the consumer server; search for a second business number corresponding to the second business type from a preset correspondence between the business type and the business number; obtain a second TOPIC including the second environment number and the second business number; and obtain a message carrying the second TOPIC from the message center server.
[0009] By means of the above technical solution, the present application provides a message processing system, in which the producer server can determine the first TOPIC carried by the message it produces based on its corresponding first test environment and first business type; if the first test environment corresponding to the producer server changes or the corresponding first business type changes, the determined first TOPIC will also change automatically. The producer server produces a message carrying the first TOPIC and stores it in the message center server. The consumer server can determine the second TOPIC carried by the message it consumes based on its corresponding second test environment and second business type; if the second test environment corresponding to the consumer server changes or the corresponding second business type changes, the determined second TOPIC will also change automatically. The consumer server can obtain the message carrying the second TOPIC from the message center server and process it. In the present application, if the test environment corresponding to the producer server or the consumer server changes or the corresponding business type changes, the first TOPIC corresponding to the producer server and the second TOPIC corresponding to the consumer server will automatically change. No human intervention is required, which avoids the errors existing in the relevant technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0011] Figure 1 A schematic diagram of the system architecture provided for this application;
[0012] Figure 2 A schematic diagram of an optional hardware structure of a terminal provided in this application;
[0013] Figure 3 A schematic diagram of the structure of a server provided for this application;
[0014] Figure 4A signaling diagram of a message processing system provided in an embodiment of the present application;
[0015] Figure 5 A schematic diagram of code for processing messages by a consumer server provided in an embodiment of the present application;
[0016] Figure 6 A schematic diagram of the code for initializing the producer server provided in an embodiment of the present application;
[0017] Figure 7 A schematic diagram of the code for initializing the consumer server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] The following describes the embodiments of the present application in conjunction with the accompanying drawings. The terms used in the implementation methods of the present application are only used to explain the specific embodiments of the present application and are not intended to limit the present application.
[0019] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0020] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0021] See also Figure 1 , Figure 1 FIG2 shows a schematic diagram of a system architecture. The system may include one or more producer servers 100 , a message center server 200 , and one or more consumer servers 300 .
[0022] Exemplarily, the producer server 100 may be one server or a cluster including multiple servers.
[0023] Exemplarily, the message center server 200 may be a server or a cluster including multiple servers. Exemplarily, the message center server may be a BROKER server that stores ROCKETMQ.
[0024] Exemplarily, the consumer server 300 can be one server or a cluster including multiple servers.
[0025] Exemplarily, the message center server can correspond to a first terminal, which can exhibit an interface through which a developer can set a TOPIC stored by the message center server.
[0026] Exemplarily, one or more producer servers 100 can constitute a producer cluster. Each producer cluster corresponds to a cluster number; different producer clusters correspond to different cluster numbers. Exemplarily, the business types corresponding to different producer clusters can be different or the same.
[0027] Exemplarily, one or more consumer servers 300 can constitute a consumer cluster. Each consumer cluster corresponds to a cluster number; different consumer clusters correspond to different cluster numbers. The business types corresponding to different consumer clusters can be different or the same.
[0028] Exemplarily, one or more producer clusters correspond to a same test environment; one or more consumer clusters correspond to a same test environment.
[0029] The test environment is described below. The test environment (Testing environment) refers to a description of the software and hardware environment on which the test is run, and any other software that interacts with the software under test, including drivers and stubs. The test environment refers to the total of computer hardware, software, network equipment, historical data necessary for completing the software test work.
[0030] For example, the test environment can be: sit (System Integration Testing Environment, system integration test environment), uat (User Acceptance Testing Environment, user acceptance test environment).
[0031] Figure 1 Three producer clusters are shown in the figure, and the test environments corresponding to the three producer clusters are sitA, sitB, and uat, respectively. Figure 1 This is only an example and does not limit the number of producer clusters included in the system. Figure 1 Three consumer clusters are shown in the figure, and the test environments corresponding to the three consumer clusters are sitA, sitB, and uat, respectively. Figure 1 This is only an example and does not limit the number of consumer clusters included in the system.
[0032] For example, the producer server 100 has a second terminal that can display an interface through which R&D personnel can set the test environment corresponding to the producer server 100. The producer server 100 can store a correspondence between preset test environments and environment numbers, as well as a correspondence between preset business types and business numbers.
[0033] For example, the consumer server 300 may be associated with a third terminal that displays an interface through which developers can set the topic of messages to which the consumer server 300 subscribes. After subscribing to messages through the third terminal, the correspondence between the consumer server 300's GID (groupId) and the subscribed topic can be sent by the consumer server 300 to the message center server. The consumer server 300 may also store the correspondence between pre-set test environments and environment numbers, as well as the correspondence between pre-set service types and service numbers.
[0034] It is understandable that if a producer server 100 and a consumer server 300 have the same test environment and the same business type, the TOPICs obtained by the producer server 100 and the consumer server 300 are the same.
[0035] Exemplarily, the same test environment corresponds to one or more producer clusters; the same test environment corresponds to one or more consumer clusters.
[0036] The producer server 100 is used to produce messages and store the messages in the message center server; the consumer server obtains messages from the message center server.
[0037] The following describes the interaction process between the producer server 100, the message center server 200 and the consumer server 300 in conjunction with the application scenario.
[0038] Suppose a customer purchases an insurance product from an insurance company and then wants to redeem it. A redemption transaction is initiated. This transaction includes the customer's bank card number and the redemption date, and the insurance company records the redemption transaction. When the redemption date arrives, the insurance company deposits the funds into the bank, which then deposits the funds into the bank card number included in the redemption transaction.
[0039] In the case that the redemption transaction has been performed and the redemption time has not arrived, i.e., the insurance company does not deposit the fund into the bank, the bank card A of the customer is lost and the customer handles the card replacement business in the bank, the bank provides the new bank card B for the user, and at this time, the card number of the bank card A in the redemption transaction stored by the insurance company needs to be changed to the card number of the bank card B. In the above application scenario, the producer server 100 can be a server of the bank, and the message produced by the producer server 100 can be a message for replacing the card number of the bank card A of the customer with the card number of the bank card B. The consumer server 300 can be a server of the insurance company, and the insurance company obtains the above message and changes the card number of the bank card A in the redemption transaction to the card number of the bank card B.
[0040] Next, a product form of any one of the first terminal, the second terminal, and the third terminal is described.
[0041] The terminal in the embodiments of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), and the like, and the embodiments of the present application do not make any limitation thereto.
[0042] Figure 2 An optional hardware structure schematic diagram of the terminal is shown.
[0043] Reference Figure 2 As shown, the terminal can include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190, and the like. Those skilled in the art can understand that the terminal can include more or less components than those shown, or combine certain components, or different components. Figure 2 The above is merely an example of the terminal and does not constitute a limitation on the terminal, and the terminal can include more or less components than those shown, or combine certain components, or different components.
[0044] The input unit 130 can be configured to receive inputted digital or character information, and to generate key signal inputs related to a user's setting of the terminal and a function control. Specifically, the input unit 130 can include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect a user's touch operation (e.g., a user's operation using a finger, a knuckle, a stylus, or the like on or near the touch screen) and drive a corresponding connected device according to a pre-set program. The touch screen can detect a user's touch action on the touch screen, convert the touch action into a touch signal, and transmit the touch signal to the processor 170. The touch screen can also receive a command from the processor 170 and execute the command. The touch signal can include at least touch coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal and the user. In addition, the touch screen can be implemented in various types such as a resistive type, a capacitive type, an infrared type, and a surface acoustic wave type. In addition to the touch screen 131, the input unit 130 can include other input devices. Specifically, the other input devices 132 can include one or more of a physical keyboard, function keys (e.g., a volume control button, a switch button, or the like), a trackball, a mouse, a joystick, or the like.
[0045] The input device 132 can receive inputted data, and the like.
[0046] The display unit 140 can be configured to display information inputted by a user or information provided to the user, various menus of the terminal, an interactive interface, a file display, and / or a play of any type of multimedia file. In an embodiment of the present application, the display unit 140 can be configured to display an interface, a processing result, and the like.
[0047] The storage 120 can be configured to store instructions and data. The storage 120 can mainly include a storage instruction area and a storage data area. The storage data area can store various data such as a multimedia file, a text, and the like. The storage instruction area can store a software unit such as an operating system, an application, and instructions required for at least one function, or a subset, an extension set thereof. The storage 120 can further include a non-volatile random access memory. The storage 120 can provide the processor 170 with a software and an application including management of hardware, software, and data resources in a computing processing device, support for a control software, and the like. The storage 120 can also be used for storage of a multimedia file, and storage of a running program and an application.
[0048] Processor 170 is the terminal's control center, connecting all components of the terminal using various interfaces and circuits. By executing instructions stored in memory 120 and accessing data stored therein, it performs various terminal functions and processes data, thereby providing overall control of the terminal device. Optionally, processor 170 may include one or more processing units. Preferably, processor 170 integrates an application processor and a modem processor, with the application processor primarily processing the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 170. In some embodiments, the processor and memory may be implemented on a single chip; in other embodiments, they may be implemented on separate chips. Processor 170 may also generate corresponding operational control signals and send them to corresponding components of the computing and processing device. It also reads and processes data in the software, particularly data and programs in memory 120, to enable the various functional modules therein to perform their corresponding functions, thereby controlling the corresponding components to operate as instructed.
[0049] The memory 120 may be used to store software codes, the processor 170 may execute the software codes, and may also schedule other units (such as the input unit 130 and the display unit 140 ) to implement corresponding functions.
[0050] The RF unit 110 (optional) can be used to send and receive information or receive and send signals during a call. For example, after receiving downlink information from the base station, it is passed to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF unit 110 can also communicate with network devices and other devices via wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0051] In this embodiment of the present application, the radio frequency unit 110 can send data to the server and receive processing results sent by the server.
[0052] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.
[0053] The terminal also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby managing charging, discharging, and power consumption through the power management system.
[0054] The terminal further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal to other devices for communication, or to connect a charger for charging the terminal.
[0055] Although not shown, the terminal may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which will not be described in detail here. Some or all of the methods described below may be applied to Figure 2 in the terminal shown.
[0056] Next, the product form of any server among the producer server, message center server and consumer server is described.
[0057] Figure 3 A server structure diagram is provided, such as Figure 3 As shown, the server includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.
[0058] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0059] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0060] The memory 204 may include volatile memory, such as random access memory (RAM). The memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0061] The memory 204 may be used to store software codes, and the processor 202 may execute the software codes and schedule other units to implement corresponding functions.
[0062] It should be understood that the above-mentioned terminals and servers can be centralized or distributed devices, and the processors in the above-mentioned terminals and servers (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), general-purpose processors, digital signal processors (DSP), microprocessors or microcontrollers, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.
[0063] In the embodiments of the present application, the consumer cluster and the producer cluster corresponding to the same TOPIC can be referred to as a group, that is, the TOPIC of the message produced by the producer belonging to the same group is the same as the TOPIC of the message processed by the consumer. The consumer cluster belonging to the group is used to consume the message produced by the producer cluster of the group. In the related art, the producer cluster and the consumer cluster of the same group need to be set. For example, the developer needs to set the TOPIC A that needs to be carried by the message produced by the producer cluster through the terminal corresponding to the producer cluster, so that the producer server in the producer cluster can produce the message carrying the TOPIC A; the developer needs to set the TOPIC A that needs to be carried by the message consumed by the consumer cluster through the terminal corresponding to the consumer cluster, so that the consumer server in the consumer cluster knows that it needs to consume the message carrying the TOPIC A. If the consumer cluster in the same group is changed to another consumer cluster, or the producer cluster in the same group is changed to another producer cluster, but the developer does not modify the TOPIC for the terminal of the consumer cluster or the terminal of the producer cluster, confusion will be caused. The following is an example.
[0064] Suppose that the producer cluster A and the consumer cluster B belong to the same group, and the producer cluster A and the consumer cluster B correspond to the same TOPIC A; if the producer cluster A and the consumer cluster B belong to the same group are changed to the producer cluster A and the consumer cluster C belong to the same group, but the TOPIC A corresponding to the consumer cluster B is not modified to another TOPIC, the consumer cluster B will still obtain the message carrying the TOPIC A from the message center server, and the message carrying the TOPIC A obtained by the consumer cluster B cannot be obtained by the consumer cluster C. If the other TOPIC corresponding to the consumer cluster C is not modified to the TOPIC A, the consumer cluster C will not obtain the message carrying the TOPIC A from the message center server.
[0065] In order to solve the above problems, the embodiments of the present application provide a message processing system. The applicant found the following situations in the research process:
[0066] Situation one: the consumer cluster and the producer cluster belonging to the same group correspond to the same test environment and the same business type.
[0067] Case 2: The test environments corresponding to consumer clusters and producer clusters belonging to different groups are different, and the business types corresponding to consumer clusters and producer clusters belonging to different groups are different; or, the test environments corresponding to consumer clusters and producer clusters belonging to different groups are the same, and the business types corresponding to consumer clusters and producer clusters belonging to different groups are different; or, the test environments corresponding to consumer clusters and producer clusters belonging to different groups are different, and the business types corresponding to consumer clusters and producer clusters belonging to different groups are the same.
[0068] Combining Case 1 and Case 2, each group of consumer clusters and producer clusters can be uniquely identified by the test environment and business type. Based on this, the embodiment of the present application characterizes the TOPIC corresponding to each group of consumer clusters and producer clusters with the test environment and business type corresponding to the group.
[0069] The message processing system of the embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0070] Reference Figure 4 , Figure 4 A signaling diagram of a message processing system provided in an embodiment of the present application, such as Figure 4 As shown, a message processing system provided by an embodiment of the present application may include steps S401 to S413, and these steps are described in detail below.
[0071] Step S401: The producer server 100 determines a first test environment corresponding to the producer server.
[0072] For example, the test environment of the producer server 100 can be changed through the interface displayed by the second terminal corresponding to the producer server 100. That is, the producer server 100 can obtain its own corresponding test environment through the interface of the second terminal.
[0073] Exemplarily, the producer server 100 executes steps S401 to S405 each time it is started or during startup. In this way, when the developer modifies the test environment through the second terminal corresponding to the producer server 100, the producer server 100 can automatically sense the modified test environment without manual operation.
[0074] Exemplarily, the project version numbers (versions) of different test environments may be different, and the test environment can be determined by the project version number in the producer server 100 .
[0075] Step S402: The producer server 100 searches for the first environment number corresponding to the first test environment from the preset correspondence between the test environment and the environment number.
[0076] Assumptions Figure 1 The three producer clusters in the system correspond to the test environments sitA, sitB and uat respectively. The correspondence between the three test environments and the environment numbers includes: the test environment sitA corresponds to the environment number 001001%, the test environment sitB corresponds to the environment number 001002%, and the test environment uat corresponds to the environment number 001003%.
[0077] Step S403: The producer server 100 determines the first business type corresponding to the producer server.
[0078] For example, each producer server 100 is provided with a corresponding business code, and the business code includes the business type corresponding to the producer server. The business codes of the multiple producer servers belonging to the same producer cluster are the same, and the business codes of the producer servers belonging to different producer clusters are different.
[0079] The business type is described below by way of example. For example, the business type includes but is not limited to: card opening business, card replacement business for replacing bank card number, payment business, and batch running and account reconciliation business.
[0080] Step S404: The producer server 100 finds the first business number corresponding to the first business type from the preset correspondence between the business type and the business number.
[0081] For example, the business number can be composed of one or more of letters, numbers and special symbols.
[0082] Step S405: The producer server 100 acquires a first TOPIC including the first environment number and the first business number.
[0083] For example, the first TOPIC is composed of the first environment number and the first business number. Assuming that the first environment number is 001001% and the first business number is @11, the first TOPIC is 001001% @11.
[0084] Step S406: The producer server 100 generates a message carrying the first TOPIC, and sends the message to the message center server 200.
[0085] For example, after the producer server 100 generates the message, the message can be intercepted before sending the message, and the TOPIC carried by the message is set to the first TOPIC.
[0086] Step S407: The message center server 200 stores multiple storage spaces corresponding to multiple TOPICS respectively, and stores the message in the storage space corresponding to the first TOPIC.
[0087] Exemplarily, before the message center server 200 starts, the developer can obtain multiple TOPICS based on the existing producer cluster corresponding to the test environment and the business type, so that the multiple TOPICS corresponding to the storage spaces can be created through the first terminal corresponding to the message center server 200. The process of the developer obtaining the TOPIC is the same as the process of the producer server obtaining the first TOPIC.
[0088] Exemplarily, the message center server stores an MQ (Message Queue) queue. Exemplarily, the storage space corresponding to each TOPIC is an MQ.
[0089] Step S408: The consumer server 300 determines the second test environment corresponding to the consumer server.
[0090] Exemplarily, the second test environment can be the same as or different from the first test environment.
[0091] Exemplarily, the consumer server 300 executes steps S408 to S412 after or during each start.
[0092] Step S409: The consumer server 300 finds the second environment number corresponding to the second test environment from the preset correspondence between the test environment and the environment number.
[0093] Step S410: The consumer server 300 determines the second business type corresponding to the consumer server.
[0094] Exemplarily, the second business type can be the same as or different from the first business type.
[0095] Step S411: The consumer server 300 finds the second business number corresponding to the second business type from the preset correspondence between the business type and the business number.
[0096] Exemplarily, the corresponding business code is set in each consumer server 300, and the business code includes the business type corresponding to the consumer server 300. The business codes set in the multiple consumer servers belonging to the same consumer cluster are the same; the business codes set in the consumer servers belonging to different consumer clusters are different.
[0097] The business type is described below by way of example. For example, the business type includes but is not limited to the card opening business, the card replacement business of replacing the bank card number, the payment business, and the batch running and account reconciliation business.
[0098] Step S412: The consumer server 300 obtains the second TOPIC including the second environment number and the second business number.
[0099] Exemplarily, the second TOPIC is composed of the second environment number and the second service number. Assuming that the second environment number is 001002% and the second service number is @21, the second TOPIC is 001002%@21.
[0100] Illustratively, the second TOPIC may be the same as or different from the first TOPIC.
[0101] Step S413: the consumer server 300 obtains the message carrying the second TOPIC from the message center server.
[0102] An embodiment of the present application provides a message processing system, in which a producer server can determine the first TOPIC carried by the message it produces based on its corresponding first test environment and first business type; if the first test environment corresponding to the producer server changes or the corresponding first business type changes, the determined first TOPIC will also change automatically. The producer server produces a message carrying the first TOPIC and stores it in a message center server. The consumer server can determine the second TOPIC carried by the message it consumes based on its corresponding second test environment and second business type; if the second test environment corresponding to the consumer server changes or the corresponding second business type changes, the determined second TOPIC will also change automatically. The consumer server can obtain the message carrying the second TOPIC from the message center server and process it. In this application, if the test environment corresponding to the producer server or the consumer server changes or the corresponding business type changes, the first TOPIC corresponding to the producer server and the second TOPIC corresponding to the consumer server will automatically change. No human intervention is required, which avoids the errors existing in the relevant technology.
[0103] In a possible implementation, there are multiple implementations of step S413, and the embodiments of the present application provide but are not limited to the following two.
[0104] The first implementation of step S413 includes the following steps A11 to A12.
[0105] Step A11: the consumer server 300 sends a message acquisition request to the message center server 200, where the message acquisition request carries the second TOPIC.
[0106] Step A12: the message center server 200 sends the message carrying the second TOPIC to the consumer server 300.
[0107] The second implementation method of step S413 includes the following steps A21 to 24.
[0108] Step A21: the consumer server 300 obtains a target GID including the cluster identifier of the cluster to which the consumer server belongs and the second environment number.
[0109] The same test environment may correspond to one or more consumer clusters. A consumer cluster includes one or more consumer servers. Messages consumed by different consumer clusters carry different TOPICs.
[0110] Step A22: the consumer server 300 generates a get message request, where the get message request includes the target GID and the second TOPIC.
[0111] Step A23: The consumer server 300 sends the message acquisition request to the message center server.
[0112] Step A24: the message center server 200 searches for the TOPIC corresponding to the target GID from the preset correspondence between the GID and TOPIC of the consumer server.
[0113] Exemplarily, the preset correspondence between the GID and TOPIC of each consumer server is uploaded to the message center server 200 by each consumer server. That is, a consumer server can subscribe to messages. The process of a consumer server subscribing to a message carrying the second TOPIC includes: obtaining a subscription message instruction, which includes the target GID and the second TOPIC; and sending the subscription message instruction to the message center server. The message center server stores the correspondence between the target GID and the second TOPIC. If a consumer server has not subscribed to a message carrying the second TOPIC, the message center server 200 will not send the message carrying the second TOPIC to the consumer server.
[0114] Step A25 : If the TOPIC corresponding to the target GID is the same as the second TOPIC, the message center server 200 sends the message in the storage space corresponding to the second TOPIC to the consumer server 300 .
[0115] In order to prevent the same message from being processed by consumer servers belonging to the same consumer cluster, the message center server 200 may set the status of the message sent to the consumer server to a consumed status.
[0116] It is understandable that the consumer server can update the subscription message, and the method for updating the subscription message includes the following steps B1 to B3.
[0117] Step B1: The consumer server 300 obtains an update subscription message instruction, which includes the target GID and the second TOPIC.
[0118] Assume that the TOPIC carried by the message previously subscribed by the consumer server 300 is the third TOPIC, and the developer needs to change the third TOPIC carried by the message subscribed by the consumer server 300 to the second TOPIC, so the subscription message needs to be updated.
[0119] Step B2: The consumer server 300 sends the update subscription message instruction to the message center server.
[0120] Step B3: the message center server 200 adds the correspondence between the target GID and the second TOPIC to the preset correspondence between the GID and TOPIC of the consumer server.
[0121] It is understandable that the update subscription message instruction is generated by triggering by a developer. For example, if the update subscription message is automatically generated, then before executing step B1, the following steps B11 to B13 may also be executed.
[0122] Step B11: If the second TOPIC obtained by the consumer server in step S412 is different from the TOPIC in the subscription message closest to the current time, it is determined that the subscription message of the consumer server has changed.
[0123] The consumer server stores the subscription message most recent to the current time.
[0124] Assume that the current time is 11:00 a.m. on September 23, 2024, and the consumer server sent the first subscription message to the message center server at 10:00 a.m. on August 1, 2024; the consumer server sent the second subscription message to the message center server at 10:00 a.m. on September 22, 2024. The second subscription message is the subscription message closest to the current time.
[0125] It can be understood that the second TOPIC obtained through step S412 represents the test environment and business type currently corresponding to the consumer's server. If the second TOPIC is different from the TOPIC in the most recent subscription message at the current time, it means that the R&D personnel have forgotten to update the subscription message. If the subscription message is not updated in time, the consumer server will not be able to obtain the message carrying the second TOPIC from the message center server due to step A25.
[0126] Step B12: If the target GID obtained by the consumer server in step A21 is different from the GID in the subscription message closest to the current time, it is determined that the subscription message of the consumer server has changed.
[0127] It is understandable that if the target GID obtained in step A21 is different from the GID in the subscription message closest to the current time, it means that the test environment corresponding to the consumer server has changed.
[0128] The target GID can represent the test environment corresponding to the consumer server and the cluster identifier of the cluster where the consumer server is located.
[0129] In the embodiment of the present application, it can be determined whether the subscription message of the consumer server has changed through step B11 and / or step B12.
[0130] Step B13: If it is determined in step B11 that the subscription message of the consumer server has changed, or if it is determined in step B12 that the subscription message of the consumer server has changed, the consumer server is triggered to execute steps B1 to B2.
[0131] For example, in the related technology, if the GID of the consumer server is changed, the R&D personnel need to change it manually, which will lead to the following problems: if the R&D personnel fail to change the GID of the consumer server in time, it may cause the GIDs of consumer servers belonging to different consumer clusters to be the same; for example, consumer cluster A corresponds to GIDA, and consumer cluster B corresponds to GIDB. Assuming that the GIDA corresponding to consumer cluster A needs to be changed to GIDB, and the GIDB corresponding to consumer cluster B needs to be changed to GIDC, the R&D personnel promptly changes the GIDA corresponding to consumer cluster A to GIDB but fails to promptly change the GIDB corresponding to consumer cluster B to GIDC, resulting in the GIDs corresponding to consumer cluster A and consumer cluster B being GIDB. If any consumer server in consumer cluster A first sends a subscription message to the message center server (including the correspondence between GIDB and TOPIC11), the message center server changes the TOPIC corresponding to GIB to TOPIC11 in the subscription message, and any consumer server in consumer cluster B then sends a subscription message to the message center server (including the correspondence between GIDB and TOPIC12), the message center server changes the TOPIC corresponding to GIB to TOPIC12 in the subscription message. However, in reality, because consumer cluster A corresponds to the GIDB, the message center server should retain the "correspondence between GIDB and TOPIC11." Therefore, if the GID corresponding to the consumer cluster is not updated in a timely manner, the correspondence between the GID and TOPIC stored by the message center server may be incorrect. Steps B11 to B13 allow the consumer server to automatically perceive the changed GID and TOPIC, thus avoiding the problems encountered in related technologies.
[0132] In an optional implementation, after the consumer server 300 obtains the message carrying the second TOPIC, it can process the message carrying the second TOPIC. The specific processing process includes but is not limited to the following steps C1 to C2.
[0133] Step C1: based on the message body type of the message carrying the second TOPIC, parse the message carrying the second TOPIC to obtain a parsed message.
[0134] A MIME type (Multipurpose Internet Mail Extensions type) is a standard used on the Internet to represent file formats. A MIME type consists of two parts: the type and the subtype, separated by a slash ( / ). Common MIME types include:
[0135] text / plain: indicates a plain text file.
[0136] text / html: indicates a web page in HTML format.
[0137] image / jpeg: indicates an image in JPEG format.
[0138] image / png: indicates an image in PNG format.
[0139] application / json: indicates data in JSON format.
[0140] application / xml: indicates data in XML format.
[0141] application / pdf: indicates files in PDF format.
[0142] In the HTTP protocol, the MIME type is usually specified in the Content-Type header, telling the recipient how to process the received message.
[0143] Step C2: Process the parsed message through a preset template method pattern.
[0144] Exemplarily, step C2 includes but is not limited to the following methods: initializing the context (abstract method, implemented by the actual consumer), which is implemented according to the actual business. Message filtering (abstract method, implemented by the actual consumer), which determines whether the message needs to be filtered out according to the actual business. Message processing (abstract method, implemented by the actual consumer), which is implemented according to the actual business. Message persistence, which persists the message to the database and stores the message in a unified manner. Update the consumption result of the message, which updates the consumption status of the message according to the consumer's consumption situation. Context clearing (abstract method, implemented by the actual consumer), which is implemented according to the actual business.
[0145] For example, the template method pattern is an abstract parent class integrated by the consumer server. When the consumer server receives a message, it automatically calls the onEvent template method in the abstract parent class and then processes the message according to the steps defined by the onEvent template method. Figure 5 shown.
[0146] In an optional implementation, the reason why the message center server can store storage spaces corresponding to multiple TOPICs is that the R&D personnel upload multiple TOPICs to the message center server through the first terminal corresponding to the message center server, so that the message center server can divide the storage spaces corresponding to the multiple TOPICs. It is understandable that the test environment or business type corresponding to the same producer cluster may change, thereby causing the TOPIC corresponding to the producer cluster to change, for example, change to TOPIC B. The message center server may not store the storage space corresponding to TOPIC B, so TOPIC B needs to be uploaded to the message center server in a timely manner. If it is uploaded manually, it may cause omissions, resulting in the message center server being unable to store messages carrying TOPIC B. Based on this, the embodiment of the present application provides the following method, which includes but is not limited to the following steps D1 to D4.
[0147] Step D1: The message center server obtains the test environments corresponding to the multiple producer servers and the business types corresponding to the multiple producer servers.
[0148] Exemplarily, if a start instruction is detected, step D1 is executed.
[0149] Exemplarily, the test environments corresponding to the multiple producer servers and the business types corresponding to the multiple producer servers can be actively reported to the message center server by the producer server after startup, or can be actively obtained by the message center server from the producer server.
[0150] For example, a producer server in a plurality of producer servers belonging to the same producer cluster reports its corresponding test environment and business type to the message center server.
[0151] Step D2: The message center server finds the environment number of the test environment corresponding to each of the plurality of producer servers from the preset correspondence between test environment and environment number.
[0152] Step D3: The message center server finds the business number of the business type corresponding to each of the plurality of producer servers from the preset correspondence between business type and business number.
[0153] Step D4: The message center server obtains a TOPIC for each of the plurality of producer servers based on the environment number and the business type corresponding to the producer server, and creates a storage space for the TOPIC.
[0154] In the above embodiment, the message center server can automatically perceive the changes of the test environment and business type corresponding to the producer cluster, thereby being able to automatically update the plurality of TOPICs stored by the message center server and create the storage space for the corresponding TOPICs.
[0155] In an optional implementation, the producer server obtains its GID in the same way as the consumer server, which will not be described here.
[0156] In an optional implementation, the start method can be executed to initialize the producer server, and the process of initializing the producer server includes the process of determining the test environment and business type corresponding to the producer server and the process of determining the TOPIC corresponding to the producer server. Before the producer server sends a message, the message needs to be intercepted and the TOPIC carried by the message needs to be modified, so as to achieve the isolation of message sending. Part of the code is shown in Figure 6
[0157] In an optional implementation, before the project starts to instantiate the consumer server, steps S408 to S412 need to be executed. The "preset correspondence between test environment and environment number" and the "preset correspondence between business type and business number" stored by the consumer server and the producer server are the same. The GID and TOPIC of the consumer server are different when it starts in different test environments and business types. In this way, the isolation of consumption can be achieved. Since the "preset correspondence between test environment and environment number" and the "preset correspondence between business type and business number" stored by the consumer server and the producer server are the same, the one-to-one correspondence between the consumer cluster and the producer cluster is achieved, and the isolation of the test environment is achieved. Part of the code is shown in Figure 7 .
[0158] In the embodiments of this application, if the test environment or business type corresponding to the producer server or consumer server changes, there is no need to manually modify the configuration of the producer server or consumer server, which reduces the development workload to a certain extent. After the implementation of this application, there has been no problem of message consumption failure due to switching the test environment or business type of the producer cluster or consumer cluster, which has improved the testing quality to a certain extent.
[0159] For example, the code involved in this application can be packaged into a Jar (Java Archive) package and can be used in the above system by introduction. If similar problems are encountered, it can be used as a solution and may provide some reference and help.
[0160] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0161] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0162] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
Claims
1. A message processing system, characterized in that: include: The producer server is used to determine a first test environment corresponding to the producer server; Searching for a first environment number corresponding to the first test environment from a preset correspondence between test environments and environment numbers; determining a first service type corresponding to the producer server; searching for a first service number corresponding to the first service type from a preset correspondence between service types and service numbers; obtaining a first topic including the first environment number and the first service number; generating a message carrying the first topic; and sending the message to a message center server; The message center server is used to store storage spaces corresponding to multiple TOPICs respectively; Storing the message in the storage space corresponding to the first TOPIC; A consumer server is used to determine a second test environment corresponding to the consumer server; search for a second environment number corresponding to the second test environment from a preset correspondence between the test environment and the environment number; determine a second business type corresponding to the consumer server; search for a second business number corresponding to the second business type from a preset correspondence between the business type and the business number; obtain a second TOPIC including the second environment number and the second business number; and obtain a message carrying the second TOPIC from the message center server.
2. The message processing system according to claim 1, characterized in that: The process of the consumer server acquiring the message carrying the second TOPIC from the message center server specifically includes: Obtain a target GID including a cluster identifier of the cluster to which the consumer server belongs and the second environment number; Generate an acquisition message request, where the acquisition message request includes the target GID and the second TOPIC; Sending the message acquisition request to the message center server; Receive the message carrying the second TOPIC fed back by the message center server.
3. The message processing system according to claim 2, characterized in that: The method for the message center server to feed back a message carrying the second TOPIC includes: Receiving the message acquisition request; From the preset correspondence between the GID and TOPIC of the consumer server, find the TOPIC corresponding to the target GID; If the TOPIC corresponding to the target GID is the same as the second TOPIC, the message in the storage space corresponding to the second TOPIC is sent to the consumer server.
4. The message processing system according to claim 3, characterized in that: The message center server is also used for: Set the status of the message sent to the consumer server to the consumed status.
5. The message processing system according to any one of claims 3 or 4, characterized in that: The consumer server is further configured to: Obtain an update subscription message instruction, where the update subscription message instruction includes the target GID and the second TOPIC; Send the update subscription message instruction to the message center server.
6. The message processing system according to claim 5, characterized in that: The message center server is also used for: Receive the update subscription message instruction; The corresponding relationship between the target GID and the second TOPIC is added to the preset corresponding relationship between the GID and TOPIC of the consumer server.
7. The message processing system according to claim 1, characterized in that: The consumer server is further configured to: Process the message carrying the second TOPIC.
8. The message processing system according to claim 7, characterized in that: The process of the consumer server processing the message carrying the second TOPIC includes: Parsing the message carrying the second TOPIC based on the message body type of the message carrying the second TOPIC to obtain a parsed message; The parsed message is processed by a preset template method pattern.
9. The message processing system according to claim 1, characterized in that: The method for the message center server to set storage spaces corresponding to multiple TOPICs includes: Obtaining the test environments corresponding to the plurality of producer servers and the business types corresponding to the plurality of producer servers; From the preset correspondence between the test environment and the environment number, searching for the environment numbers of the test environments corresponding to the plurality of producer servers; From the preset correspondence between the business type and the business number, searching for the business numbers of the multiple producer servers corresponding to the business types respectively; For each producer server, a TOPIC is obtained based on the environment number and the business type corresponding to the producer server; and a storage space for the TOPIC is created.
10. The message processing system according to claim 9, characterized in that: The message center server is also used for: If a startup instruction is detected, the step of obtaining the test environments corresponding to the multiple producer servers and the business types corresponding to the multiple producer servers is executed.
Citation Information
Patent Citations
Message request processing method and device, electronic equipment and storage medium
CN116805946A
Message processing system, system and device and storage medium
CN117527892A