Message processing method, apparatus, device, storage medium and computer program product

CN119561928BActive Publication Date: 2026-10-30MASHANG CONSUMER FINANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311136478.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-04
Publication Date
2026-10-30
Estimated Expiration
2043-09-04

AI Technical Summary

Technical Problem

[0002]在消息发布应用中,存在着各种消息主题(Topic)和各种消费对象,消费对象对消息的消费通常通过监听消息主题实现,并且各种消费对象所消费的消息主题可能不同;在因消费对象变更消费消息主题而引起消息主题的监听变更的情况下,常常需要修改监听消息主题的配置信息;然而,修改配置信息之后需重启消息处理服务,影响了消息处理效率

Benefits of technology

[0020]本申请实施例至少具有以下有益效果:通过存储消费对象与消息主题之间的第一对应关系,以及消息主题与监听对象之间的第三对应关系,使得在接收到目标消费对象对目标消息主题的订阅变更请求时,通过更新第一对应关系,并将更新出的第二对应关系中的消息主题与第三对应关系中的消息主题进行比较,就能够确定是否存在消息主题变更;以及在确定存在消息主题变更时,基于目标消息主题对应的目标监听对象更新第三对应关系,以得到第四对应关系;从而,在因消费对象变更消息主题而引起消息主题的监听变更的情况下,能够实现消费对象与消息主题、以及消息主题与监听对象之间的对应关系的快速动态变更,进而通过第四对应关系就能够实现不同消息主题的消息的监听,以及通过第二对应关系就能够实现不同消息消费对消息的消费;因此,能够提升消息处理效率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119561928B_ABST
    Figure CN119561928B_ABST
Patent Text Reader

Abstract

The application provides a message processing method, device, equipment, storage medium and computer software; the method comprises the following steps: in response to a subscription change request of a target consumer object to a target message topic, updating a first correspondence relationship based on the target consumer object and the target message topic to obtain a second correspondence relationship, the first correspondence relationship representing the correspondence relationship between the consumer object and the message topic; in the case that a first message topic set in the second correspondence relationship is different from a second message topic set in a third correspondence relationship, determining a target listener object corresponding to the target message topic, the third correspondence relationship representing the correspondence relationship between the message topic and the listener object; updating the third correspondence relationship based on the target message topic and the target listener object to obtain a fourth correspondence relationship; performing message listening based on the fourth correspondence relationship, and performing message consumption in combination with the message listening result and the second correspondence relationship. Through the application, the message processing efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a message processing method, apparatus, device, storage medium, and computer software. Background Technology

[0002] In message publishing applications, there are various message topics and various consumer objects. Consumer objects typically consume messages by listening to message topics, and different consumer objects may consume different message topics. When the message topic listening changes due to a change in the message topic consumed by a consumer object, it is often necessary to modify the configuration information of the message topic listening. 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] This application provides a message processing method, apparatus, device, storage medium, and computer software that can improve message processing efficiency.

[0004] The technical solution of this application embodiment is implemented as follows:

[0005] This application provides a message processing method, the method comprising:

[0006] In response to a subscription change request from a target consumer to a target message topic, the first correspondence is updated based on the target consumer and the target message topic to obtain a second correspondence, wherein the first correspondence represents the correspondence between the consumer and the message topic;

[0007] If the first message topic set in the second correspondence relationship is different from the second message topic set in the third correspondence relationship, the target listening object corresponding to the target message topic is determined, and the third correspondence relationship represents the correspondence between message topics and listening objects;

[0008] The third correspondence is updated based on the target message topic and the target listening object to obtain the fourth correspondence;

[0009] Message listening is performed based on the fourth correspondence, and message consumption is performed by combining the message listening results with the second correspondence.

[0010] This application provides a message processing device, the message processing device comprising:

[0011] The relationship update module is used to respond to the subscription change request of the target consumer object to the target message topic, update the first correspondence relationship based on the target consumer object and the target message topic to obtain the second correspondence relationship, wherein the first correspondence relationship represents the correspondence relationship between the consumer object and the message topic;

[0012] The change determination module is used to determine the target listening object corresponding to the target message topic when the first message topic set in the second correspondence relationship is different from the second message topic set in the third correspondence relationship, wherein the third correspondence relationship represents the correspondence between the message topic and the listening object;

[0013] The relationship update module is also used to update the third correspondence relationship based on the target message topic and the target listening object to obtain the fourth correspondence relationship;

[0014] The message processing module is used to listen for messages based on the fourth correspondence and to consume messages by combining the message listening results with the second correspondence.

[0015] This application provides an electronic device for message processing, the electronic device comprising:

[0016] Memory is used to store executable instructions or computer programs.

[0017] The processor, when executing computer-executable instructions or computer programs stored in the memory, implements the message processing method provided in the embodiments of this application.

[0018] This application provides a computer-readable storage medium storing computer-executable instructions or computer programs, which, when executed by a processor, implement the message processing method provided in this application.

[0019] This application provides computer software, including computer-executable instructions or computer programs, which, when executed by a processor, implement the message processing method provided in this application.

[0020] The embodiments of this application have at least the following beneficial effects: By storing a first correspondence between a consumer object and a message topic, and a third correspondence between a message topic and a listening object, when a subscription change request for a target message topic is received from a target consumer object, the first correspondence is updated, and the message topic in the updated second correspondence is compared with the message topic in the third correspondence to determine whether a message topic change has occurred. Furthermore, when a message topic change is determined, the third correspondence is updated based on the target listening object corresponding to the target message topic to obtain a fourth correspondence. Thus, in the case of a message topic change caused by a change in the consumer object's message topic, rapid and dynamic changes in the correspondence between the consumer object and the message topic, and between the message topic and the listening object, are possible. This allows for the listening of messages with different message topics through the fourth correspondence, and the consumption of messages by different message consumers through the second correspondence. Therefore, message processing efficiency can be improved. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of an exemplary message processing structure;

[0022] Figure 2 This is a schematic diagram illustrating the application environment of a messaging method provided in an embodiment of this application.

[0023] Figure 3 This is a schematic diagram illustrating an application scenario of the message processing method provided in the embodiments of this application;

[0024] Figure 4 This is one of the embodiments provided in this application. Figure 3 A schematic diagram of the server structure in the diagram;

[0025] Figure 5 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 1 ;

[0026] Figure 6 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 2 ;

