Message processing method and device, equipment, storage medium and computer software
By updating the correspondence between the consumer object and the message topic and the correspondence between the message topic and the listening object, the problem of message topic monitoring changes caused by consumer object changes is solved, and efficient dynamic changes in message processing are achieved.
Patent Information
- Application Number
- CN202311136478.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2025-03-04
AI Technical Summary
In message publishing applications, changes in consumer objects lead to changes in monitoring of message topics. The prior art requires modifying configuration information and restarting the message processing service, which affects efficiency.
By storing the correspondence between the consumer object and the message topic and the correspondence between the message topic and the listening object, responding to the consumer object's subscription change request for the message topic, update the correspondence to determine the message topic change, and update the relationship based on the target message topic and the listening object to achieve rapid dynamic changes.
It realizes rapid dynamic changes in the relationship between consumer objects and message themes, message themes and listening objects, improves message processing efficiency, and avoids the necessity of restarting services.
Smart Images

Figure CN119561928A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a message processing method, device, equipment, storage medium and computer software. Background Art
[0002] In message publishing applications, there are various message topics and various consumer objects. Consumer objects usually consume messages by monitoring message topics, and the message topics consumed by various consumer objects may be different. When the monitoring of message topics changes due to changes in the consumption message topics of consumer objects, it is often necessary to modify the configuration information of the monitoring message topics. However, after modifying the configuration information, the message processing service needs to be restarted, which affects the message processing efficiency. Summary of the invention
[0003] Embodiments of the present application provide a message processing method, apparatus, device, storage medium and computer software, which can improve message processing efficiency.
[0004] The technical solution of the embodiment of the present application is implemented as follows:
[0005] The present application provides a message processing method, the method comprising:
[0006] In response to a subscription change request of a target consumer object to a target message topic, a first correspondence relationship is updated based on the target consumer object and the target message topic to obtain a second correspondence relationship, wherein the first correspondence relationship represents a correspondence relationship between the consumer object and the message topic;
[0007] In the case where the first message topic set in the second corresponding relationship is different from the second message topic set in the third corresponding relationship, determining the target monitoring object corresponding to the target message topic, wherein the third corresponding relationship represents the corresponding relationship between the message topic and the monitoring object;
[0008] Update the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship;
[0009] Message monitoring is performed based on the fourth corresponding relationship, and message consumption is performed in combination with the message monitoring result and the second corresponding relationship.
[0010] The present invention provides a message processing device, which includes:
[0011] a relationship updating module, configured to respond to a subscription change request of a target consumer object to a target message subject, update a first corresponding relationship based on the target consumer object and the target message subject to obtain a second corresponding relationship, wherein the first corresponding relationship represents a corresponding relationship between the consumer object and the message subject;
[0012] a change determination module, configured to determine a target monitoring object corresponding to the target message subject when the first message subject set in the second corresponding relationship is different from the second message subject set in the third corresponding relationship, wherein the third corresponding relationship represents a corresponding relationship between a message subject and a monitoring object;
[0013] The relationship updating module is further used to update the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship;
[0014] A message processing module is used to monitor messages based on the fourth corresponding relationship, and consume messages in combination with the message monitoring result and the second corresponding relationship.
[0015] An embodiment of the present application provides an electronic device for message processing, the electronic device comprising:
[0016] A memory for storing computer executable instructions or computer programs;
[0017] The processor is used to implement the message processing method provided in the embodiment of the present application when executing the computer executable instructions or computer program stored in the memory.
[0018] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the message processing method provided in the embodiment of the present application is implemented.
[0019] An embodiment of the present application provides a computer software, including computer executable instructions or a computer program. When the computer executable instructions or the computer program are executed by a processor, the message processing method provided by the embodiment of the present application is implemented.
[0020] The embodiments of the present application have at least the following beneficial effects: by storing a first correspondence between a consumption object and a message subject, and a third correspondence between a message subject and a monitoring object, when a subscription change request for a target message subject is received from a target consumption object, by updating the first correspondence and comparing the message subject in the updated second correspondence with the message subject in the third correspondence, it is possible to determine whether there is a message subject change; and when it is determined that there is a message subject change, the third correspondence is updated based on the target monitoring object corresponding to the target message subject to obtain a fourth correspondence; thereby, in the case where the monitoring of the message subject is changed due to the change of the message subject by the consumption object, the corresponding relationships between the consumption object and the message subject, and between the message subject and the monitoring object can be changed rapidly and dynamically, and then the monitoring of messages of different message subjects can be realized through the fourth correspondence, and the consumption of messages by different message consumers can be realized through the second correspondence; therefore, the message processing efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is an exemplary message processing structure diagram;
[0022] Figure 2 A schematic diagram of an application environment of a message method provided in an embodiment of the present application;
[0023] Figure 3 It is a schematic diagram of an application scenario of the message processing method provided in an embodiment of the present application;
[0024] Figure 4 This is a method provided by the embodiment of the present application. Figure 3 A schematic diagram of the structure of the server in FIG.
[0025] Figure 5 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 1 ;
[0026] Figure 6 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 2 ;
[0027] Figure 7 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 3 ;
[0028] Figure 8 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 4 ;
[0029] Fig. 9 is an exemplary message processing architecture diagram provided in an embodiment of the present application;
[0030] Fig.10 It is an exemplary message processing flow chart provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0032] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0033] In the following description, the terms "first\second\third\fourth" are used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third\fourth" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0034] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0035] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0036] 1) Distributed publish-subscribe messaging system (Kafka), used to improve message consumption efficiency in message publishing applications, is widely used in various business platforms, such as abnormal message processing platforms. The message processing method provided in the embodiment of the present application can realize message monitoring, subscription change and calculation through Kafka.
[0037] 2) Message topic, also known as message category; each message published to the distributed publish-subscribe messaging system corresponds to a category, which is called the message topic. Different components within the business platform produce different message categories, which also include different message topics.
[0038] 3) Annotation (@KafkaListener) is used to listen to and pull messages, and convert these messages into a specified format and send them to the consumer.
[0039] 4) In response, it is used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed may be in real time or have a set delay. Unless otherwise specified, there is no restriction on the order of execution of the multiple operations executed.
[0040] It should be noted that in the process of connecting multiple message topics within the platform to external systems, a common component (for example, a message center) is generally developed within the platform to connect multiple message sources within the platform and multiple external systems to achieve the real-time message push function; the message center can listen to the message topics of multiple message sources within the platform through the annotation @KafkaListener of the message middleware (for example, Kafka, etc.); for example, see Figure 1 , Figure 1 is an exemplary message processing structure diagram; Figure 1 As shown, the message center 1-1 is used to connect to the external system 1-2 to obtain the connection information of the external system 1-2; the message center 1-1 includes an annotation 1-3, which is used to monitor the messages of the message topics corresponding to the message sources (the message topics 1-51 to 1-53 corresponding to the message sources 1-41 to 1-43 are shown as examples), and the monitored messages are pushed to the external system 1-2 based on the connection messages. Usually, in order to be able to resend the message when the message fails to be sent, the message can be persisted in the message middleware, and then the message can be pushed to the external system according to the connection specifications with the external system.
[0041] That is to say, in the message publishing application, there are various message topics and various consumer objects. The consumption of messages by consumer objects is usually realized by monitoring message topics, and the message topics consumed by various consumer objects may be different. Since consumer objects are changing and there is uncertainty, all message topics within the platform can be monitored, and the messages of all message topics can be persisted in the message center. For example, in the case of three message topics, Topic1, Topic2 and Topic3, consumer object A may consume the messages of Topic1, and consumer object B may consume the messages of Topic2. At this time, Topic1, Topic2 and Topic3 are all persistent. The messages of the three message topics Topic2 and Topic3 are persisted; this affects the monitoring performance of the message topics and increases the message space usage; in addition, when the monitored message topic changes due to the change of the consumer message topic of the consumer object, it can also be achieved by modifying the configuration information of the monitored message topic; for example, the monitored message topics configured in the original configuration information are Topic1, Topic2 and Topic3, which now need to be changed to Topic1 and Topic2; however, after modifying the configuration information, the message processing service needs to be restarted, which affects the dynamic monitoring change performance of the message topic, and thus affects the message processing efficiency.
[0042] Based on this, an embodiment of the present application provides a message processing method, apparatus, device, computer-readable storage medium and computer software; when the message processing method receives a subscription change request from a target consumer object to a target message topic, it updates the first correspondence between the consumer object and the message topic, and compares the updated message topic (first message topic set) with the message topic being monitored (second message topic set) to determine whether there is a monitoring change of the message topic; and when it is determined that there is a monitoring change of the message topic, since each monitored message topic corresponds to a monitoring object, the third correspondence is updated based on the target monitoring object corresponding to the target message topic to obtain a fourth correspondence, thereby realizing rapid dynamic changes in the correspondence between the consumer object and the message topic, and between the message topic and the monitoring object; and then the fourth correspondence can be used to realize message monitoring of different message topics, and the second correspondence can be used to realize message consumption of different message topics; therefore, the message processing efficiency can be improved.
[0043] The following describes an exemplary application of an electronic device for message processing (hereinafter referred to as a message processing device) provided in an embodiment of the present application. The message processing device provided in an embodiment of the present application can be implemented as various types of terminals such as smart phones, smart watches, laptops, tablet computers, desktop computers, smart home appliances, set-top boxes, smart car devices, portable music players, personal digital assistants, dedicated message devices, intelligent voice interaction devices, portable game devices, and smart speakers, and can also be implemented as a server. Below, an exemplary application when the message processing device is implemented as a server will be described.
[0044] See also Figure 2 , Figure 2 A schematic diagram of an application environment of a message method provided in an embodiment of the present application; Figure 2 As shown, the message processing device used by the message processing method provided in the embodiment of the present application can be applied to the server 400, and the server 400 can be connected to the terminal 200 through the network 300. Among them, the network 300 is used to provide a medium for the communication link between the server 400 and the terminal 200. The network 300 may include various connection types, for example, a wired communication link, a wireless communication link, etc., which is not limited in the embodiment of the present application. In addition, the message processing device may also be a smart phone, a laptop computer, and the like.
[0045] It should be noted that Figure 2 The server 400, network 300 and terminal 200 are schematic, and any number of servers, networks and terminals may be included according to implementation requirements. For example, the server 400 may be a physical server, or a server cluster composed of multiple servers, and the terminal 200 may be a mobile phone, a tablet, a desktop computer, a laptop computer, or other devices. In addition, the embodiment of the present application may also allow multiple terminals 200 to access the server 400 at the same time.
[0046] based on Figure 2 , see Figure 3 , Figure 3 Schematic diagram of an application scenario of the message processing method provided in the embodiment of the present application; Figure 3 As shown, to support a message processing application, in a message processing scenario 100, a terminal 200 (exemplarily showing a terminal 200-1 and a terminal 200-2) is connected to a server 400 via a network 300. In addition, the message processing scenario 100 also includes a server 500, the server 500 corresponds to a message source, and the server 400 is used to monitor the server 500 to monitor messages of different message topics.
[0047] Server 400 is used to respond to a subscription change request of a target consumer object to a target message topic, update a first correspondence based on the target consumer object and the target message topic to obtain a second correspondence, the first correspondence representing the correspondence between the consumer object and the message topic; determine a target monitoring object corresponding to the target message topic when the first message topic set in the second correspondence is different from the second message topic set in the third correspondence, the third correspondence representing the correspondence between the message topic and the monitoring object; update the third correspondence based on the target message topic and the target monitoring object to obtain a fourth correspondence; perform message monitoring based on the fourth correspondence, and perform message consumption in combination with the message monitoring result and the second correspondence, so as to send a message corresponding to the message topic to terminal 400 through network 300.
[0048] Terminal 200 is used to receive a message corresponding to a message subject sent by server 400 through network 300, and display the message (exemplarily showing graphical interface 210-1 (Hello, device A has a level one alarm, please handle it in time) and graphical interface 210-2 (Hello, device B has a level two alarm, please handle it in time)).
[0049] See also Figure 4 , Figure 4 This is a method provided by the embodiment of the present application. Figure 3 The structural diagram of the server in Figure 4 As shown, the server 400 includes: at least one processor 410, a memory 450 and at least one network interface 420; in some embodiments, the server 400 also includes a user interface 430. The various components in the server 400 are coupled together through a bus system 440. It can be understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 4 Various buses are labeled as bus system 440 .
[0050] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0051] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0052] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.
[0053] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0054] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0055] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0056] A network communication module 452, for reaching other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, Wireless Fidelity (Wi-Fi), and Universal Serial Bus (USB), etc.;
[0057] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.
[0058] In some embodiments, the message processing device provided in the embodiments of the present application can be implemented in software. Figure 4The message processing device 455 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., and includes the following software modules: a relationship update module 4551, a change determination module 4552, a message processing module 4553, a request generation module 4554 and an initial configuration module 4555. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0059] In some embodiments, the message processing device provided in the embodiments of the present application can be implemented in hardware. As an example, the message processing device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the message processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (Application Specific Integrated Circuit, ASIC), DSP, programmable logic device (Programmable Logic Device, PLD), complex programmable logic device (Complex Programmable Logic Device, CPLD), field programmable gate array (Field-Programmable Gate Array, FPGA) or other electronic components.
[0060] Below, the message processing method provided by the embodiment of the present application will be described in combination with the exemplary application and implementation of the message processing device provided by the embodiment of the present application. In addition, the message processing method provided by the embodiment of the present application is applied to various message processing scenarios such as cloud technology, artificial intelligence, smart transportation and vehicle-mounted.
[0061] See also Figure 5 , Figure 5 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 1 , where the execution subject of each step is the information processing device; Figure 5 The steps shown are explained.
[0062] Step 101: In response to a subscription change request from a target consumer object to a target message topic, a first corresponding relationship is updated based on the target consumer object and the target message topic to obtain a second corresponding relationship.
[0063] In an embodiment of the present application, the information processing device includes a first corresponding relationship, or the information processing device can obtain the first corresponding relationship from other devices (for example, storage devices such as databases), and the first corresponding relationship represents the corresponding relationship between the consumer object and the message subject; when the target consumer object subscribes to the target message subject or unsubscribes from the target consumer subject, the information processing device also receives the target consumer object's subscription change request for the target message subject; at this time, the information processing device responds to the subscription change request, updates the first corresponding relationship based on the target consumer object and the target message subject, and determines the updated first corresponding relationship as the second corresponding relationship. Therefore, the second corresponding relationship is the corresponding relationship between the consumer object and the message subject after responding to the message subscription change request.
[0064] It should be noted that the target consumer object refers to the consumer object that is currently changing the message topic. The consumer object is used to consume messages under the message topic, such as an alarm message processing device or account, a public account follow-up account, a news subscription account, etc.; the target message topic refers to the message topic corresponding to the message consumed by the target consumer object. The message topic is the category of the message, such as an alarm message category, a news category, a multimedia category, etc. In addition, the subscription change request is at least one of a message topic subscription request and a subscription cancellation request. The message topic subscription request refers to a request for the target consumer object to subscribe to the target message topic, and the subscription cancellation request refers to a request for the target consumer object to cancel its subscription to the target message topic. The first corresponding relationship is the corresponding relationship between the consumer object and the message topic when the subscription change request is received; and, in the first corresponding relationship, one message object corresponds to one message topic, indicating that one message object subscribes to messages of one message topic.
[0065] In an embodiment of the present application, the information processing device updates the first correspondence based on the subscription change request, so that the first correspondence and the second correspondence differ by the correspondence information between the target message object and the target message subject.
[0066] See also Figure 6 , Figure 6 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 2 ;like Figure 6 As shown, step 101 can be implemented through step 1011A, that is, the information processing device responds to the target consumer object's subscription change request for the target message topic, updates the first corresponding relationship based on the target consumer object and the target message topic, and obtains the second corresponding relationship, including step 1011A, which is explained below.
[0067] Step 1011A: when the subscription change request is a message topic subscription request, in response to the message topic subscription request of the target consumer object for the target message topic, the target consumer object and the target message topic are stored in the first corresponding relationship in correspondence to obtain a second corresponding relationship.
[0068] It should be noted that, when the message processing device determines that the subscription change request is a message topic subscription request, it indicates that the first correspondence relationship does not include the corresponding information of the target consumer object and the target message topic, and the corresponding information of the target consumer object and the target message topic will be added to the first correspondence relationship; thus, the message processing device stores the target consumer object and the target message topic in the first correspondence relationship, and the first correspondence relationship that stores the corresponding information of the target consumer object and the target message topic is the second correspondence relationship.
[0069] See also Figure 7 , Figure 7 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 3 ;like Figure 7 As shown, step 101 can be implemented through step 1011B, that is, the information processing device responds to the target consumer object's subscription change request for the target message topic, updates the first corresponding relationship based on the target consumer object and the target message topic, and obtains the second corresponding relationship, including step 1011B, which is explained below.
[0070] Step 1011B: when the subscription change request is a subscription cancellation request, in response to the target consumer object's subscription cancellation request for the target message topic, the target consumer object and the target message topic are deleted from the first corresponding relationship to obtain a second corresponding relationship.
[0071] It should be noted that, when the message processing device determines that the subscription change request is a subscription cancellation request, it indicates that the first corresponding relationship includes corresponding information of the target consumer object and the target message subject, and the corresponding information of the target consumer object and the target message subject is to be deleted from the first corresponding relationship; thus, the message processing device searches for the corresponding information of the target consumer object and the target message subject in the first corresponding relationship, and deletes the found corresponding information of the target consumer object and the target message subject from the first corresponding relationship, and the first corresponding relationship from which the corresponding information of the target consumer object and the target message subject is deleted is the second corresponding relationship.
[0072] Step 102: When the first message topic set in the second corresponding relationship is different from the second message topic set in the third corresponding relationship, determine the target monitoring object corresponding to the target message topic.
[0073] In an embodiment of the present application, since the second corresponding relationship represents the corresponding relationship between the consumer object and the message subject after responding to the message subscription change request, the message processing device obtains the full message subject in the second corresponding relationship, and determines the full message subject obtained from the second corresponding relationship as the first message subject set. In addition, the information processing device also includes a third corresponding relationship, or the information processing device can obtain the third corresponding relationship from other devices (such as storage devices such as databases), and the third corresponding relationship represents the corresponding relationship between the message subject and the monitoring object, so that the message processing device obtains the full message subject in the third corresponding relationship, and determines the full message subject obtained from the third corresponding relationship as the second message subject set. Here, since the first message subject set is a set consisting of the latest message subjects to be monitored, the second message subject set is a set consisting of the message subjects to be monitored before responding to the subscription change request; thus, when the first message subject set is different from the second message subject set, it indicates that there is a message subject of subscription change, and the message subject of the subscription change is the target message subject; then, the message processing device determines the target monitoring object corresponding to the target message subject, so as to combine the target message subject and the target monitoring object to perform the monitoring change of the message subject; wherein, the target monitoring object is used to monitor the message of the target message subject.
[0074] It should be noted that the monitoring object is used to monitor the messages corresponding to the message topic, and the third corresponding relationship is the corresponding relationship between the monitoring object and the message topic when a subscription change request is received; and, in the third corresponding relationship, one monitoring object corresponds to one message topic, indicating that one monitoring object monitors the messages of one message topic.
[0075] Continue to see Figure 6 , step 102 can be implemented through step 1021A and step 1022A; that is, when the first message topic set in the second corresponding relationship is different from the second message topic set in the third corresponding relationship, the message processing device determines the target monitoring object corresponding to the target message topic, including step 1021A and step 1022A, and each step is explained below.
[0076] Step 1021A: When the first message topic set in the second corresponding relationship is greater than the second message topic set in the third corresponding relationship, the target message topics that are greater than the second message topic set in the first message topic set are determined as the message topics to be added.
[0077] It should be noted that, when the first message topic set is different from the second message topic set, which means that the first message topic set is more than the second message topic set, it indicates that there are new message topics to be monitored, and the new message topics to be monitored are the message topics that the first message topic set has more than the second message topic set, and the extra message topics are the target message topics; thus, the message processing device determines that the target message topic is the message monitoring category to be added, and thus determines that the target message topic is the message topic to be added.
[0078] Step 1022A: Create a new target monitoring object for the message topic to be added.
[0079] It should be noted that, since the target message topic is a new message topic to be monitored, the target message topic has no corresponding monitoring object. Therefore, the message processing device creates a monitoring object for the message topic to be added, and thus obtains the target monitoring object.
[0080] In an embodiment of the present application, before creating a new target monitoring object for a message topic to be added, the message processing device determines the number of message topics of the new monitoring object to be created; when the number of message topics is multiple, the message topic with the highest priority is selected from the multiple message topics of the new monitoring object to create the monitoring object; and when the number of message topics is one, a new target monitoring object is created for the message topic to be added.
[0081] It should be noted that, in the case where multiple message topics are obtained by dividing the message topics, since different message topics correspond to different categories, the priority of message processing of different categories can be different; thus, different priorities can be set for multiple message topics; so that when multiple message topics are waiting to create monitoring objects, the message topic with the highest priority can be given priority to create a new monitoring object; in this way, the monitoring speed and consumption speed of the message topic with the highest priority can be improved, and the timeliness of message processing can be improved. In addition, in the case of determining to create a new target monitoring object for the message topic to be added, if it is determined that there is a message topic with a priority higher than the message topic to be added to be newly created, the timing is started; if it is determined before the end of the timing that the priority of the message topic to be added is the highest, a new target monitoring object is created for the message topic to be added; and if it is determined that there is still a message topic with a priority higher than the message topic to be added at the end of the timing, a new target monitoring object is created for the message topic to be added; in this way, the priority creation of the monitoring object of the message topic with the highest priority is achieved, and the waiting time of the message topic with a low priority is ensured to be within the specified range, so that in the process of creating the monitoring object, a balance between priority and efficiency is achieved.
[0082] Continue to see Figure 7, step 102 can be implemented through step 1021B and step 1022B; that is, when the first message topic set in the second corresponding relationship is different from the second message topic set in the third corresponding relationship, determining the target monitoring object corresponding to the target message topic includes step 1021B and step 1022B, and each step is explained below.
[0083] Step 1021B: when the first message topic set in the second corresponding relationship is less than the second message topic set in the third corresponding relationship, determine the target message topics that are less than the second message topic set in the first message topic set as the message topics to be deleted.
[0084] It should be noted that, when the first message topic set is different from the second message topic set, it means that the first message topic set is less than the second message topic set, which indicates that there are message topics that do not need to be monitored, and the message topics that do not need to be monitored are message topics whose first message topic set is less than the second message topic set, and the less message topics are the target message topics; thus, the message processing device determines that the target message topic is the message topic whose monitoring is to be canceled, and thus determines that the target message topic is the message topic to be deleted.
[0085] Step 1022B: Determine the target monitoring object corresponding to the subject of the message to be deleted from the third corresponding relationship.
[0086] It should be noted that, since the target message subject is the message subject to be unmonitored, the target message subject has a corresponding monitoring object; here, the monitoring object used to monitor the message of the target message subject is called the target monitoring object; thus, the corresponding information of the target message subject and the target monitoring object is stored in the third corresponding relationship; then, the message processing device can find the corresponding information of the target message subject and the target monitoring object from the third corresponding relationship, and delete the found corresponding information of the target message subject and the target monitoring object from the third corresponding relationship.
[0087] Step 103: Update the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship.
[0088] In an embodiment of the present application, since the target message topic is the message topic to be monitored and changed, and the target message topic corresponds to the target monitoring object, the message processing device updates the third correspondence based on the target message topic and the target monitoring object, so that each message topic in the updated third correspondence is the message topic to be monitored; here, the message processing device calls the updated third correspondence the fourth correspondence, so that the fourth correspondence is the latest correspondence between the message topic and the monitoring object obtained in response to the subscription change request.
[0089] It should be noted that, compared with the third correspondence, the fourth correspondence differs in the corresponding information of the target message subject and the target monitoring object; where, when the subscription change request is a message subject subscription request, the fourth correspondence has one more corresponding information of the target message subject and the target monitoring object than the third correspondence; and where the subscription change request is a subscription cancellation request, the third correspondence has one more corresponding information of the target message subject and the target monitoring object than the fourth correspondence.
[0090] In the embodiments of this application, see Figure 6 , step 103 can be implemented through step 1031A; that is, the message processing device updates the third corresponding relationship based on the target message subject and the target monitoring object to obtain the fourth corresponding relationship, including step 1031A, which is described below.
[0091] Step 1031A: When the target message subject is a message subject to be added, the target message subject and the target monitoring object are stored in a third corresponding relationship in correspondence with each other to obtain a fourth corresponding relationship.
[0092] It should be noted that, when the target message subject is a message subject to be added, the message processing device stores the target message subject and the target monitoring object in a third corresponding relationship so as to monitor the target message subject based on the target monitoring object. The third corresponding relationship storing the corresponding information of the target message subject and the target monitoring object is the fourth corresponding relationship. At this time, the fourth corresponding relationship has one more corresponding relationship between the target message subject and the target monitoring object than the third corresponding relationship.
[0093] In the embodiments of this application, see Figure 7 , step 103 can be implemented through step 1031B; that is, the message processing device updates the third corresponding relationship based on the target message subject and the target monitoring object to obtain the fourth corresponding relationship, including step 1031B, which is described below.
[0094] Step 1031B: when the target monitoring object is a monitoring object to be deleted, delete the target message subject and the target monitoring object from the third corresponding relationship to obtain a fourth corresponding relationship.
[0095] It should be noted that, when the target message subject is the subject of the message to be deleted, the message processing device searches for the monitoring object corresponding to the message subject that matches the target message subject from the third corresponding relationship. It is easy to know that the monitoring object corresponding to the message subject that matches the target message subject is the target monitoring object; thus, the target message subject and the monitoring object corresponding to the message subject that matches the target message subject are deleted from the third corresponding relationship, and the target message subject and the target monitoring object are deleted from the third corresponding relationship. Among them, the third corresponding relationship in which the corresponding information of the target message subject and the target monitoring object is deleted is the fourth corresponding relationship. At this time, the fourth corresponding relationship has one less corresponding information of the target message subject and the target monitoring object than the third corresponding relationship.
[0096] It can be understood that when it is determined that the monitoring of the message topic has been changed to add a new message topic to be monitored (called the target message topic), the correspondence between the current message topic and the monitoring object is updated by the new message topic to be monitored, and the latest correspondence between the message topic and the monitoring object can be obtained, thereby realizing the rapid update of the correspondence between the message topic and the monitoring object, and providing real-time data basis for the monitoring of the message topic.
[0097] In step 1031B of the embodiment of the present application, when the target monitoring object is a monitoring object to be deleted, the message processing device deletes the target message subject and the target monitoring object from the third corresponding relationship to obtain a fourth corresponding relationship, including: when the target monitoring object is a monitoring object to be deleted, the message processing device starts timing; when the timing duration reaches the specified duration, the target message subject and the target monitoring object are deleted from the third corresponding relationship. Before the timing duration reaches the specified duration, if the next message subject to be added is determined to be the target message subject in response to the next subscription change request, the timing ends and the deletion of the target message subject and the target monitoring object is canceled.
[0098] It should be noted that the message processing device can use a delayed deletion method to delete the target message subject and the target monitoring object; that is, when the message processing device determines that the target message subject and the target monitoring object are to be deleted from the third corresponding relationship, the target message subject and the target monitoring object are deleted after a specified period of time, so that in the time period corresponding to the moment of deletion and the moment after the specified period of time, if the message subject to be added is determined to be the target message subject, then by canceling the deletion of the target message subject and the target monitoring object, the target monitoring object of the target message subject is obtained; thereby, the steps of deleting the target monitoring object and creating the target monitoring object again are simplified, thereby reducing the resource consumption of message processing and improving the efficiency of message processing.
[0099] Step 104: Monitor messages based on the fourth corresponding relationship, and consume messages based on the message monitoring result and the second corresponding relationship.
[0100] In the embodiment of the present application, after the message processing device obtains the second correspondence and the fourth correspondence, the message subject change processing is completed; at this time, the message consumption can be performed in combination with the second correspondence and the fourth correspondence. Here, the message processing device monitors the message subject based on the monitoring object in the fourth correspondence, and sends the message obtained through the message monitoring to the consumer object corresponding to the corresponding message subject to realize message consumption; wherein, the message monitoring result refers to the message obtained through the message monitoring, that is, the message of the monitored message subject.
[0101] In an embodiment of the present application, the message subject is an alarm message subject, such as an emergency alarm, a normal alarm, and the like; at this time, the message processing device monitors the message based on the fourth correspondence, and consumes the message in combination with the message monitoring result and the second correspondence, including: the message processing device monitors the corresponding type of alarm message subject through each monitoring object in the fourth correspondence; and when the alarm message of the alarm message subject is monitored, based on the second correspondence, the consumption object corresponding to the alarm message subject is determined, and the consumption object corresponding to the determined alarm message subject is determined as the alarm message consumption object; wherein, the alarm message consumption object is used to consume the alarm message of the monitored alarm message subject.
[0102] It can be understood that the message processing method provided in the embodiment of the present application can be applied to the alarm message distribution scenario; by responding to the subscription change request, when it is determined that there is a monitoring change of the alarm message topic, the first corresponding relationship is updated to obtain the second corresponding relationship, and the third corresponding relationship is updated to obtain the fourth corresponding relationship, so as to obtain the latest correspondence between the alarm message topic and the alarm message consumption object, and the latest correspondence between the alarm message topic and the alarm message monitoring object, so as to quickly realize the monitoring change of the alarm message topic; thereby improving the message processing efficiency.
[0103] It can also be understood that by storing the first correspondence between the consumption object and the message topic, and the third correspondence between the message topic and the monitoring object, when a subscription change request for the target message topic is received from the target consumption object, by updating the first correspondence and comparing the message topic in the updated second correspondence with the message topic in the third correspondence, it is possible to determine whether there is a message topic change; and when it is determined that there is a message topic change, the third correspondence is updated based on the target monitoring object corresponding to the target message topic to obtain a fourth correspondence; thereby, in the case where the monitoring of the message topic is changed due to the change of the message topic by the consumption object, the correspondence between the consumption object and the message topic, and between the message topic and the monitoring object can be changed rapidly and dynamically, and then the monitoring of messages of different message topics can be realized through the fourth correspondence, and the consumption of messages by different message consumers can be realized through the second correspondence; therefore, the message processing efficiency can be improved.
[0104] In an embodiment of the present application, in step 101, the message processing device responds to the subscription change request of the target consumer object for the target message topic, updates the first correspondence based on the target consumer object and the target message topic, and obtains the second correspondence. The message processing method also includes: when the first message topic set is the same as the second message topic set, the message processing device determines that there is no message topic change; and when it is determined that there is no message topic change, ends the message processing process.
[0105] It should be noted that when responding to a subscription change request, the type of message topic in the first corresponding relationship may be the same as or different from the type of message topic in the second corresponding relationship; when the type of message topic in the first corresponding relationship is the same as the type of message topic in the second corresponding relationship, the first message topic set is the same as the second message topic set; at this time, there is no change in the message topic, the message monitoring process remains unchanged, and the message forwarding process is changed, thereby ending the message processing process of the message monitoring change.
[0106] It can be understood that when the target message topic involved in the subscription change request already exists in the third corresponding relationship, the message processing device ends the update of the third corresponding relationship, and monitors the message based on the third corresponding relationship, and consumes the message based on the second corresponding relationship; in this way, the resource consumption of message processing can be reduced.
[0107] In the examples of this application, see Figure 8 , Figure 8 This is a flow diagram of the message processing method provided in the embodiment of the present application. Figure 4 , where the execution subject of each step is the message processing device; Figure 8As shown, before step 101, steps 105 to 107 are also included; that is, the message processing device responds to the subscription change request of the target consumer object to the target message topic, updates the first corresponding relationship based on the target consumer object and the target message topic, and before obtaining the second corresponding relationship, the message processing method also includes steps 105 to 107, and each step is explained below.
[0108] Step 105: In response to the message service start request, monitor the blocking queue.
[0109] In an embodiment of the present application, when message monitoring and message consumption processing are triggered, a message service start request is received; at this time, the message processing device responds to the message service start request by monitoring the blocking queue to monitor the consumer object's change task on the message subject.
[0110] It should be noted that the message service start request is used to start the message service, which includes message processing such as message monitoring and message consumption. The blocking queue is used to store subscription change tasks of real-time message topics.
[0111] Step 106: Generate a subscription change task in response to the subscription change operation on the subscription change interface.
[0112] It should be noted that the message processing device provides a subscription change interface to external consumer objects, and the subscription change interface is used by consumer objects to make subscription changes to message topics (for example, subscribe, unsubscribe); thus, when the target consumer object makes a subscription change to the target message topic through the subscription change interface, the message processing device also receives the subscription change operation for the subscription change interface; at this time, the message processing device responds to the subscription change operation and generates a subscription change task for the target consumer object to make a subscription change to the target message topic.
[0113] Step 107: When an operation of storing a subscription change task in a blocking queue is monitored, a subscription change request is generated.
[0114] In an embodiment of the present application, the message processing device stores the subscription change task in a blocking queue. At this time, by listening to the blocking queue, the operation of storing the subscription change task in the blocking queue can be listened to; then, in response to the operation, a subscription change request of the target consumer object to the target message topic is generated, and the first corresponding relationship and the third corresponding relationship are dynamically updated based on the subscription change request.
[0115] In the embodiment of the present application, a subscription change request may also be generated through a thread wake-up mechanism.
[0116] It is understandable that through the monitoring mechanism, subscription change requests can be monitored in real time, and then the monitoring changes of message topics can be realized in real time and dynamically, thereby improving the monitoring change efficiency of message topics. In addition, by storing subscription change tasks in a blocking queue, subsequent processing is performed only when a subscription change task is monitored in the blocking queue, and monitoring continues when no subscription change task is monitored, thus reducing the resource consumption of monitoring changes of message topics.
[0117] In an embodiment of the present application, the message processing method also includes: the message processing device obtains a default message topic set in response to a message service startup request; traverses the default message topic set, and performs the following processing for each traversed default message topic: constructs a corresponding default monitoring object for the default message topic, and stores the default message topic and the default monitoring object in correspondence; after traversing the default message topic set, obtains a third corresponding relationship based on the correspondingly stored default message topics and the corresponding default monitoring objects.
[0118] It should be noted that when the message processing device responds to the message service startup request, it is also used to perform monitoring initialization of the message topic; that is, the message processing device creates a corresponding monitoring object for the default monitored message topic to realize the monitoring of the default monitored message topic. Among them, the default message topic set includes at least one default message topic, and each default message topic is a default monitored message topic. The message processing device creates a monitoring object for each default message topic, and the monitoring object created for each default message topic is called the default monitoring object. In addition, the default message topic can be a message topic whose monitoring priority is greater than the priority threshold determined by the monitoring priority.
[0119] It is understandable that when the message service is started in response to the message service start request, the response efficiency of the subscription change request can be improved by initializing the monitoring of the default message topic.
[0120] The following is an exemplary application of the embodiment of the present application in a practical application scenario. The exemplary application describes the monitoring and consumption process of the alarm message.
[0121] See also Fig. 9 , Fig. 9 is an exemplary message processing architecture diagram provided in an embodiment of the present application; Fig. 9As shown, three alarm message topics 9-11 to 9-13 are exemplarily shown, wherein alarm message topic 9-11 comes from alarm message source 9-21, alarm message topic 9-12 comes from alarm message source 9-22, and alarm message topic 9-13 comes from alarm message source 9-23; in message center 9-3 (referred to as message processing device), consumer object 9-311 (referred to as monitoring object) monitors the alarm message of alarm message topic 9-11, consumer object 9-312 (referred to as monitoring object) monitors the alarm message of alarm message topic 9-12, and consumer object 9-313 (referred to as monitoring object) monitors the alarm message of alarm message topic 9-13; and, the addition and deletion of consumer objects are realized by monitoring the subscription or cancellation tasks (referred to as subscription change tasks) in blocking queue 9-32. The message center 9-3 also includes an external interface 9-33, which is used to respond to a subscription request (called a message topic subscription request) or a cancellation request (called a subscription cancellation request) for the alarm consumption topic by an external system 9-4 (called a consumer object) to add a subscription task or add a cancellation task to the blocking queue 9-32.
[0122] It should be noted that the message center includes a user-topic information table (User_Topic_Info table, called the first correspondence), which is used to record the correspondence between the alarm message topic subscribed by the external system and the docking address; the message center also includes a startup class (ApplicationRunner). After the service is started, the run method (run()) of the startup class ApplicationRunner is called to initialize the default alarm message topic; wherein, the initialization of the default alarm message topic refers to traversing the initialization listening list (called the default message topic set), the initialization listening list is a list composed of at least one default alarm message topic, for each default alarm message topic traversed, a consumer object (called the default listening object) is created through the Kafka interface to listen to the default alarm message topic and complete the consumption processing of the listened message, and at the same time, each default alarm message topic and the created consumer object are stored in the cache Map accordingly. Here, the startup class uses a while loop to execute the loop processing of the change. The while loop includes a blocking queue, which is used to add a change task based on the change message of the alarm message topic subscribed to the external system received; after receiving the change message, based on the alarm message topic and docking address in the change message, the User_Topic_Info table is updated, and the latest alarm message topic Topic subscription list (called the first message topic set) in the updated User_Topic_Info table (called the second corresponding relationship) is compared with the alarm message topic Topic subscription list (called the second message topic set) in the cache Map; according to the comparison result, if it is determined that there is a new Topic to be monitored, c. Create a consumer object through the Kafka interface, specify the created consumer object to listen to the newly added Topic, complete the consumption processing and persistence of the messages of the newly added Topic, and update the cache Map (called the third correspondence) at the same time, reducing the business impact on the monitoring and consumption logic of other Topics; according to the comparison results, if the Topic to be deleted is determined, delete the Topic to be deleted through the Kafka interface to cancel the monitoring of the Topic, and update the cache Map at the same time, reducing the business impact on the monitoring and consumption logic of other Topics; finally, push the monitored messages to the external system through the interface address provided when the external system subscribes.
[0123] based on Fig. 9 , see Fig.10 , Fig.10 is an exemplary message processing flow chart provided in an embodiment of the present application; Fig.10As shown, the message center includes a user-topic information table 10-1; in addition, the creation of consumer objects, the monitoring of topics, and the processing of messages are encapsulated in the new consumer object service (AddConsumerService tool class) 10-3, and the logic of canceling the monitoring of consumer objects is encapsulated in the deletion of consumer object service (DelConsumerService tool class) 10-5; it is easy to know that when the message center initializes the message topic, for each Topic, a consumer object is created through the AddConsumerService tool class to realize the asynchronous consumption of the message of the Topic, that is, the Topic and the consumer object are one-to-one. Each monitored Topic and the corresponding consumer object are stored in the cache; in addition, the startup class 10-2 monitors whether there are pending change tasks in the blocking queue through a While loop. Thus, the exemplary message processing flow includes steps 1001 to 1005, and each step is described below.
[0124] Step 1001: Receive a subscription request or a cancel subscription request.
[0125] Here, the message center updates the user-topic information table 10-1 based on the subscription request or unsubscription request received from the external system 9-4.
[0126] It should be noted that the message center 9-3 includes a subscription interface, through which the external system 9-4 implements the subscription operation or unsubscription operation of the Topic, so that the message center 9-3 can receive a subscription request or unsubscription request from the external system 9-4.
[0127] Step 1002: Query the latest alarm message topic subscription information.
[0128] It should be noted that, when an external system subscribes to a Topic, a subscription task is stored in a blocking queue. When the While loop process monitors that there is a subscription task in the queue, the list of Topics subscribed by the external system in the user-topic information table 10-1 is queried and compared with the list of Topics currently monitored in the cache. Therefore, during the service startup process, the startup class 10-2 responds to the subscription request or the unsubscription request and queries the latest alarm message topic subscription information from the user-topic information table 10-1.
[0129] Step 1003: Change the monitoring of the alarm message topic.
[0130] It should be noted that if the queried latest alarm message topic subscription information is different from the latest alarm message topic monitoring information in the cache, it is determined to change the monitoring of the alarm message topic.
[0131] Step 1004: Add a new alarm message topic.
[0132] It should be noted that, when the list of topics subscribed by the external system in the user-topic information table 10-1 has more topics than the list of topics currently monitored in the cache, it is determined that the monitoring of the changed alarm message topic is the newly added alarm message topic; at this time, the new consumer object service 10-3 is called to create a consumer object to monitor the message source 10-4 of the newly added alarm message topic, and push the message to the external system 9-4, and update the cache based on the newly added alarm message topic and the created consumer object.
[0133] Step 1005: Delete the alarm message topic.
[0134] It should be noted that, when the list of topics subscribed by the external system in the user-topic information table 10-1 has fewer topics than the list of topics currently monitored in the cache, it is determined that the monitoring of the change alarm message topic is to delete the alarm message topic; at this time, the deletion consumer object service 10-5 is called to delete the consumer object corresponding to the alarm message topic to cancel the monitoring of the deleted alarm message topic and the message push, and at the same time update the cache based on the deleted alarm message topic and the deleted consumer object.
[0135] Exemplarily, the system's internal service (called the message source) A generates an alarm message type A, and service B generates an alarm message type B; according to the message classification rules, the alarm message type A corresponds to Topic A, and the alarm message type B corresponds to Topic B; if the external system A pulls a message of the alarm message type A at this time, then it subscribes to Topic A from the message center; if the external system B pulls a message of the alarm message type at this time, then it subscribes to Topic B from the message center without modifying the service configuration and restarting; and it has no impact on the message consumption of the external system A; and, if the external system B cancels its subscription to Topic B at this time, then it only needs to cancel the monitoring of Topic B, which has no impact on the message consumption of the external system A.
[0136] It is understandable that the interface provided by Kafka is used to create and delete consumer objects to monitor and cancel the monitoring of topics, and the list of monitored topics in the cache is dynamically updated in combination with the blocking queue and the subscription information of the external system, so that the message processing of each topic is realized through an independent consumer object and in an asynchronous manner, and has no impact on the monitoring and consumption logic of other topics. In addition, based on subscription change information and cyclic monitoring processing (While loop + blocking queue, or thread wake-up mechanism), it is possible to use Kafka's interface to dynamically add and delete consumer objects, thereby realizing dynamic monitoring and message processing of topics, improving the performance of message processing, and reducing the storage space occupied by message persistence.
[0137] The following further describes an exemplary structure of the message processing device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, for example Figure 4 As shown, the software modules stored in the message processing device 455 of the memory 450 may include:
[0138] The relationship updating module 4551 is used to respond to a subscription change request of a target consumer object to a target message topic, update a first corresponding relationship based on the target consumer object and the target message topic, and obtain a second corresponding relationship, wherein the first corresponding relationship represents a corresponding relationship between the consumer object and the message topic;
[0139] a change determination module 4552, configured to determine a target monitoring object corresponding to the target message subject when the first message subject set in the second correspondence relationship is different from the second message subject set in the third correspondence relationship, wherein the third correspondence relationship represents a correspondence relationship between a message subject and a monitoring object;
[0140] The relationship updating module 4551 is further configured to update the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship;
[0141] The message processing module 4553 is used to monitor messages based on the fourth corresponding relationship, and consume messages in combination with the message monitoring result and the second corresponding relationship.
[0142] In an embodiment of the present application, the subscription change request is at least one of a message topic subscription request and a subscription cancellation request, the message topic subscription request refers to a request for the target consumer object to subscribe to the target message topic, and the subscription cancellation request refers to a request for the target consumer object to cancel its subscription to the target message topic.
[0143] In an embodiment of the present application, the relationship update module 4551 is also used to, when the subscription change request is a message topic subscription request, store the target consumer object and the target message topic in correspondence in the first corresponding relationship to obtain the second corresponding relationship; when the subscription change request is a subscription cancellation request, delete the target consumer object and the target message topic from the first corresponding relationship to obtain the second corresponding relationship.
[0144] In an embodiment of the present application, the change determination module 4552 is also used to, when the first message topic set in the second corresponding relationship is more than the second message topic set in the third corresponding relationship, determine the target message topics that are more in the first message topic set than in the second message topic set as message topics to be added, and create a new target monitoring object for the message topics to be added; when the first message topic set in the second corresponding relationship is less than the second message topic set in the third corresponding relationship, determine the target message topics that are less in the first message topic set than in the second message topic set as message topics to be deleted, and determine the target monitoring object corresponding to the message topic to be deleted from the third corresponding relationship.
[0145] In an embodiment of the present application, the relationship update module 4551 is also used to, when the target message subject is a message subject to be added, store the target message subject and the target monitoring object in correspondence with each other in the third corresponding relationship to obtain the fourth corresponding relationship; when the target monitoring object is a monitoring object to be deleted, delete the target message subject and the target monitoring object from the third corresponding relationship to obtain the fourth corresponding relationship.
[0146] In an embodiment of the present application, the change determination module 4552 is also used to determine that there is no message topic change when the first message topic set is the same as the second message topic set; when it is determined that there is no message topic change, end the message processing process.
[0147] In an embodiment of the present application, the message processing device 455 also includes a request generation module 4554, which is used to listen to the blocking queue in response to the message service startup request; generate a subscription change task in response to the subscription change operation on the subscription change interface; and generate the subscription change request when the operation of storing the subscription change task in the blocking queue is listened to.
[0148] In an embodiment of the present application, the message processing device 455 also includes an initial configuration module 4555, which is used to obtain a default message topic set in response to the message service startup request; traverse the default message topic set, and perform the following processing for each traversed default message topic: construct a corresponding default monitoring object for the default message topic; store the default message topic and the default monitoring object in correspondence; after traversing the default message topic set, obtain the third corresponding relationship based on the correspondingly stored default message topics and the correspondingly stored default monitoring objects.
[0149] In an embodiment of the present application, the message subject is an alarm message subject; the message processing module 4553 is also used to monitor the alarm message subject of the corresponding type through each of the monitoring objects in the fourth corresponding relationship; when the alarm message of the alarm message subject is monitored, based on the second corresponding relationship, the consumer object corresponding to the alarm message subject is determined, and the consumer object corresponding to the determined alarm message subject is determined as an alarm message consumer object, and the alarm message consumer object is used to consume the alarm message of the monitored alarm message subject.
[0150] The embodiment of the present application provides a computer software, which includes a computer executable instruction or a computer program, and the computer executable instruction or computer program is stored in a computer readable storage medium. The processor of the message processing device reads the computer executable instruction or computer program from the computer readable storage medium, and the processor executes the computer executable instruction or computer program, so that the message processing device executes the message processing method described above in the embodiment of the present application.
[0151] The embodiment of the present application provides a computer-readable storage medium, in which computer executable instructions or computer programs are stored. When the computer executable instructions or computer programs are executed by a processor, the processor will be caused to execute the message processing method provided by the embodiment of the present application, for example, Figure 5 The message processing method is shown.
[0152] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.
[0153] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0154] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0155] As an example, computer executable instructions may be deployed to be executed on one electronic device (in which case, this one electronic device is the message processing device), or on multiple electronic devices located at one location (in which case, the multiple electronic devices located at one location are the message processing devices), or on multiple electronic devices distributed at multiple locations and interconnected by a communication network (in which case, the multiple electronic devices distributed at multiple locations and interconnected by a communication network are the message processing devices).
[0156] It is understandable that in the embodiments of the present application, data related to subscription operations, unsubscription operations, and messages, when the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of relevant data need to comply with relevant laws, regulations, and standards of relevant countries and regions. In addition, in the present application, the implementation of the message monitoring technical solution involved, when the above embodiments of the present application are applied to specific products or technologies, the relevant message collection, use, and processing process should comply with the requirements of national laws and regulations, comply with the principles of legality, legitimacy, and necessity, do not involve obtaining data types prohibited or restricted by laws and regulations, and will not hinder the normal operation of the target website.
[0157] To summarize, the embodiment of the present application stores the first correspondence between the consumption object and the message topic, and the third correspondence between the message topic and the monitoring object, so that when a subscription change request for the target message topic is received from the target consumption object, by updating the first correspondence and comparing the message topic in the updated second correspondence with the message topic in the third correspondence, it is possible to determine whether there is a message topic change; and when it is determined that there is a message topic change, the third correspondence is updated based on the target monitoring object corresponding to the target message topic to obtain a fourth correspondence; thereby, in the case where the monitoring of the message topic is changed due to the change of the message topic by the consumption object, the correspondence between the consumption object and the message topic, and between the message topic and the monitoring object can be changed rapidly and dynamically, and then the monitoring of messages of different message topics can be realized through the fourth correspondence, and the consumption of messages by different message consumers can be realized through the second correspondence; therefore, the message processing efficiency can be improved and the consumption of space resources can be reduced.
[0158] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A message processing method, characterized in that: The method comprises: In response to a subscription change request of a target consumer object to a target message topic, a first correspondence relationship is updated based on the target consumer object and the target message topic to obtain a second correspondence relationship, wherein the first correspondence relationship represents a correspondence relationship between the consumer object and the message topic; In the case where the first message topic set in the second corresponding relationship is different from the second message topic set in the third corresponding relationship, determining the target monitoring object corresponding to the target message topic, wherein the third corresponding relationship represents the corresponding relationship between the message topic and the monitoring object; Update the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship; Message monitoring is performed based on the fourth corresponding relationship, and message consumption is performed in combination with the message monitoring result and the second corresponding relationship.
2. The method according to claim 1, characterized in that The updating of the first corresponding relationship based on the target consumption object and the target message subject to obtain the second corresponding relationship includes: In the case where the subscription change request is a message topic subscription request, the target consumer object and the target message topic are stored in the first corresponding relationship in correspondence with each other to obtain the second corresponding relationship; In the case where the subscription change request is a subscription cancellation request, the target consumer object and the target message topic are deleted from the first corresponding relationship to obtain the second corresponding relationship.
3. The method according to claim 1, characterized in that In the case where the first message topic set in the second corresponding relationship is different from the second message topic set in the third corresponding relationship, determining the target monitoring object corresponding to the target message topic includes: In the case that the first message topic set in the second corresponding relationship is more than the second message topic set in the third corresponding relationship, the target message topics that are more than the second message topic set in the first message topic set are determined as message topics to be added, and the target monitoring object is newly created for the message topics to be added; When the first message topic set in the second corresponding relationship is less than the second message topic set in the third corresponding relationship, the target message topic that is less than the second message topic set in the first message topic set is determined as the message topic to be deleted, and the target monitoring object corresponding to the message topic to be deleted is determined from the third corresponding relationship.
4. The method according to claim 1, characterized in that: The updating the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship includes: In the case where the target message subject is a message subject to be added, the target message subject and the target monitoring object are stored in the third corresponding relationship in correspondence with each other to obtain the fourth corresponding relationship; In the case that the target monitoring object is a monitoring object to be deleted, the target message subject and the target monitoring object are deleted from the third corresponding relationship to obtain the fourth corresponding relationship.
5. The method according to any one of claims 1 to 4, characterized in that: In response to the target consumer object's subscription change request for the target message topic, before updating the first corresponding relationship based on the target consumer object and the target message topic to obtain the second corresponding relationship, the method further includes: In response to the message service start request, listen to the blocking queue; In response to a subscription change operation on a subscription change interface, generating a subscription change task; In case of monitoring the operation of storing the subscription change task in the blocking queue, the subscription change request is generated.
6. The method according to claim 5, characterized in that The method further comprises: In response to the message service start request, obtaining a default message topic set; Traversing the default message topic set, and performing the following processing for each traversed default message topic: constructing a corresponding default monitoring object for the default message topic; and storing the default message topic and the default monitoring object in correspondence; When the default message topic set is traversed, the third corresponding relationship is obtained based on the correspondingly stored default message topics and the default monitoring objects.
7. A message processing device, characterized in that: The message processing device comprises: a relationship updating module, configured to respond to a subscription change request of a target consumer object to a target message subject, update a first corresponding relationship based on the target consumer object and the target message subject to obtain a second corresponding relationship, wherein the first corresponding relationship represents a corresponding relationship between the consumer object and the message subject; a change determination module, configured to determine a target monitoring object corresponding to the target message subject when the first message subject set in the second corresponding relationship is different from the second message subject set in the third corresponding relationship, wherein the third corresponding relationship represents a corresponding relationship between a message subject and a monitoring object; The relationship updating module is further used to update the third corresponding relationship based on the target message subject and the target monitoring object to obtain a fourth corresponding relationship; A message processing module is used to monitor messages based on the fourth corresponding relationship, and consume messages in combination with the message monitoring result and the second corresponding relationship.
8. An electronic device for message processing, characterized in that: The electronic device comprises: A memory for storing computer executable instructions or computer programs; The processor is used to implement the message processing method described in any one of claims 1 to 6 when executing the computer executable instructions or computer programs stored in the memory.
9. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the message processing method according to any one of claims 1 to 6 is implemented.
10. Computer software, comprising computer executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the message processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Event control system and method
CN108241542A
Message queue-based data processing method and device, computer equipment and medium
CN112612607A
Data management method and device, electronic equipment and computer readable storage medium
CN113422790A
Message subscription method and device based on ZK server
CN114840353A
Event management system and method
CN115550439A