Message service processing method, apparatus, device, and storage medium
By performing type-linked list sorting and polling operations on subscribed events in RPC calls, the problem of excessive server load was solved, and efficient event processing and information transmission were achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-22
- Publication Date
- 2026-03-17
AI Technical Summary
Existing RPC call technology can cause excessive server load when processing large amounts of data, resulting in low efficiency and potential loss of call information.
Upon receiving a subscription event, the corresponding subscription event method is retrieved and added to the event type linked list for sorting. Events are then added to the event queue according to their priority and sent via polling.
By prioritizing and polling, the efficiency of event processing is improved, ensuring that high-priority events are processed in a timely manner, reducing server load, and preventing information loss.
Smart Images

Figure CN115437804B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a message service processing method, apparatus, device, and storage medium. Background Technology
[0002] Currently, with the development of network technology, there are more and more types of network applications. In network applications, clients typically use the Remote Procedure Call (RPC) protocol to request services from remote servers.
[0003] However, in existing RPC call technologies, the server begins processing immediately upon receiving the information. When processing large amounts of data, the server's processing capacity is limited, and since RPC is blocking, the caller must block and wait for the result when remotely calling the service. This increases the server load, reduces system capacity, and may also cause the loss of call information.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this invention is to provide a message service processing method, apparatus, device, and storage medium, aiming to solve the technical problem in the prior art where servers process all data immediately when a large amount of data needs to be processed, resulting in low efficiency.
[0006] To achieve the above objectives, the present invention provides a message service processing method, the method comprising the following steps:
[0007] Upon receiving a subscription event, obtain the subscription event method corresponding to the subscription event;
[0008] The event types that the subscription event method can receive are added to the event type list, and the event type list is sorted according to the priority of the event types;
[0009] Based on the sorting results, the events that need to be sent are added to the corresponding event queues, and the events in the event queues are sent through a polling operation.
[0010] Optionally, the step of obtaining the subscription event method corresponding to the subscription event upon receiving a subscription event includes:
[0011] Upon receiving a subscription event, the system checks the cache to see if a corresponding subscription event method exists based on the subscription event.
[0012] If so, obtain the corresponding subscription event method based on the subscription event.
[0013] Optionally, after the step of checking in the cache whether a corresponding subscription event method exists when a subscription event is received, the method further includes:
[0014] If not, obtain the corresponding indexing method identifier based on the subscribed event;
[0015] The corresponding subscription event method is selected from the index class according to the indexing method identifier;
[0016] Accordingly, before the step of obtaining the corresponding index method identifier based on the subscription event (if not), the method further includes:
[0017] Generate a corresponding index identifier based on the subscription event method, and save the index identifier and the corresponding subscription event method to the index class.
[0018] Optionally, the step of adding the events to be sent to the corresponding event queue according to the sorting result, and sending the events in the event queue through a polling operation, includes:
[0019] Based on the sorting results, the events that need to be sent are added to the event queue.
[0020] Retrieve the corresponding subscriber from the event type linked list based on the event type;
[0021] The events in the event queue are sent to the subscribers through a polling operation.
[0022] Optionally, after the step of adding the events to be sent to the event queue according to the sorting result, the method further includes:
[0023] Get the current thread type of the event queue;
[0024] Accordingly, after the step of sending events in the event queue to the subscriber via polling, the method further includes:
[0025] The thread pattern is obtained according to the event subscription method, and the thread pattern is sent to the subscriber according to the current thread type, so that the subscriber can process the event according to the thread pattern after receiving the event.
[0026] Optionally, before the step of adding the events to be sent to the event queue according to the sorting result, the method further includes:
[0027] Determine whether the subscribed event is a sticky event based on the event type;
[0028] If so, the event type and the event subscription method are saved to the sticky event collection;
[0029] Accordingly, the step of obtaining the subscription event method corresponding to the subscription event upon receiving a subscription event includes:
[0030] Upon receiving a subscription event, determine whether it is a sticky event based on the event type of the subscription event;
[0031] If so, then obtain the corresponding subscription event method from the sticky event set according to the subscription event.
[0032] Optionally, after the steps of adding the event types that the subscription event method can receive to the event type list and sorting the event type list according to the priority of the event types, the method further includes:
[0033] Add the subscriber corresponding to the subscribed event and the event type to the subscriber list;
[0034] Accordingly, after the step of adding the events to be sent to the corresponding event queue according to the sorting result, and sending the events in the event queue through a polling operation, the method further includes:
[0035] When receiving a pending unsubscribe event, the corresponding event type in the event type chain is deleted based on the pending unsubscribe event.
[0036] Furthermore, to achieve the above objectives, the present invention also proposes a message service processing apparatus, the apparatus comprising:
[0037] The method acquisition module is used to acquire the subscription event method corresponding to the subscription event when a subscription event is received;
[0038] The linked list sorting module is used to add the event types that the subscription event method can receive to the event type linked list, and sort the event type linked list according to the priority of the event types;
[0039] The event sending module is used to add the events that need to be sent to the corresponding event queue according to the sorting result, and send the events in the event queue through a polling operation.
[0040] Furthermore, to achieve the above objectives, the present invention also proposes a message service processing device, the device comprising: a memory, a processor, and a message service processing program stored in the memory and executable on the processor, the message service processing program being configured to implement the steps of the message service processing method as described above.
[0041] Furthermore, to achieve the above objectives, the present invention also proposes a storage medium storing a message service processing program, which, when executed by a processor, implements the steps of the message service processing method described above.
[0042] This invention involves obtaining the subscription event method corresponding to the received subscription event; adding the event types that the subscription event method can receive to an event type linked list, and sorting the event type linked list according to the priority of the event types; adding the events that need to be sent to the corresponding event queue according to the sorting result, and sending the events in the event queue through a polling operation. Because this invention first sorts the subscription event methods according to the priority of the event types, and then sends the events according to the sorting result using a polling operation, compared to existing methods that process all events immediately upon receiving them, resulting in delays in processing urgent events, this invention can promptly process high-priority events, improving processing efficiency. Attached Figure Description
[0043] Figure 1 This is a schematic diagram of the message service processing device structure in the hardware operating environment involved in the embodiments of the present invention;
[0044] Figure 2 This is a flowchart illustrating the first embodiment of the message service processing method of the present invention;
[0045] Figure 3 This is a flowchart illustrating the second embodiment of the message service processing method of the present invention;
[0046] Figure 4 This is a flowchart illustrating the third embodiment of the message service processing method of the present invention;
[0047] Figure 5 This is a structural block diagram of the first embodiment of the message service processing device of the present invention.
[0048] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0049] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0050] Reference Figure 1 , Figure 1 This is a schematic diagram of the message service processing device structure in the hardware operating environment involved in the embodiments of the present invention.
[0051] like Figure 1As shown, the message service processing device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wireless-Fidelity (Wi-Fi) interface). The memory 1005 may be high-speed random access memory (RAM) or stable non-volatile memory (NVM), such as a disk storage device. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0052] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the message service processing device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0053] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a message service processing program.
[0054] exist Figure 1 In the message service processing device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the message service processing device of the present invention can be set in the message service processing device, and the message service processing device calls the message service processing program stored in the memory 1005 through the processor 1001 and executes the message service processing method provided in the embodiment of the present invention.
[0055] This invention provides a message service processing method, with reference to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the message service processing method of the present invention.
[0056] In this embodiment, the message service processing method includes the following steps:
[0057] Step S10: Upon receiving a subscription event, obtain the subscription event method corresponding to the subscription event.
[0058] It should be noted that the method in this embodiment can be applied in scenarios where the server receives and processes messages from the user, or in other scenarios where message processing is required. The executing entity in this embodiment can be a message service processing device with data processing, network communication, and program execution functions, such as a computer, server, or other devices capable of performing the same or similar functions. This embodiment and the following embodiments will be specifically described using the aforementioned message service processing device (hereinafter referred to as the device).
[0059] It is understood that this embodiment is based on an event bus framework. The event bus framework mainly includes events (i.e., the above-mentioned subscribed events), subscribers, and publishers. Events can be of any type. Publishers can publish any event in the event bus. Events are broadcast in the event bus. Subscribers receive the required events in the event bus according to their needs and process the required events. The processing method (i.e. the above-mentioned subscription event method) can be set according to the actual situation. This embodiment does not limit this.
[0060] It should be understood that before a subscriber subscribes to an event, the subscriber needs to create an instance. The creation method can be the double-lock singleton pattern. The double-lock singleton pattern can ensure data security by performing two non-null checks and using locking for synchronization control. After the above creation is completed, the device can register the subscriber on the event bus, and then notify the subscriber when the event is published to the event bus so that the subscriber can receive the event.
[0061] It is important to emphasize that during the registration process of the aforementioned devices, the devices can first obtain the registration class corresponding to the subscriber. Here, class is a data type, and a list of all subscription event methods of the subscriber can be found based on the registration class.
[0062] Furthermore, to improve the efficiency of the search, step S10 above includes:
[0063] Step S11: Upon receiving a subscription event, check in the cache whether a corresponding subscription event method exists based on the subscription event.
[0064] Step S12: If yes, obtain the corresponding subscription event method according to the subscription event.
[0065] It should be noted that the cache mentioned above stores historical subscription event methods. The device can save all previously subscribed event methods to the cache. When searching later, it can directly retrieve the corresponding subscription event method from the cache based on the class and save the found subscription event method to the subscription event method list. For ease of explanation later, this subscription event method list will be referred to as List. <subscribermethod>.
[0066] Furthermore, if the device does not find the corresponding subscription event method in the aforementioned cache, it can choose to use an indexing method. The specific steps, following step S11 above, also include:
[0067] Step S13: If not, obtain the corresponding indexing method identifier based on the subscribed event;
[0068] Step S14: Select the corresponding subscription event method from the index class according to the index method identifier;
[0069] Accordingly, before step S13 above, the following steps are also included:
[0070] Step S013: Generate the corresponding index identifier according to the subscription event method, and save the index identifier and the corresponding subscription event method to the index class.
[0071] Understandably, the aforementioned device can generate an index identifier for each historical subscription event method and save the index identifier and the corresponding subscription event method to an index class. When the device uses the index to perform a search, it can obtain the index identifier of the corresponding subscription event method based on the aforementioned class, and then search within the index class based on the index identifier, saving the found subscription event method to the aforementioned List. <subscribermethod>In, and in the List <subscribermethod>Save it to the cache so that it can be retrieved directly from the cache later.
[0072] As another implementation of this embodiment, if the device does not use an index, the subscription event method can be obtained through reflection parsing, and the parsed subscription event method can be saved to the aforementioned List. <subscribermethod>In the middle, simultaneously include List <subscribermethod>Save it to the cache so that it can be retrieved directly from the cache later.
[0073] It should be understood that when the corresponding subscription event method is not found in the cache, the choice between using an index or using reflection resolution can be set according to the actual situation, and this embodiment does not impose any restrictions on this.
[0074] In its implementation, the device can search the cache based on the subscriber's subscription events. If a corresponding subscription event method is found, all found subscription event methods are saved to the subscription event method list. If no corresponding subscription event method is found in the cache, the device can choose to use either indexing or reflection resolution based on its settings. If indexing is used, the device can generate an index identifier for each historical subscription event method before use, then find the corresponding subscription event method based on the index identifier, and save the found subscription event method to the subscription event method list. Simultaneously, the subscription event method list is saved to the cache so that it can be directly retrieved from the cache later, shortening the search time. If reflection resolution is used, the device can obtain the subscription event method through reflection resolution, save the resolved subscription event method to the subscription event method list, and simultaneously save the subscription event method list to the cache so that it can be directly retrieved from the cache later, shortening the search time, thus completing the search for all subscription event methods of the subscriber.
[0075] Step S20: Add the event types that the subscription event method can receive to the event type list, and sort the event type list according to the priority of the event types.
[0076] It should be noted that the event type linked list above stores the event types that the event subscription method can receive and the corresponding set of subscribers, that is, which subscribers can subscribe to a certain event type. For ease of explanation later, we will refer to the event type linked list as subscriptionByEventType.
[0077] Understandably, each of the above event types has a corresponding priority. When sorting a subscription event method, the order can be based on the priority of the corresponding event type. If the priority of the event type is higher, the corresponding subscription event method will be sorted first, and if the priority is lower, the corresponding subscription event method will be sorted last.
[0078] In a specific implementation, the device can save the event types that the subscription event methods can receive and the corresponding set of subscribers to an event type linked list, and sort the subscription event methods in the event type linked list according to the priority of the event types.
[0079] Step S30: Add the events that need to be sent to the corresponding event queue according to the sorting result, and send the events in the event queue through a polling operation.
[0080] It should be understood that after the above-mentioned device completes the subscriber registration process, it needs to send the corresponding events. The events that need to be sent now correspond to the subscription events of the above-mentioned subscribers. There can be multiple event queues, and different event queues can send different events.
[0081] In this embodiment, the device can search the cache based on the subscriber's subscription event. If a corresponding subscription event method is found, all found subscription event methods are saved to the subscription event method list. If no corresponding subscription event method is found in the cache, the device can choose to use an indexing method or a reflection resolution method according to the actual settings. If the indexing method is used, the device can generate an index identifier for each historical subscription event method before use, then find the corresponding subscription event method based on the index identifier, and save the found subscription event method to the subscription event method list. Simultaneously, the subscription event method list is saved to the cache so that it can be directly retrieved from the cache later, thus reducing latency. Short search time: If reflection resolution is used, the device can subscribe to event methods via reflection and save the resolved subscription event methods to the subscription event method list. Simultaneously, the subscription event method list is saved to a cache for later direct retrieval, shortening search time and enabling the search of all subscription event methods for each subscriber. The event types that the found subscription event methods can receive and the corresponding subscriber sets are saved to an event type linked list, and the subscription event methods in the event type linked list are sorted according to the priority of the event types. Then, events to be sent are added to the corresponding event queues based on the sorting results, and the events are sent to the corresponding subscribers through a polling operation. Compared to existing methods that process events immediately upon receipt, this embodiment can sort events according to their priority and store historical subscription event methods in a cache for later direct retrieval, improving processing efficiency.
[0082] refer to Figure 3 , Figure 3 This is a flowchart illustrating the second embodiment of the message service processing method of the present invention.
[0083] Furthermore, in order to process multiple subscription events simultaneously and improve processing capacity, based on the first embodiment described above, in this embodiment, step S30 includes:
[0084] Step S31: Add the events that need to be sent to the event queue according to the sorting result;
[0085] Step S32: Retrieve the corresponding subscriber from the event type linked list according to the event type;
[0086] Step S33: Send the events in the event queue to the subscribers through a polling operation.
[0087] It should be noted that, since the event type linked list stores the set of subscribers corresponding to the event type, in the specific implementation, the device can obtain the corresponding subscriber information from the event type linked list according to the event type of the event to be sent, and send the event to the corresponding subscriber through a polling operation.
[0088] Considering the relationships between some events, before retrieving the corresponding subscriber from the event type list based on the event type, the device will also traverse all events in the event queue to determine if there is a superclass event, that is, to determine if the event to be sent has related events. If so, the device will traverse to find the corresponding parent class event and find all events related to the event to be sent so as to send them simultaneously, thereby improving processing efficiency.
[0089] To further improve the processing capability of the above-mentioned device, the above-mentioned device can support a multi-threaded mode, that is, after step S31, it further includes: obtaining the current thread type of the event queue; correspondingly, after step S33, it further includes: obtaining the thread mode according to the event subscription method, and sending the thread mode to the subscriber according to the current thread type, so that the subscriber can process the event according to the thread mode after receiving the event.
[0090] Understandably, the current thread type can be divided into main thread and non-main thread, and the thread mode can be different event handling methods (i.e., subscribing to event methods). When the thread that publishes the event in the event queue is the main thread, the event subscription method is called through reflection to complete the event sending. When the thread that publishes the event in the event queue is a non-main thread, a thread switch will be performed to switch the non-main thread to the main thread, and then the event subscription method will be called through reflection.
[0091] Furthermore, considering that some events need to be resent because subscribers have not yet registered when they are sent, which is a complicated process, some events can be set as sticky events so that subscribers can automatically receive previously sent events after registering. Specifically, before step S31 above, the steps include: determining whether the subscribed event is a sticky event based on the event type; if so, saving the event type and the subscription event method to the sticky event set; correspondingly, step S10 includes: when a subscription event is received, determining whether it is a sticky event based on the event type of the subscription event; if so, obtaining the corresponding subscription event method from the sticky event set based on the subscription event.
[0092] This embodiment can retrieve the corresponding subscriber information from the event type linked list based on the event type to be sent, and send the event to the corresponding subscriber through a polling operation, thereby improving processing efficiency. Simultaneously, this embodiment can enhance processing capabilities through multi-threading mode, sending thread modes to the corresponding subscribers according to different current thread types, so that subscribers can call the subscription event method according to different thread modes. This embodiment can also set some events as sticky events, so that when a subscription event is received from a subscriber later, if it is a sticky event, the corresponding subscription event method can be directly selected from the sticky event set, further reducing the operating pressure on the device.
[0093] refer to Figure 4 , Figure 4 This is a flowchart illustrating the third embodiment of the message service processing method of the present invention.
[0094] Furthermore, considering that subscribers may need to unsubscribe from events, based on the above embodiments, such as Figure 4 As shown, after step S20 above, the following steps are also included:
[0095] Step S21: Add the subscriber corresponding to the subscribed event and the event type to the subscriber list.
[0096] Accordingly, after step S30 above, the method further includes: step S40: when receiving a subscription event to be unsubscribed, deleting the corresponding event type in the event type chain according to the subscription event to be unsubscribed.
[0097] It should be noted that the subscriber list above stores the subscriber and all the event types of the events it subscribes to, that is, all the event types that a subscriber subscribes to. For ease of explanation, we can refer to the subscriber list as typesBySubscriber.
[0098] Understandably, after the device sorts the data in subscriptionByEventType according to the priority of event types, it can save the data in typesBySubscriber based on the subscriber and the event types of all its subscribed events for use when canceling later.
[0099] In the specific implementation, when a subscriber cancels a subscription event, the device receives the event to be canceled and the subscriber to be canceled (i.e., the current subscriber). First, it retrieves a list of all event types corresponding to the current subscriber from typesBySubscribe, then iterates through the list of event types. At the same time, it retrieves a list of all subscribers corresponding to the event type from subscriptionByEventType, then iterates through the subscriber list, matches the subscriber to be canceled, and deletes it from the list of subscribers corresponding to the current event type. After the iteration is complete, it deletes the information of the current subscriber from typesBySubscribe.
[0100] In this embodiment, after the device sorts the data in the event type chain list according to the priority of the event type, it adds the subscriber and the corresponding event type to the subscriber list. When the unsubscribe event of the current subscriber is received, the event type in the event type chain list is deleted first, and then the current subscriber in the subscriber list is deleted, thereby realizing the subscriber cancellation process.
[0101] Furthermore, this embodiment of the invention also proposes a storage medium storing a message service processing program, which, when executed by a processor, implements the steps of the message service processing method described above.
[0102] In addition, refer to Figure 5 , Figure 5 This is a structural block diagram of a first embodiment of the message service processing device of the present invention. The present invention also proposes a message service processing device, which includes:
[0103] The method acquisition module 501 is used to acquire the subscription event method corresponding to the subscription event when a subscription event is received;
[0104] The linked list sorting module 502 is used to add the event types that the subscription event method can receive to the event type linked list, and sort the event type linked list according to the priority of the event types;
[0105] The event sending module 503 is used to add the events that need to be sent to the corresponding event queue according to the sorting result, and send the events in the event queue through a polling operation.
[0106] In this embodiment, the device can search the cache based on the subscriber's subscription event. If a corresponding subscription event method is found, all found subscription event methods are saved to the subscription event method list. If no corresponding subscription event method is found in the cache, the device can choose to use an indexing method or a reflection resolution method according to the actual settings. If the indexing method is used, the device can generate an index identifier for each historical subscription event method before use, then find the corresponding subscription event method based on the index identifier, and save the found subscription event method to the subscription event method list. Simultaneously, the subscription event method list is saved to the cache so that it can be directly retrieved from the cache later, thus reducing latency. Short search time: If reflection resolution is used, the device can subscribe to event methods via reflection and save the resolved subscription event methods to the subscription event method list. Simultaneously, the subscription event method list is saved to a cache for later direct retrieval, shortening search time and enabling the search of all subscription event methods for each subscriber. The event types that the found subscription event methods can receive and the corresponding subscriber sets are saved to an event type linked list, and the subscription event methods in the event type linked list are sorted according to the priority of the event types. Then, events to be sent are added to the corresponding event queues based on the sorting results, and the events are sent to the corresponding subscribers through a polling operation. Compared to existing methods that process events immediately upon receipt, this embodiment can sort events according to their priority and store historical subscription event methods in a cache for later direct retrieval, improving processing efficiency.
[0107] Other embodiments or specific implementations of the message service processing device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0108] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0109] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0110] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0111] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.< / subscribermethod> < / subscribermethod> < / subscribermethod> < / subscribermethod> < / subscribermethod>
Claims
1. A message service processing method, characterized by, The method comprises the following steps: When a subscription event is received, a subscription event method corresponding to the subscription event is acquired; The event type chain table is added with the event type that the subscription event method can receive, and the event type chain table is sorted according to the priority of the event type; According to the sorting result, the event currently needing to be sent is added to the corresponding event queue, and the events in the event queue are sent through polling operation; The step of adding the event currently needing to be sent to the event queue according to the sorting result, and sending the events in the event queue through polling operation, comprises: According to the sorting result, the event currently needing to be sent is added to the event queue; According to the event type, the corresponding subscriber is acquired from the event type chain table; The events in the event queue are sent to the subscriber through polling operation; After the step of adding the event currently needing to be sent to the event queue according to the sorting result, the method further comprises the following steps: The current thread type of the event queue is acquired; Accordingly, after the step of sending the events in the event queue to the subscriber through polling operation, the method further comprises the following steps: According to the subscription event method, the thread mode is acquired, and the thread mode is sent to the subscriber according to the current thread type, so that the subscriber performs event processing according to the thread mode after receiving the event.
2. The message service processing method of claim 1, wherein, The step of acquiring the subscription event method corresponding to the subscription event when the subscription event is received, comprises: When the subscription event is received, whether there is a corresponding subscription event method in the cache according to the subscription event is found; If yes, the corresponding subscription event method is acquired according to the subscription event.
3. The message service processing method of claim 2, wherein, After the step of finding whether there is a corresponding subscription event method in the cache according to the subscription event when the subscription event is received, the method further comprises the following steps: If no, the corresponding index mode identifier is acquired according to the subscription event; According to the index mode identifier, the corresponding subscription event method is selected from the index class; Accordingly, before the step of acquiring the corresponding index mode identifier according to the subscription event if no, the method further comprises the following steps: According to the subscription event method, the corresponding index identifier is generated, and the index identifier and the corresponding subscription event method are saved to the index class.
4. The message service processing method of claim 1, wherein, Before the step of adding the event currently needing to be sent to the event queue according to the sorting result, the method further comprises the following steps: According to the event type, it is judged whether the subscription event is a sticky event; If yes, the event type and the subscription event method are saved to the sticky event set; Accordingly, the step of acquiring the subscription event method corresponding to the subscription event when the subscription event is received, comprises: When the subscription event is received, whether the subscription event is a sticky event according to the event type of the subscription event is judged; If yes, the corresponding subscription event method is acquired from the sticky event set according to the subscription event.
5. The message service processing method according to any one of claims 1 to 3, wherein After the step of adding the event type that the subscription event method can receive to the event type chain table, and sorting the event type chain table according to the priority of the event type, the method further comprises the following steps: add the subscriber corresponding to the subscription event and the event type to a subscriber list; Accordingly, the step of adding the event currently in need of sending to the corresponding event queue according to the sorting result, and sending the events in the event queue through polling operation, further comprises: When receiving the event to be unsubscribed, delete the corresponding event type in the event type linked list according to the event to be unsubscribed.
6. A message service processing apparatus characterized by comprising: The device comprises: The method acquisition module is configured to acquire the subscription event method corresponding to the subscription event when receiving the subscription event; The linked list sorting module is configured to add the event type that the subscription event method can receive to an event type linked list, and sort the event type linked list according to the priority of the event type; The event sending module is configured to add the event currently in need of sending to the corresponding event queue according to the sorting result, and send the events in the event queue through polling operation. The event sending module is further configured to add the event currently in need of sending to the event queue according to the sorting result; acquire the corresponding subscriber from the event type linked list according to the event type; and send the events in the event queue to the subscriber through polling operation. The event sending module is further configured to acquire the current thread type of the event queue; acquire the thread mode according to the subscription event method, and send the thread mode to the subscriber according to the current thread type, so that the subscriber performs event processing according to the thread mode after receiving the event.
7. A message service processing device, characterized by comprising: The device comprises a memory, a processor, and a message service processing program stored on the memory and executable on the processor, and the message service processing program is configured to implement the steps of the message service processing method according to any one of claims 1 to 5.
8. A storage medium, characterized by The storage medium stores a message service processing program, and the message service processing program implements the steps of the message service processing method according to any one of claims 1 to 5 when executed by the processor.
Citation Information
Patent Citations
Subscription information pushing method and device, computer device and readable storage medium
CN111193789A
Multi-user message pushing method and pushing system based on publish-subscribe pattern
CN113905089A