[0027] Figure 7 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 3 ;

[0028] Figure 8 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 4 ;

[0029] Figure 9 This is an exemplary message processing architecture diagram provided in an embodiment of this application;

[0030] Figure 10 This is an exemplary message processing flowchart provided in an embodiment of this application. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0032] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is 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 objects. It is understood that “first, second, third, fourth” may be interchanged in a specific order or sequence where permitted, so that the embodiments of this 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 this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0035] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0036] 1) The distributed publish-subscribe messaging system (Kafka) is used to improve message consumption efficiency in message publishing applications and is widely used in various business platforms, such as exception message handling platforms. The message processing method provided in this application embodiment can use Kafka to implement message listening, subscription changes, and inference, among other message processing functions.

[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, and therefore include different message topics.

[0038] 3) The annotation (@KafkaListener) is used to listen for and fetch messages, and then send these messages to the consumer object after converting them into a specified format.

[0039] 4) In response to, used to indicate the conditions or states on which the operation performed depends, one or more operations performed may be performed in real time or with a set delay if the conditions or states on which they depend are met; unless otherwise specified, there is no restriction on the order in which the multiple operations are performed.

[0040] It should be noted that when connecting multiple message topics within the platform to external systems, a common component (e.g., a message center) is typically developed within the platform to connect to multiple message sources within the platform and to multiple external systems to achieve real-time message push functionality. The message center can listen to message topics from multiple message sources within the platform using the `@KafkaListener` annotation on message middleware (e.g., Kafka). For example, see [link to example]. Figure 1 , Figure 1 This is a schematic diagram of an exemplary message processing structure; such as Figure 1 As shown, message center 1-1 is used to interface with external system 1-2 to obtain interface information from external system 1-2. Message center 1-1 includes annotation 1-3, which is used to listen to messages in the message topics corresponding to message sources (for example, message topics 1-51 to 1-53 corresponding to message sources 1-41 to 1-43 are shown), and push the listened messages to external system 1-2 based on the interface information. Typically, in order to resend messages when they fail to be sent, the messages can be persisted in the message middleware, and then pushed to the external system according to the interface specifications with the external system.

[0041] In other words, in a message publishing application, there are various message topics and various consumer objects. Consumer objects typically consume messages by listening to message topics, and the message topics consumed by different consumer objects may be different. Because consumer objects are dynamic and uncertain, it is possible to listen to all message topics within the platform and persist messages for all message topics in the message center. For example, if there are three message topics: Topic1, Topic2, and Topic3, consumer object A might consume messages from Topic1, while consumer object B might consume messages from Topic2. In this case, the message topics from Topic1 and Topic2 are stored in the message center. The messages from Topic2 and Topic3 ​​are persisted; however, this impacts message topic listening performance and increases message space usage. Furthermore, when the message topics being listened to change due to a change in the consumer's message topic, this can be achieved by modifying the message topic listening configuration information. For example, if the original configuration specified Topic1, Topic2, and Topic3, it needs to be changed to Topic1 and Topic2. However, modifying the configuration requires restarting the message processing service, impacting the performance of dynamic message topic listening and thus affecting message processing efficiency.

[0042] Based on this, embodiments of this application provide 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 for 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 currently monitored message topic (second message topic set) to determine if there is a message topic monitoring change. When a message topic monitoring change is determined to exist, 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, thus achieving rapid dynamic changes in the correspondence between the consumer object and the message topic, and between the message topic and the monitoring object. Furthermore, the fourth correspondence enables message monitoring of different message topics, and the second correspondence enables message consumption of different message topics; therefore, message processing efficiency can be improved.

[0043] The following describes exemplary applications of the electronic device for message processing (hereinafter referred to as the message processing device) provided in the embodiments of this application. The message processing device provided in the embodiments of this application can be implemented as various types of terminals such as smartphones, smartwatches, laptops, tablets, desktop computers, smart home appliances, set-top boxes, smart in-vehicle devices, portable music players, personal digital assistants, dedicated messaging devices, smart voice interaction devices, portable gaming devices, and smart speakers, or it can be implemented as a server. The following will describe exemplary applications when the message processing device is implemented as a server.

[0044] See Figure 2 , Figure 2 This is a schematic diagram illustrating the application environment of a messaging method provided in an embodiment of this application; for example... Figure 2 As shown, the message processing device used in the message processing method provided in this embodiment can be applied to a server 400, which can be connected to a terminal 200 via a network 300. The network 300 serves as a medium for providing a communication link between the server 400 and the terminal 200. The network 300 can include various connection types, such as wired communication links, wireless communication links, etc., and this embodiment does not limit this. Additionally, the message processing device can also be a smartphone, a laptop computer, etc.

[0045] It should be noted that, Figure 2 The server 400, network 300, and terminal 200 in the diagram are illustrative and can include any number of servers, networks, and terminals as needed. For example, server 400 can be a physical server or a server cluster composed of multiple servers, and terminal 200 can be a mobile phone, tablet, desktop computer, laptop computer, or other device. Furthermore, embodiments of this application can also allow multiple terminals 200 to access server 400 simultaneously.

[0046] based on Figure 2 See Figure 3 , Figure 3 This is a schematic diagram illustrating an application scenario of the message processing method provided in the embodiments of this application; for example... Figure 3 As shown, to support a message processing application, in message processing scenario 100, terminal 200 (terminals 200-1 and 200-2 are shown as examples) connects to server 400 via network 300. Additionally, message processing scenario 100 also includes server 500, which corresponds to the message source. Server 400 is used to listen to server 500 to monitor messages on different topics.

[0047] Server 400 is used to respond to a subscription change request from a target consumer for a target message topic. Based on the target consumer and the target message topic, it updates the first correspondence to obtain a second correspondence. The first correspondence represents the correspondence between the consumer and the message topic. If the first message topic set in the second correspondence differs from the second message topic set in the third correspondence, it determines the target listening object corresponding to the target message topic. The third correspondence represents the correspondence between the message topic and the listening object. Based on the target message topic and the target listening object, it updates the third correspondence to obtain a fourth correspondence. Based on the fourth correspondence, it performs message listening and consumes messages by combining the message listening results with the second correspondence, so as to send the message corresponding to the message topic to terminal 400 via network 300.

[0048] Terminal 200 is used to receive messages corresponding to the message topic sent by server 400 through network 300 and display the message (exemplary graphical interfaces 210-1 (Hello, device A has a level 1 alarm, please handle it in time) and 210-2 (Hello, device B has a level 2 alarm, please handle it in time) are shown).

[0049] See Figure 4 , Figure 4 This is one of the embodiments provided in this application. Figure 3 A schematic diagram of the server structure in the diagram; such as Figure 4 As shown, server 400 includes at least one processor 410, memory 450, and at least one network interface 420; in some embodiments, server 400 also includes a user interface 430. The various components in server 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to implement communication between these components. In addition to a data bus, bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 4 The general labeled all buses 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. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0051] User interface 430 includes one or more output devices 431 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. 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 storage, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices physically located away from the processor 410.

[0053] The memory 450 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 450 described in this application embodiment is intended to include any suitable type of memory.

[0054] In some embodiments, memory 450 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.

[0055] Operating system 451 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;

[0056] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: Bluetooth, Wi-Fi, and Universal Serial Bus (USB), etc.

[0057] The input processing module 454 is used to detect and translate one or more user inputs or interactions from one or more input devices 432.

[0058] In some embodiments, the message processing apparatus provided in this application can be implemented in software. Figure 4A message processing device 455 stored in memory 450 is shown. This device can be software in the form of programs and plug-ins, 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 logically linked and can therefore be arbitrarily combined or further divided according to their implemented functions. The functions of each module will be described below.

[0059] In some embodiments, the message processing apparatus provided in this application can be implemented in hardware. As an example, the message processing apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the message processing method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0060] The message processing method provided in this application will be described below with reference to exemplary applications and implementations of the message processing device provided in the embodiments of this application. Furthermore, the message processing method provided in the embodiments of this application is applicable to various message processing scenarios such as cloud technology, artificial intelligence, smart transportation, and in-vehicle systems.

[0061] See Figure 5 , Figure 5 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 1 In this process, the main body executing each step is the information processing equipment; the following will combine... Figure 5 The steps shown are explained.

[0062] Step 101: In response to the target consumer's subscription change request for the target message topic, update the first correspondence based on the target consumer and the target message topic to obtain the second correspondence.

[0063] In this embodiment, the information processing device includes a first correspondence, or the information processing device can obtain the first correspondence from other devices (e.g., storage devices such as databases). This first correspondence represents the correspondence between a consumer object and a message topic. When a target consumer object subscribes to or unsubscribes from a target message topic, the information processing device receives a subscription change request from the target consumer object. In response to this subscription change request, the information processing device updates the first correspondence based on the target consumer object and the target message topic, and determines the updated first correspondence as the second correspondence. Therefore, the second correspondence is the correspondence between the consumer object and the message topic after responding to the message subscription change request.

[0064] It should be noted that the target consumer object refers to the consumer object currently undergoing message topic change. This consumer object consumes messages under the specified message topic, such as an alarm message processing device or account, a public account followed, 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 message category, such as alarm message category, news category, multimedia category, etc. Furthermore, a subscription change request can be at least one of a message topic subscription request and a subscription cancellation request. A message topic subscription request is a request from the target consumer object to subscribe to the target message topic, while a subscription cancellation request is a request from the target consumer object to unsubscribe from the target message topic. The first correspondence is the correspondence between the consumer object and the message topic when the subscription change request is received; and in the first correspondence, one message object corresponds to one message topic, indicating that one message object subscribes to messages under one message topic.

[0065] In this embodiment of the 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 a correspondence information between the target message object and the target message topic.

[0066] See Figure 6 , Figure 6 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 2 ;like Figure 6 As shown, step 101 can be implemented through step 1011A. That is, in response to the target consumer's subscription change request for the target message topic, the information processing device updates the first correspondence based on the target consumer and the target message topic to obtain the second correspondence, including step 1011A, which will be explained below.

[0067] Step 1011A: When the subscription change request is a message topic subscription request, in response to the target consumer object's message topic subscription request for the target message topic, the target consumer object and the target message topic are stored in the first correspondence relationship to obtain the second correspondence 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 does not include the correspondence information between the target consumer and the target message topic. The correspondence information between the target consumer and the target message topic will be added to the first correspondence. Thus, the message processing device stores the target consumer and the target message topic in the first correspondence, and the first correspondence that stores the correspondence information between the target consumer and the target message topic is the second correspondence.

[0069] See Figure 7 , Figure 7 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 3 ;like Figure 7 As shown, step 101 can be implemented through step 1011B. That is, in response to the target consumer's subscription change request for the target message topic, the information processing device updates the first correspondence based on the target consumer and the target message topic to obtain the second correspondence, including step 1011B, which will be explained below.

[0070] Step 1011B: In the case that the subscription change request is a subscription cancellation request, in response to the target consumer's subscription cancellation request for the target message topic, delete the target consumer and the target message topic from the first correspondence to obtain the second correspondence.

[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 correspondence includes 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 needs to be deleted from the first correspondence. Therefore, the message processing device searches for the corresponding information of the target consumer object and the target message topic in the first correspondence, and deletes the found corresponding information of the target consumer object and the target message topic from the first correspondence. The first correspondence after deleting the corresponding information of the target consumer object and the target message topic is the second correspondence.

[0072] Step 102: If the first message topic set in the second correspondence is different from the second message topic set in the third correspondence, determine the target listening object corresponding to the target message topic.

[0073] In this embodiment, since the second correspondence represents the correspondence between the consumer object and the message topic after responding to the message subscription change request, the message processing device obtains all message topics in the second correspondence and determines the all message topics obtained from the second correspondence as the first message topic set. Additionally, the information processing device also includes a third correspondence, or the information processing device can obtain a third correspondence from other devices (e.g., storage devices such as databases). This third correspondence represents the correspondence between the message topic and the listening object. The message processing device then obtains all message topics in the third correspondence and determines the all message topics obtained from the third correspondence as the second message topic set. Here, since the first message topic set is the set of the latest message topics to be listened to, and the second message topic set is the set of message topics to be listened to before responding to the subscription change request, the difference between the first and second message topic sets indicates the existence of a message topic subject to subscription change, and this message topic subject to subscription change is the target message topic. Next, the message processing device determines the target listening object corresponding to the target message topic, and combines the target message topic and the target listening object to perform message topic listening changes. The target listening object is used to listen to messages of the target message topic.

[0074] It should be noted that the listener object is used to listen to the messages corresponding to the message topic, and the third correspondence is the correspondence between the listener object and the message topic when a subscription change request is received; and in the third correspondence, one listener object corresponds to one message topic, meaning that one listener object listens to the messages of one message topic.

[0075] See also Figure 6 Step 102 can be implemented through steps 1021A and 1022A; that is, when the first message topic set in the second correspondence relationship is different from the second message topic set in the third correspondence relationship, the message processing device determines the target listening object corresponding to the target message topic, including steps 1021A and 1022A. Each step is explained below.

[0076] Step 1021A: If the set of first message topics in the second correspondence is greater than the set of second message topics in the third correspondence, the target message topics that are more numerous in the set of first message topics than in the set of second message topics shall be identified as 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, it means that the first message topic set is larger than the second message topic set. This indicates that there is a new message topic to be monitored, and the new message topic to be monitored is the message topic that is larger than the second message topic set in the first message topic set. The additional message topic is the target message topic. Therefore, 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 listener 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 listened to, there is no corresponding listening object for the target message topic. Therefore, the message processing device creates a listening object for the message topic to be added, and thus obtains the target listening object.

[0080] In this embodiment of the application, before creating a new target listening object for a message topic to be added, the message processing device determines the number of message topics for which a new listening object is to be created; if there are multiple message topics, the device selects the message topic with the highest priority from the multiple message topics for which a new listening object is to be created; and if there is only one message topic, the device creates a new target listening object for the message topic to be added.

[0081] It should be noted that when multiple message topics are obtained by dividing the message topics, since different message topics correspond to different categories, the message processing priorities of different categories can be different. Therefore, different priorities can be set for multiple message topics. This allows for the creation of new listener objects for the highest priority message topic when multiple message topics are waiting to have listener objects created. This improves the listening and consumption speed of the highest priority message topic, enhancing the timeliness of message processing. Furthermore, when it is determined that a target listener object is to be created for a message topic to be added, if it is determined that there is a message topic with a higher priority waiting to have a listener object created, a timer starts. If it is determined that the message topic to be added has the highest priority before the timer ends, a target listener object is created for that message topic. If it is determined that there is still a message topic with a higher priority than the message topic to be added when the timer ends, a target listener object is created for that message topic. In this way, the creation of listener objects for the highest priority message topic is prioritized, while ensuring that the waiting time for lower priority message topics remains within a specified range, achieving a balance between priority and efficiency in the listener object creation process.

[0082] See also Figure 7Step 102 can be implemented through steps 1021B and 1022B; that is, when the first message topic set in the second correspondence is different from the second message topic set in the third correspondence, the target listening object corresponding to the target message topic is determined, including steps 1021B and 1022B. Each step is explained below.

[0083] Step 1021B: If the set of first message topics in the second correspondence is less than the set of second message topics in the third correspondence, the target message topics that are less than the set of second message topics in the first correspondence shall be identified as 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 if the first message topic set is less than the second message topic set, it indicates that there are message topics that do not need to be monitored. The message topics that do not need to be monitored are those that are fewer in the first message topic set than the second message topic set, and these fewer message topics are the target message topics. Therefore, the message processing device determines that the target message topic is the message topic to be unmonitored, and thus determines that the target message topic is the message topic to be deleted.

[0085] Step 1022B: From the third correspondence, determine the target listening object corresponding to the message topic to be deleted.

[0086] It should be noted that since the target message topic is the message topic to be canceled from listening, there is a corresponding listening object for the target message topic; here, the listening object used to listen to messages of the target message topic is called the target listening object; thus, the correspondence information between the target message topic and the target listening object is stored in the third correspondence relationship; then, the message processing device can find the correspondence information between the target message topic and the target listening object from the third correspondence relationship, and delete the found correspondence information between the target message topic and the target listening object from the third correspondence relationship.

[0087] Step 103: Update the third correspondence based on the target message topic and the target listening object to obtain the fourth correspondence.

[0088] In this embodiment of the application, since the target message topic is the message topic to be monitored 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 a message topic to be monitored; here, the message processing device refers to the updated third correspondence as the fourth correspondence, and 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 the fourth correspondence differs from the third correspondence in that it lacks the corresponding information for the target message topic and the target listening object. Specifically, when the subscription change request is changed to a message topic subscription request, the fourth correspondence has one more corresponding information for the target message topic and the target listening object than the third correspondence. However, when the subscription change request is changed to a subscription cancellation request, the third correspondence has one more corresponding information for the target message topic and the target listening object than the fourth correspondence.

[0090] In the embodiments of this application, see also Figure 6 Step 103 can be achieved through step 1031A; that is, the message processing device updates the third correspondence based on the target message topic and the target listening object to obtain the fourth correspondence, including step 1031A, which will be explained below.

[0091] Step 1031A: If the target message topic is a message topic to be added, store the target message topic and the target listening object in the third correspondence relationship to obtain the fourth correspondence relationship.

[0092] It should be noted that when the target message topic is a message topic to be added, the message processing device stores the target message topic and the target listening object in the third correspondence, so as to listen to the target message topic based on the target listening object. The third correspondence, which stores the correspondence information between the target message topic and the target listening object, is the fourth correspondence. In this case, the fourth correspondence has one more correspondence between the target message topic and the target listening object than the third correspondence.

[0093] In the embodiments of this application, see also Figure 7 Step 103 can be implemented through step 1031B; that is, the message processing device updates the third correspondence based on the target message topic and the target listening object to obtain the fourth correspondence, including step 1031B, which will be explained below.

[0094] Step 1031B: If the target listening object is a listening object to be deleted, delete the target message topic and the target listening object from the third correspondence to obtain the fourth correspondence.

[0095] It should be noted that when the target message topic is a message topic to be deleted, the message processing device searches for the listening object corresponding to the message topic that matches the target message topic in the third correspondence. It is easy to see that the listening object corresponding to the message topic that matches the target message topic is the target listening object. Therefore, deleting the target message topic and the listening object corresponding to the message topic that matches the target message topic from the third correspondence also means deleting both the target message topic and the target listening object from the third correspondence. The third correspondence after deleting the corresponding information of the target message topic and the target listening object becomes the fourth correspondence. At this point, the fourth correspondence has one less corresponding piece of information—the target message topic and the target listening object—than the third correspondence.

[0096] Understandably, when the message topic monitoring is changed to the addition of a new message topic to be monitored (referred to as the target message topic), updating the correspondence between the current message topic and the monitoring object through the new message topic to be monitored allows for obtaining the latest correspondence between the message topic and the monitoring object. This enables rapid updating of the correspondence between the message topic and the monitoring object, providing real-time data for message topic monitoring.

[0097] In step 1031B of this embodiment, when the target listening object is a listening object to be deleted, the message processing device deletes the target message topic and the target listening object from the third correspondence to obtain a fourth correspondence. This includes: when the target listening object is a listening object to be deleted, the message processing device starts timing; when the timing duration reaches a specified duration, the target message topic and the target listening object are deleted from the third correspondence. However, before the timing duration reaches the specified duration, if in response to a next subscription change request it is determined that the next message topic to be added is the target message topic, the timing ends, and the deletion of the target message topic and the target listening object is cancelled.

[0098] It should be noted that the message processing device can use a delayed deletion method to delete the target message topic and the target listener object. That is, when the message processing device determines that the target message topic and the target listener object should be deleted from the third correspondence, it will delete the target message topic and the target listener object only after a specified time period. This way, if the message topic to be added is determined to be the target message topic within the time period corresponding to the time when the deletion is determined and the time period after the specified time period, the target message topic and the target listener object can be obtained by canceling the deletion of the target message topic and the target listener object. This simplifies the steps of deleting the target listener object and recreating the target listener object, thereby reducing the resource consumption of message processing and improving the efficiency of message processing.

[0099] Step 104: Listen for messages based on the fourth correspondence, and consume messages by combining the message listening results with the second correspondence.

[0100] In this embodiment, once the message processing device obtains the second and fourth correspondences, it has completed the message topic change processing. At this point, message consumption can be performed by combining the second and fourth correspondences. Here, the message processing device listens to the message topic based on the listening object in the fourth correspondence and sends the message obtained through message listening to the consumption object corresponding to the message topic to achieve message consumption. The message listening result refers to the message obtained through message listening, which is the message of the listened-to message topic.

[0101] In this embodiment, the message topic is an alarm message topic, such as an emergency alarm, a normal alarm, etc. At this time, the message processing device listens to messages based on the fourth correspondence relationship and consumes messages by combining the message listening results with the second correspondence relationship. This includes: the message processing device listens to alarm message topics of the corresponding type through each listening object in the fourth correspondence relationship; and when an alarm message of an alarm message topic is detected, the device determines the consumption object corresponding to the alarm message topic based on the second correspondence relationship, and identifies the consumption object corresponding to the determined alarm message topic as the alarm message consumption object; wherein, the alarm message consumption object is used to consume the alarm messages of the detected alarm message topic.

[0102] It is understood that the message processing method provided in this application embodiment can be applied to alarm message distribution scenarios; by responding to subscription change requests, when it is determined that there is a change in the listening of alarm message topics, the first correspondence is updated to obtain the second correspondence, and the third correspondence is updated to obtain the fourth correspondence, so as to obtain the latest correspondence between alarm message topics and alarm message consumer objects, and the latest correspondence between alarm message topics and alarm message listening objects, so as to quickly realize the listening change of alarm message topics; thereby improving message processing efficiency.

[0103] It is also understandable that by storing the first correspondence between consumer objects and message topics, and the third correspondence between message topics and listening objects, when a subscription change request for a target message topic is received from a target consumer object, the first correspondence is updated, and the message topics in the updated second correspondence are compared with those in the third correspondence to determine whether a message topic change has occurred. Furthermore, when a message topic change is confirmed, the third correspondence is updated based on the target listening object corresponding to the target message topic to obtain a fourth correspondence. Thus, in cases where a change in the message topic by a consumer object causes a change in the message topic being listened to, the correspondence between consumer objects and message topics, as well as between message topics and listening objects, can be rapidly and dynamically changed. This allows for listening to messages with different topics through the fourth correspondence, and for consuming messages from different message consumers through the second correspondence. Therefore, message processing efficiency can be improved.

[0104] In this embodiment of the application, after the message processing device responds to the target consumer's subscription change request for the target message topic in step 101, updates the first correspondence based on the target consumer and the target message topic to obtain the second correspondence, the message processing method further includes: if 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, the message processing process ends.

[0105] It should be noted that when responding to a subscription change request, the types of message topics in the first correspondence and the second correspondence can be the same or different. If the types of message topics in the first correspondence and the second correspondence are the same, that is, the first message topic set and the second message topic set are the same. In this case, there is no change in the message topic, the message listening process remains unchanged, the message forwarding process changes, and thus the message processing process for message listening change ends.

[0106] Understandably, if the target message topic involved in the subscription change request already exists in the third correspondence, the message processing device ends the update of the third correspondence, listens for messages based on the third correspondence, and consumes messages based on the second correspondence; in this way, the resource consumption of message processing can be reduced.

[0107] In the embodiments of this application, see Figure 8 , Figure 8 This is a flowchart illustrating the message processing method provided in the embodiments of this application. Figure 4 In this process, the execution entity for each step is the message processing device; for example... Figure 8As shown, steps 105 to 107 are included before step 101; that is, before the message processing device updates the first correspondence based on the target consumer object and the target message topic to obtain the second correspondence in response to the target consumer object's subscription change request for the target message topic, the message processing method further includes steps 105 to 107. Each step is explained below.

[0108] Step 105: In response to the message service start request, listen to the blocking queue.

[0109] In this embodiment of the application, when message listening 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 listening to the message topic change task of the consumer object through the listening blocking queue.

[0110] It should be noted that the message service startup request is used to start the message service, which includes message listening and message consumption. The blocking queue is used to store real-time message topic subscription change tasks.

[0111] Step 106: In response to the subscription change operation for the subscription change interface, generate a subscription change task.

[0112] It should be noted that the message processing device provides a subscription change interface to external consumers. This subscription change interface is used by consumers to make subscription changes to message topics (e.g., subscribe, unsubscribe). Therefore, when the target consumer makes a subscription change to the target message topic through the subscription change interface, the message processing device receives the subscription change operation for the subscription change interface. At this time, the message processing device responds to the subscription change operation by generating a subscription change task for the target consumer to make a subscription change to the target message topic.

[0113] Step 107: Upon detecting an operation to store subscription change tasks in the blocking queue, generate a subscription change request.

[0114] In this embodiment of the application, the message processing device stores the subscription change task in the 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 detected. Then, in response to the operation, a subscription change request for the target message topic of the target consumer object is generated, and the first correspondence and the third correspondence are dynamically updated based on the subscription change request.

[0115] In this embodiment of the application, a subscription change request can also be generated through a thread wake-up mechanism.

[0116] Understandably, the listening mechanism allows for real-time monitoring of subscription change requests, enabling dynamic and real-time monitoring of message topics and improving the efficiency of message topic change monitoring. Furthermore, storing subscription change tasks in a blocking queue ensures that subsequent processing only occurs when a subscription change task is detected in the queue; otherwise, monitoring continues, reducing the resource consumption associated with monitoring message topic changes.

[0117] In this embodiment of the application, the message processing method further includes: the message processing device responding to the message service start request to obtain a set of default message topics; traversing the set of default message topics and performing the following processing for each traversed default message topic: constructing a corresponding default listening object for the default message topic, and storing the default message topic and the default listening object accordingly; after traversing the set of default message topics, obtaining a third correspondence based on each stored default message topic and each default listening object.

[0118] It should be noted that when responding to a message service startup request, the message processing device also initializes message topic listening; that is, the message processing device creates corresponding listener objects for the default message topics to enable listening to those topics. The default message topic set includes at least one default message topic, and each default message topic is the default listening topic. The message processing device creates a listener object for each default message topic, and this listener object is called the default listener object. Furthermore, the default message topic can be a message topic whose listening priority is determined by a priority threshold.

[0119] Understandably, when starting the message service in response to a message service startup request, initializing the listener for the default message topic can improve the response efficiency of subscription change requests.

[0120] The following describes an exemplary application of the embodiments of this application in a real-world application scenario. This exemplary application describes the process of listening to and consuming alarm messages.

[0121] See Figure 9 , Figure 9 This is an exemplary message processing architecture diagram provided in the embodiments of this application; as shown below. Figure 9As shown, three alarm message topics 9-11 to 9-13 are illustrated, where alarm message topic 9-11 originates from alarm message source 9-21, alarm message topic 9-12 originates from alarm message source 9-22, and alarm message topic 9-13 originates from alarm message source 9-23. In the message center 9-3 (referred to as the message processing device), consumer object 9-311 (referred to as the listening object) listens for alarm messages in alarm message topic 9-11, consumer object 9-312 (referred to as the listening object) listens for alarm messages in alarm message topic 9-12, and consumer object 9-313 (referred to as the listening object) listens for alarm messages in alarm message topic 9-13. Furthermore, the addition and deletion of consumer objects are achieved by listening to subscription or cancellation tasks (referred to as subscription change tasks) in the blocking queue 9-32. The message center 9-3 also includes an external interface 9-33, which is used to add subscription tasks or cancellation tasks to the blocking queue 9-32 in response to subscription requests (called message topic subscription requests) or cancellation requests (called subscription cancellation requests) from external systems 9-4 (called consumer objects) for alarm consumption topics.

[0122] It should be noted that the message center includes a user-topic information table (User_Topic_Info table, referred to as the first correspondence), which records the correspondence between alarm message topics subscribed to by external systems and their interface addresses. The message center also includes a startup class (ApplicationRunner). After the service starts, the run method (run()) of the startup class ApplicationRunner is called to initialize the default alarm message topics. The initialization of the default alarm message topics refers to iterating through the initialization listener list (called the default message topic set). The initialization listener list consists of a list of at least one default alarm message topic. For each default alarm message topic encountered, a consumer object (called the default listener object) is created through the Kafka interface to listen to the default alarm message topic and complete the consumption and processing of the listened messages. At the same time, each default alarm message topic and the created consumer object are stored in a cache Map. Here, the startup class uses a while loop to perform cyclical processing of changes. The while loop includes a blocking queue for adding change tasks based on received change messages for external system alarm message topics. Upon receiving a change message, the User_Topic_Info table is updated based on the alarm message topic and interface address in the change message. The updated User_Topic_Info table (referred to as the second correspondence) is compared with the latest alarm message topic subscription list (referred to as the first message topic set) in the updated table (referred to as the second correspondence) and the alarm message topic subscription list in the cache Map (referred to as the second message topic set). Based on the comparison result, if a new Topic to be monitored is determined... c) A consumer object is created through the Kafka interface, specifying that the created consumer object listens to the newly added topic, and completes the consumption, processing, and persistence of messages for the new topic. At the same time, the cache map (called the third correspondence) is updated, reducing the impact on business logic such as listening and consuming other topics. Based on the comparison results, if a topic to be deleted is determined, the topic to be deleted is deleted through the Kafka interface to cancel listening to that topic. At the same time, the cache map is updated, reducing the impact on business logic such as listening and consuming other topics. Finally, the listened messages are pushed to the external system through the interface address provided when subscribing to the external system.

[0123] based on Figure 9 See Figure 10 , Figure 10 This is an exemplary message processing flowchart provided in an embodiment of this application; as shown... Figure 10As shown, the message center includes a user-topic information table 10-1. Furthermore, the creation of consumer objects, topic listening, and message processing are encapsulated in the AddConsumerService utility class 10-3, and the logic for canceling consumer object listening is encapsulated in the DeletionConsumerService utility class 10-5. It is easy to see that when the message center initializes a message topic, it creates a consumer object for each topic using the AddConsumerService utility class to achieve asynchronous message consumption for that topic. That is, there is a one-to-one relationship between topics and consumer objects, and each listened topic and its corresponding consumer object are stored in a cache. Additionally, the startup class 10-2 uses a While loop to monitor the blocking queue for pending change tasks. Therefore, this exemplary message processing flow includes steps 1001 to 1005, which are described below.

[0124] Step 1001: Receive a subscription request or unsubscribe request.

[0125] Here, the message center updates the user-topic information table 10-1 based on the received subscription or unsubscription requests from external systems (9-4).

[0126] It should be noted that message center 9-3 includes a subscription interface. External system 9-4 uses this subscription interface to perform Topic subscription or unsubscription operations. Thus, message center 9-3 can receive subscription or unsubscription requests from 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 the blocking queue. During the While loop, if a subscription task is detected in the queue, the user-topic information table 10-1 is queried to find the list of topics subscribed to by the external system, and compared with the cached list of currently monitored topics. Therefore, during service startup, startup class 10-2 responds to subscription or unsubscription requests by querying the user-topic information table 10-1 for the latest alarm message topic subscription information.

[0129] Step 1003: Change the listening topic of the alarm message.

[0130] It should be noted that if the latest alarm message topic subscription information retrieved is different from the latest alarm message topic listening information in the cache, the alarm message topic listening will be changed.

[0131] Step 1004: Add a new alarm message topic.

[0132] It should be noted that if the list of topics subscribed to by external systems in the user-topic information table 10-1 is more than the list of topics currently being listened to in the cache, the monitoring of the alarm message topic change is determined to be the new alarm message topic. At this time, the new consumer object service 10-3 is called to create a consumer object to listen to the message source 10-4 of the new alarm message topic and push the message to the external system 9-4. At the same time, the cache is updated based on the new alarm message topic and the created consumer object.

[0133] Step 1005: Delete the alarm message topic.

[0134] It should be noted that if the list of topics subscribed to by external systems in the user-topic information table 10-1 is less than the list of topics currently being listened to in the cache, the monitoring of changing the alarm message topic is determined to be the deletion of the alarm message topic. At this time, the consumer object deletion service 10-5 is called to delete the consumer object corresponding to the alarm message topic, so as to cancel the listening to messages and message pushes for the deleted alarm message topic. At the same time, the cache is updated based on the deleted alarm message topic and the deleted consumer object.

[0135] For example, internal system service A (referred to as message source) generates alarm message type A, and service B generates alarm message type B. According to the message classification rules, alarm message type A corresponds to Topic A, and alarm message type B corresponds to Topic B. If external system A pulls alarm message type A at this time, it subscribes to Topic A from the message center. If external system B pulls alarm message type A at this time, it subscribes to Topic B from the message center. No service configuration needs to be modified or restarted. And it has no impact on the message consumption of external system A. Furthermore, if external system B cancels its subscription to Topic B at this time, it simply cancels its listening to Topic B. It has no impact on the message consumption of external system A.

[0136] Understandably, Kafka's interfaces are used to create and delete consumer objects, enabling the listening and unlistening of topics. Combined with blocking queues and subscription information from external systems, the cached list of topics to be listened to is dynamically updated. This ensures that message processing for each topic is handled asynchronously by an independent consumer object, without affecting the listening and consumption logic of other topics. Furthermore, based on subscription change information and cyclical listening (While loop + blocking queue, or thread wake-up mechanism), Kafka's interfaces allow for the dynamic addition and deletion of consumer objects, thereby achieving dynamic listening and message processing of topics. This improves message processing performance and reduces the storage space occupied by message persistence.

[0137] The following description continues to illustrate the exemplary structure of the message processing device 455 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 4 As shown, the software modules stored in the message processing device 455 of the memory 450 may include:

[0138] The relationship update module 4551 is used to respond to the subscription change request of the target consumer object to the target message topic, update the first correspondence relationship based on the target consumer object and the target message topic to obtain the second correspondence relationship, wherein the first correspondence relationship represents the correspondence relationship between the consumer object and the message topic;

[0139] The change determination module 4552 is used to determine the target listening object corresponding to the target message topic when the first message topic set in the second correspondence relationship is different from the second message topic set in the third correspondence relationship, wherein the third correspondence relationship represents the correspondence between the message topic and the listening object;

[0140] The relationship update module 4551 is further configured to update the third correspondence relationship based on the target message topic and the target listening object to obtain a fourth correspondence relationship;

[0141] The message processing module 4553 is used to listen to messages based on the fourth correspondence and to consume messages by combining the message listening results with the second correspondence.

[0142] In this embodiment of the 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 the request of the target consumer to subscribe to the target message topic, and the subscription cancellation request refers to the request of the target consumer to unsubscribe from the target message topic.

[0143] In this embodiment of the application, the relationship update module 4551 is further configured to, when the subscription change request is a message topic subscription request, store the target consumer object and the target message topic in the first correspondence relationship to obtain the second correspondence relationship; and when the subscription change request is a subscription cancellation request, delete the target consumer object and the target message topic from the first correspondence relationship to obtain the second correspondence relationship.

[0144] In this embodiment of the application, the change determination module 4552 is further configured to: when the first message topic set in the second correspondence relationship is greater than the second message topic set in the third correspondence relationship, determine the target message topic that is greater than the second message topic set in the first message topic set as a message topic to be added, and create a new target listening object for the message topic to be added; when the first message topic set in the second correspondence relationship is less than the second message topic set in the third correspondence relationship, determine the target message topic that is less than the second message topic set in the first message topic set as a message topic to be deleted, and determine the target listening object corresponding to the message topic to be deleted from the third correspondence relationship.

[0145] In this embodiment of the application, the relationship update module 4551 is further configured to, when the target message topic is a message topic to be added, store the target message topic and the target listening object in the third correspondence relationship to obtain the fourth correspondence relationship; and when the target listening object is a listening object to be deleted, delete the target message topic and the target listening object from the third correspondence relationship to obtain the fourth correspondence relationship.

[0146] In this embodiment of the application, the change determination module 4552 is further configured to determine that there is no message topic change when the first message topic set is the same as the second message topic set; and to end the message processing flow when it is determined that there is no message topic change.

[0147] In this embodiment of the application, the message processing device 455 further includes a request generation module 4554, which is used to listen to the blocking queue in response to a message service start request; generate a subscription change task in response to a subscription change operation for the subscription change interface; and generate the subscription change request when an operation to store the subscription change task in the blocking queue is detected.

[0148] In this embodiment of the application, the message processing device 455 further includes an initial configuration module 4555, which is used to respond to the message service startup request, obtain a set of default message topics; traverse the set of default message topics, and perform the following processing for each default message topic traversed: construct a corresponding default listening object for the default message topic; store the default message topic and the default listening object in correspondence; and, after traversing the set of default message topics, obtain the third correspondence relationship based on the corresponding stored default message topics and default listening objects.

[0149] In this embodiment of the application, the message topic is an alarm message topic; the message processing module 4553 is further configured to listen to the alarm message topic of the corresponding type through each of the listening objects in the fourth correspondence relationship; when an alarm message of the alarm message topic is listened to, based on the second correspondence relationship, the consumer object corresponding to the alarm message topic is determined, and the consumer object corresponding to the determined alarm message topic is determined as an alarm message consumer object, which is used to consume the alarm message of the alarm message topic that has been listened to.

[0150] This application provides computer software, which includes computer-executable instructions or a computer program stored in a computer-readable storage medium. A processor of a message processing device reads the computer-executable instructions or computer program from the computer-readable storage medium and executes the computer-executable instructions or computer program, causing the message processing device to perform the message processing method described in this application.

[0151] This 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 processor will execute the message processing method provided in this 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 it may be a variety of devices including one or any combination of the above-mentioned memories.

[0153] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, 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 stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.

[0154] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).

[0155] As an example, computer-executable instructions can be deployed to execute on a single electronic device (in which case, this single electronic device is a message processing device), or to execute on multiple electronic devices located in one location (in which case, the multiple electronic devices located in one location are message processing devices), or to execute on multiple electronic devices distributed across multiple locations and interconnected via a communication network (in which case, the multiple electronic devices distributed across multiple locations and interconnected via a communication network are message processing devices).

[0156] It is understood that, in the embodiments of this application, data related to subscription operations, unsubscription operations, and messages requires user permission or consent when applied to specific products or technologies. Furthermore, the collection, use, and processing of such data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. Additionally, regarding the message monitoring technology solutions involved in this application, when applied to specific products or technologies, the collection, use, and processing of related messages should comply with national laws and regulations, adhere to the principles of legality, legitimacy, and necessity, and should not involve obtaining data types prohibited or restricted by laws and regulations, nor hinder the normal operation of the target website.

[0157] In summary, this application embodiment stores a first correspondence between consumer objects and message topics, and a third correspondence between message topics and listening objects. This allows for the determination of whether a message topic change exists when a target consumer object receives a subscription change request for a target message topic. The first correspondence is updated, and the message topics in the updated second correspondence are compared with those in the third correspondence. Upon determining that a message topic change exists, the third correspondence is updated based on the target listening object corresponding to the target message topic to obtain a fourth correspondence. Therefore, in cases where a change in message topic by the consumer object causes a change in message topic listening, rapid and dynamic changes to the correspondence between consumer objects and message topics, and between message topics and listening objects, are possible. The fourth correspondence enables listening to messages with different message topics, and the second correspondence enables message consumption by different message consumers. This improves message processing efficiency and reduces space resource consumption.

[0158] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

Claims

1. A message processing method, characterized in that, The method includes: In response to a subscription change request from a target consumer to a target message topic, the first correspondence is updated based on the target consumer and the target message topic to obtain a second correspondence, wherein the first correspondence represents the correspondence between the consumer and the message topic; If the first message topic set in the second correspondence relationship is different from the second message topic set in the third correspondence relationship, the target listening object corresponding to the target message topic is determined, and the third correspondence relationship represents the correspondence between message topics and listening objects; If the target message topic is a message topic to be added, the target message topic and the target listening object are stored in the third correspondence relationship to obtain the fourth correspondence relationship; If the target listening object is a listening object to be deleted, the target message topic and the target listening object are deleted from the third correspondence to obtain the fourth correspondence. Message listening is performed based on the fourth correspondence, and message consumption is performed by combining the message listening results with the second correspondence.

2. The method according to claim 1, characterized in that, The step of updating the first correspondence based on the target consumer object and the target message topic to obtain the second correspondence includes: When the subscription change request is a message topic subscription request, the target consumer object and the target message topic are stored in the first correspondence to obtain the second correspondence. If the subscription change request is a subscription cancellation request, the target consumer object and the target message topic are deleted from the first correspondence to obtain the second correspondence.

3. The method according to claim 1, characterized in that, When the first message topic set in the second correspondence is different from the second message topic set in the third correspondence, determining the target listening object corresponding to the target message topic includes: If the first message topic set in the second correspondence is greater than the second message topic set in the third correspondence, the target message topic that is greater than the second message topic set in the first correspondence is determined as a message topic to be added, and a new target listening object is created for the message topic to be added. If the first message topic set in the second correspondence is less than the second message topic set in the third correspondence, the target message topic whose first message topic set is less than the second message topic set is determined as a message topic to be deleted, and the target monitoring object corresponding to the message topic to be deleted is determined from the third correspondence.

4. The method according to any one of claims 1 to 3, characterized in that, Before updating the first correspondence based on the target consumer and the target message topic to obtain the second correspondence in response to the subscription change request of the target consumer for the target message topic, the method further includes: In response to a message service start request, listen to the blocking queue; In response to a subscription change operation on the subscription change interface, a subscription change task is generated; Upon detecting an operation to store the subscription change task in the blocking queue, the subscription change request is generated.

5. The method according to claim 4, characterized in that, The method further includes: In response to the message service startup request, obtain the default message topic set; Iterate through the set of default message topics, and perform the following processing for each default message topic encountered: construct a corresponding default listener object for the default message topic; store the default message topic and the default listener object accordingly; After traversing the set of default message topics, the third correspondence is obtained based on the corresponding stored default message topics and default listening objects.

6. A message processing device, characterized in that, The message processing device includes: The relationship update module is used to respond to the subscription change request of the target consumer object to the target message topic, update the first correspondence relationship based on the target consumer object and the target message topic to obtain the second correspondence relationship, wherein the first correspondence relationship represents the correspondence relationship between the consumer object and the message topic; The change determination module is used to determine the target listening object corresponding to the target message topic when the first message topic set in the second correspondence relationship is different from the second message topic set in the third correspondence relationship, wherein the third correspondence relationship represents the correspondence between the message topic and the listening object; The relationship update module is further configured to, when the target message topic is a message topic to be added, store the target message topic and the target listening object in the third correspondence relationship to obtain a fourth correspondence relationship; and when the target listening object is a listening object to be deleted, delete the target message topic and the target listening object from the third correspondence relationship to obtain a fourth correspondence relationship. The message processing module is used to listen for messages based on the fourth correspondence and to consume messages by combining the message listening results with the second correspondence.

7. An electronic device for message processing, characterized in that, The electronic device includes: Memory is used to store executable instructions or computer programs. A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the message processing method according to any one of claims 1 to 5.

8. 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 5 is implemented.

9. A computer program product, 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 5 is implemented.

Citation Information

Patent Citations

  • Event management system and method

    CN115550439A