A message processing method and related apparatus

By separating public and non-public content in messages and using a unified deserialization method, the problem of inconsistent message processing logic for different types of messages is solved, thereby improving the flexibility and scalability of message processing.

CN122317030APending Publication Date: 2026-06-30BEIJING CO WHEELS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411976863.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

How to achieve unified processing of different types of messages during message transmission, especially how to unify the deserialization processing logic of different types of messages in Kafka topics.

Method used

By acquiring messages to be processed, deserializing their common content into a temporary structure, and using the field types in the temporary structure to deserialize non-common content, the deserialization logic in the message processing process is unified. Common content is processed using a common function, and non-common content is processed according to a custom deserialization function.

Benefits of technology

It simplifies the deserialization process, improves the flexibility and scalability of message processing, reduces maintenance workload, and enhances the real-time performance and continuity of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122317030A_ABST
    Figure CN122317030A_ABST
Patent Text Reader

Abstract

This application provides a message processing method and related apparatus, relating to the field of communication technology. In this application, after obtaining a message to be processed, the common content of the message is first deserialized into a temporary structure. Then, using the field types in the temporary structure, the non-common content in the temporary structure is deserialized. Based on the results of the deserialization of the common content and the non-common content, the message content of the message to be processed is obtained. In this application, during message processing, the deserialization operation is no longer performed using separate deserialization methods for each message type. Instead, a unified approach is adopted: first deserializing the common content, then deserializing the non-common content. This unifies the deserialization processing logic in the message processing process and improves the flexibility of message processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a message processing method and related apparatus. Background Technology

[0002] During message transmission, producers will publish more and more different types of messages to Kafka topics. After the consumer obtains messages from Kafka topics, how to achieve unified processing of different types of messages is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0003] In view of the above problems, this application provides a message processing method and related apparatus to achieve the goal of unifying the deserialization processing logic in the message processing process. The specific solution is as follows:

[0004] A message processing method, comprising:

[0005] Get pending messages;

[0006] The public content in the message to be processed is deserialized into a temporary structure; wherein, the temporary structure includes the result of deserializing the public content and the non-public content that has not undergone deserialization.

[0007] Using the field types in the temporary structure, the non-public content in the temporary structure is deserialized to obtain the message content of the message to be processed based on the deserialized result of the public content and the deserialized result of the non-public content.

[0008] Optionally, the step of deserializing the common content in the message to be processed into a temporary structure includes:

[0009] Extract common content other than the specified content from the message to be processed;

[0010] Using common functions, the common content is deserialized to obtain the structure to be processed;

[0011] The specified content in the message to be processed is added as non-public content to the structure to be processed to obtain a temporary structure.

[0012] Optionally, the step of using the field types in the temporary structure to perform deserialization on the non-public content in the temporary structure, so as to obtain the message content of the message to be processed based on the deserialization result of the public content and the deserialization result of the non-public content, includes:

[0013] Determine whether the specified configuration information for the message to be processed is configured; the specified configuration information is configuration information that enables custom deserialization of the message to be processed.

[0014] If so, determine the custom deserialization function corresponding to the field type in the temporary structure;

[0015] The custom deserialization function is used to deserialize the non-public content in the temporary structure, so that the message content of the message to be processed can be obtained based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

[0016] Optionally, determining whether specified configuration information for the message to be processed is configured includes:

[0017] Get the specified environment variable;

[0018] If the content representation of the specified environment variable supports custom deserialization, the custom deserialization field in the temporary structure is obtained;

[0019] If the field content of the custom deserialization field indicates that the custom deserialization operation has not been cancelled, it is determined that the specified configuration information of the message to be processed is configured.

[0020] Optionally, the step of determining the custom deserialization function corresponding to the field type in the temporary structure includes:

[0021] Based on the correspondence between field types and custom deserialization functions, the custom deserialization functions corresponding to the field types in the temporary structure are obtained.

[0022] Optionally, the step of using the custom deserialization function to deserialize the non-public content in the temporary structure, so as to obtain the message content of the message to be processed based on the deserialization result of the public content and the deserialization result of the non-public content, includes:

[0023] For the non-public content in the temporary structure, the custom deserialization function is executed to create an instance corresponding to the non-public content;

[0024] The message content of the message to be processed is determined by using the result of deserialization of the public content in the temporary structure and the instance.

[0025] Optionally, it also includes:

[0026] Without configuring the specified configuration information for the message to be processed, create a variable with an arbitrary field type, deserialize the non-public content in the temporary structure into the variable, and use the result of deserializing the public content in the temporary structure and the variable to obtain the message content of the message to be processed.

[0027] A message processing apparatus, comprising:

[0028] The message retrieval module is used to retrieve messages to be processed.

[0029] The first processing module is used to deserialize the public content in the message to be processed into a temporary structure; wherein, the temporary structure includes the result of deserializing the public content and the non-public content that has not undergone deserialization.

[0030] The second processing module is used to perform deserialization operations on the non-public content in the temporary structure using the field types in the temporary structure, so as to obtain the message content of the message to be processed based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

[0031] An electronic device includes at least one processor and a memory connected to the processor, wherein:

[0032] The memory is used to store computer programs;

[0033] The processor is used to execute the computer program so that the electronic device can implement the message processing method described above.

[0034] A computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to perform the message processing method described above.

[0035] As can be seen from the above technical solutions, this application provides a message processing method and related apparatus. In this application, after obtaining a message to be processed, the common content of the message is first deserialized into a temporary structure. Then, using the field types in the temporary structure, the non-common content in the temporary structure is deserialized. Based on the results of the deserialization of the common content and the non-common content, the message content of the message to be processed is obtained. In this application, when processing messages, the deserialization operation is no longer performed using separate deserialization methods for each type of message. Instead, the deserialization operation is uniformly performed by first deserializing the common content and then the non-common content, thus unifying the deserialization processing logic in the message processing process and improving the flexibility of message processing. Attached Figure Description

[0036] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0037] Figure 1 A schematic diagram of a system architecture is provided for this application;

[0038] Figure 2 A schematic diagram of an optional hardware structure for a production end 100 provided in this application;

[0039] Figure 3 A schematic diagram of the structure of a consumer-side 200 provided in this application;

[0040] Figure 4 A flowchart illustrating a message processing method provided in an embodiment of this application;

[0041] Figure 5 A flowchart illustrating a deserialization method provided in an embodiment of this application;

[0042] Figure 6 This is a schematic diagram of the structure of a message processing device provided in an embodiment of this application;

[0043] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0044] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.

[0045] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0046] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.

[0047] See Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a producer end 100 and a consumer end 200. The consumer end 200 may include one or more servers (…). Figure 1 (The example includes a server) The consumer terminal 200 can provide the method provided in the embodiments of this application to one or more terminals.

[0048] The producer 100 produces messages and publishes them to a Kafka topic, while the consumer 200 retrieves messages from the Kafka topic and processes them.

[0049] The following description Figure 1 The product form of 100% in the mid-production stage;

[0050] In this application embodiment, the production end 100 can be a mobile phone, tablet computer, wearable device, in-vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), server, etc., and this application embodiment does not impose any restrictions on it.

[0051] Figure 2 A schematic diagram of an optional hardware structure for the production end 100 is shown.

[0052] refer to Figure 2As shown, the production end 100 may include components such as a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a headphone jack 163 (optional), a processor 170, an external interface 180, and a power supply 190. Those skilled in the art will understand that... Figure 2 These are merely examples of terminals or multi-functional devices and do not constitute a limitation on terminals or multi-functional devices. They may include more or fewer components than shown in the illustration, or combine certain components, or use different components.

[0053] Input unit 130 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, input unit 130 may include touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect touch operations performed by the user on or near it (such as operations performed by the user using fingers, knuckles, styluses, or any suitable object on or near the touch screen), and drive corresponding connection devices according to a pre-set program. The touch screen can detect the user's touch actions, convert the touch actions into touch signals and send them to the processor 170, and can receive and execute commands sent by the processor 170; the touch signal includes at least touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the production end 100 and the user. In addition, various types of touch screens, such as resistive, capacitive, infrared, and surface acoustic wave, can be used. In addition to touch screen 131, input unit 130 may also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.

[0054] Among them, the input device 132 can receive input data, etc.

[0055] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the production end 100, interactive interfaces, file display and / or playback of any multimedia file.

[0056] The memory 120 can be used to store instructions and data. The memory 120 may primarily include an instruction storage area and a data storage area. The data storage area can store various types of data, such as multimedia files and text. The instruction storage area can store software units such as operating systems, applications, and instructions required for at least one function, or subsets or extended sets thereof. It may also include non-volatile random access memory. It provides the processor 170 with hardware, software, and data resources for managing the computing device, supporting control software and applications. It is also used for storing multimedia files, as well as storing running programs and applications.

[0057] Processor 170 is the control center of production terminal 100. It connects various parts of production terminal 100 via various interfaces and lines. By running or executing instructions stored in memory 120 and calling data stored in memory 120, it performs various functions and processes data of production terminal 100, thereby providing overall control of the terminal device. Optionally, processor 170 may include one or more processing units; preferably, processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into processor 170. In some embodiments, the processor and memory can be implemented on a single chip; in some embodiments, they can also be implemented separately on independent chips. Processor 170 can also be used to generate corresponding operation control signals, send them to corresponding components of the computing processing device, read and process data in the software, especially read and process data and programs in memory 120, so that each functional module therein performs its corresponding function, thereby controlling the corresponding components to act according to the instructions.

[0058] The memory 120 can be used to store software code related to the message production method, and the processor 170 can execute the steps of the message production method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve the corresponding functions.

[0059] The radio frequency unit 110 (optional) can be used for receiving and transmitting signals during information transmission or calls. For example, it can receive downlink information from the base station and process it for the processor 170; additionally, it can transmit uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the radio frequency unit 110 can also communicate wirelessly with network devices and other devices. This wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0060] In this embodiment of the application, the radio frequency unit 110 can transmit data to the consumer terminal 200.

[0061] It should be understood that the radio frequency unit 110 is optional and can be replaced with other communication interfaces, such as a network port.

[0062] The production end 100 also includes a power supply 190 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.

[0063] The production end 100 also includes an external interface 180, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect the production end 100 to other devices for communication, or to connect a charger to charge the production end 100.

[0064] Although not shown, the production end 100 may also include a flash, a Wireless Fidelity (WiFi) module, a Bluetooth module, sensors with various functions, etc., which will not be elaborated here. Some or all of the methods described below can be applied to, for example... Figure 2 The production end 100 is shown.

[0065] The following description Figure 1 Product formats for mid-to-consumer end products;

[0066] Figure 3 A structural diagram of a consumer-side 200 is provided, such as... Figure 3 As shown, the consumer terminal 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0067] Bus 201 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 3 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0068] The processor 202 can be any one or more of the following processors: a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0069] Memory 204 may include volatile memory, such as random access memory (RAM). Memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0070] The memory 204 can be used to store software code related to the message processing method, and the processor 202 can execute the steps of the chip's message processing method, and can also schedule other units to achieve the corresponding functions.

[0071] It should be understood that the aforementioned production end 100 and consumer end 200 can be centralized or distributed devices. The processors (e.g., processor 170 and processor 202) in the aforementioned production end 100 and consumer end 200 can be hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, DSPs, microprocessors, or microcontrollers, etc.) or combinations of these hardware circuits. For example, the processor can be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.

[0072] This application provides a message processing method, which is applied to... Figure 1 Taking the computer device in the figure above as an example, the computer device can specifically be the consumer terminal 200 or a system composed of the producer terminal 100 and the consumer terminal 200. The message processing method of the embodiment of this application will be described in detail below with reference to the accompanying drawings.

[0073] Reference Figure 4 , Figure 4 This is a flowchart illustrating a message processing method provided in an embodiment of this application. The method includes:

[0074] Step S11: Obtain the message to be processed.

[0075] In real-world scenarios, the producer can produce messages and publish them to a Kafka topic so that the consumer can consume the messages in the Kafka topic.

[0076] The production side can be system log monitor (systemlogmonitor), daemon process (ds) deployed on each machine on the production side, or pilot processing terminal.

[0077] The production end can generate a structure corresponding to the message, and then perform a serialization operation on the structure to obtain the message. In this embodiment of the invention, the message can be called a CerberusEvent. For example, the message can be a host temperature message, a storage shortage message, etc.

[0078] The producer then sends the message to the Kafka topic, where it is saved to the corresponding Kafka message queue. Kafka can be divided into multiple message queues based on topics; the message is stored in the appropriate queue according to the topic to which it was published.

[0079] CerberusEvent-pilot acts as a consumer, consuming messages from the Kafka message queue. These messages are called pending messages. The consumer needs to deserialize these messages before it can view and use them correctly.

[0080] Step S12: Deserialize the common content in the message to be processed into a temporary structure.

[0081] The temporary structure includes the result of deserializing public content and non-public content that has not undergone deserialization.

[0082] In real-world scenarios, different message types are configured with their own deserialization methods. Currently, after receiving a message, the deserialization method matching that message type needs to be called for deserialization. However, as the number of message types increases, it becomes necessary to configure and install deserialization methods for each type, and these methods need to be called repeatedly during deserialization, making the deserialization process complex. Furthermore, the processing logic of the deserialization methods matching different message types differs, lacking a unified deserialization process and adding to its difficulties. If a unified deserialization process could be implemented, it would simplify the process, requiring only a single configuration of the deserialization method. This unified method would be applicable to all message types, eliminating the need for separate configuration for each message type and simplifying the configuration process.

[0083] This invention analyzes the message structure during unified deserialization operations and discovers that different message types contain common and non-common content. Common content refers to content present in all message types, while non-common content refers to content unique to each message type. Therefore, different methods can be used to perform deserialization operations for common and non-common content respectively.

[0084] This step mainly introduces the deserialization operation of public content. For this public content, the corresponding public function can be called to perform the deserialization operation.

[0085] Step S13: Using the field types in the temporary structure, perform deserialization on the non-public content in the temporary structure to obtain the message content of the message to be processed based on the deserialization results of the public content and the non-public content.

[0086] In this embodiment, the non-public content of different types of messages may vary, and can be configured accordingly. Therefore, it is necessary to perform deserialization operations on each type of non-public content to obtain the message content of the message to be processed. In this embodiment, a custom deserialization mechanism is used to achieve flexible parsing and processing of different structures, thereby improving the system's support for diverse business scenarios.

[0087] In this embodiment, after obtaining the message to be processed, the common content in the message is first deserialized into a temporary structure. Then, using the field types in the temporary structure, the non-common content in the temporary structure is deserialized. Based on the results of the deserialization of the common content and the non-common content, the message content of the message to be processed is obtained. In this application, when processing messages, the deserialization operation is no longer performed using the deserialization methods configured separately for each type of message. Instead, the deserialization operation is uniformly performed by first deserializing the common content and then the non-common content, thus unifying the deserialization processing logic in the message processing process and improving the flexibility of message processing.

[0088] In addition, since the deserialization processing logic in the message processing process is unified and custom operations are supported, only one program is needed to process all types of messages. There is no longer a need to configure the deserialization operation corresponding to each type of message, which reduces the workload of maintaining the deserialization operation method and also reduces the maintenance burden caused by changes in hard-coded logic.

[0089] In addition, users can customize non-public content according to their needs, improving the scalability and flexibility of the event processing system used for message processing, enabling the system to dynamically adapt to and handle various event types.

[0090] In another implementation of the present invention, the process of deserializing the common content in the message to be processed into a temporary structure is described, which may specifically include:

[0091] 1) Extract the common content other than the specified content from the message to be processed.

[0092] Specifically, the specified content can be the content in the Content field. In the message, all content other than that in the Content field is called public content. The content in the Content field can be customized, such as defining the host serial number of a power failure, device status, etc.

[0093] 2) Using the common function, the common content is deserialized to obtain the structure to be processed.

[0094] For public content, there are pre-configured public functions, specifically public deserialization functions. These functions can be used to deserialize the public content to obtain a structure to be processed. Here, a structure refers to structured data composed of a batch of data; in this embodiment, the structure to be processed is the result of deserializing the public content.

[0095] 3) Add the specified content in the message to be processed as non-public content to the structure to be processed to obtain a temporary structure.

[0096] Specifically, the specified content, namely the content in the Content field, is treated as non-public content that has not undergone deserialization and is directly added to the structure to be processed, resulting in a temporary structure temp.

[0097] The Content field in temp contains data of type json.RawMessage.

[0098] It should be noted that when adding the content of the Content field to temp, there is no need to modify or adjust the content of the Content field; you can simply add it directly.

[0099] Additionally, the `temp` object contains a message label field called `Labels[cerberus.io / cancel_self_deserialization]`, which can be considered a custom deserialization field. This field indicates whether the custom deserialization operation was not canceled. If the field content indicates that the custom deserialization of `temp.Content` (the non-public content field in the temporary structure) was canceled, it means the user does not want to perform custom deserialization operations on non-public content. If the field content indicates that the custom deserialization of `temp.Content` was not canceled, it means the user wants to perform custom deserialization operations on non-public content.

[0100] Additionally, the `Labels` property in `temp` contains a `reason` field. Different `reason` values ​​correspond to different structures. This field uses a key-value pair format, where the key is the field type and the value is the content of that field type. The specific content can be configured by the user. This value affects the custom deserialization function used during the deserialization of non-public content. Specifically, the constructor to handle `temp.Content` can be dynamically selected based on the content of the `reason` field in the `Labels` property. This pattern allows the system to flexibly extend and handle different types of business logic based on the different `reason` fields.

[0101] In this embodiment, the public content is deserialized first, that is, a portion of the content is deserialized first. The resulting temp contains a field that determines the deserialization method for the non-public content. Then, the non-public content can be deserialized based on this field.

[0102] After deserializing the public content to obtain temp, temp.Content needs to be deserialized. There are different deserialization methods depending on the content of the preset environment variables and the content of the corresponding fields in temp. These will be introduced separately.

[0103] Reference Figure 5 Using the field types in the temporary structure, the non-public content in the temporary structure is deserialized to obtain the message content of the message to be processed, including:

[0104] S21. Determine whether the specified configuration information for the message to be processed is configured; if yes, proceed to step S22; if no, proceed to step S24.

[0105] The specified configuration information refers to the configuration information that enables custom deserialization of the message to be processed. If the message to be processed is configured with this specified configuration information, it means that for non-public content, i.e., the aforementioned temp.Content, custom deserialization is allowed. If the specified configuration information is not configured, it means that for non-public content, i.e., the aforementioned temp.Content, custom deserialization is not allowed, and in this case, any variable of type any (any) can be used for deserialization.

[0106] In practical scenarios, you can determine whether specific configuration information is configured by specifying environment variables and the `Labels[cerberus.io / cancel_self_deserialization]` field mentioned above. Specifically, after reading Kafka messages, the consumer-side handler `Manager.handle` retrieves the specified environment variable `EVENT_NO_SELF_DESERIALIZATION`. This environment variable can take two values: `true`, `false`, or empty. If `EVENT_NO_SELF_DESERIALIZATION` is `true`, it means that the variable's content represents a preset field that does not support custom deserialization. When `EVENT_NO_SELF_DESERIALIZATION` is `true`, it means that all content in the current service does not use preset fields for custom deserialization. In this case, custom deserialization of `temp.Content` is not allowed; custom deserialization of `temp.Content` should be canceled, and other methods should be used for deserialization. If `false` or empty, it means that the specified environment variable's content represents a preset field that supports custom deserialization. In this case, custom deserialization of `temp.Content` is allowed.

[0107] If the specified environment variable is false or empty, retrieve the custom deserialization field in the temporary structure, that is, retrieve the Labels[cerberus.io / cancel_self_deserialization] field in temp, and determine whether to cancel the custom deserialization of temp.Content.

[0108] If the content of the custom deserialization field indicates that the custom deserialization operation has not been cancelled, then it is determined that the specified configuration information for the message to be processed is configured. If the content of the custom deserialization field indicates that the custom deserialization operation has been cancelled, then it is determined that the specified configuration information for the message to be processed is not configured, and in this case, other methods are used for deserialization.

[0109] In this embodiment, by specifying environment variables and custom deserialization fields, the system autonomously decides whether to perform custom deserialization on non-public content. This provides the ability to personalize the custom deserialization process for each field type, offering dynamic adjustment capabilities for the event handling flow and supporting a wider range of business scenario needs. Furthermore, the combined use of environment variables and message tags provides an easily adjustable event handling flow.

[0110] S22. Determine the custom deserialization function corresponding to the field type in the temporary structure.

[0111] Specifically, the mapping between field types and custom deserialization functions can be pre-configured, and this mapping can be stored in the format of a MAP table. The value is retrieved from the key-value pair corresponding to the field type `reason`, and this value is used as the query input to the MAP table to obtain the corresponding custom deserialization function. This custom deserialization function can specifically be a constructor.

[0112] It should be noted that the "reason" mentioned above specifically refers to the `cerberus.io / reason` field used in Labels. By customizing the `cerberus.io / reason` field of Labels, the deserialization method for different message types can be dynamically selected. If the content of this field is empty, it means that the user has not configured the field type in this field. In this case, the field type can be obtained from the `reason` field, and a custom deserialization function can be selected according to that field type.

[0113] S23. Use the custom deserialization function to deserialize the non-public content in the temporary structure, so as to obtain the message content of the message to be processed based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

[0114] In this embodiment, the processing endpoint Manager.handleEvent in Manager.handle calls the custom deserialization function of CerberusEvent to process non-public content, namely the content in temp.Content.

[0115] More specifically, during the deserialization process, for the non-public content in the temporary structure, the custom deserialization function is executed to create an instance v corresponding to the non-public content. The message content of the message to be processed is determined by using the result of deserialization of the public content in the temporary structure and the instance.

[0116] Specifically, the custom deserialization function continues to run, deserializing the non-public content in the temporary structure into the instance v.

[0117] In detail, the non-public content temp.Content in the temporary structure is deserialized into the instance v, which is also a structure. The result of deserializing the public content in temp and the instance v are combined to obtain the target structure. The content in the target structure is assigned to a new CerberusEvent to obtain the message content of the message to be processed.

[0118] S24. Create a variable with an arbitrary field type, deserialize the non-public content in the temporary structure into the variable, and use the result of deserializing the public content in the temporary structure and the variable to obtain the message content of the message to be processed.

[0119] Specifically, if the specified configuration information for the message to be processed is not configured, such as canceling the serialization of temp.Content using the Labels[cerberus.io / cancel_self_deserialization] field and obtaining a specified environment variable of true, it means that a custom deserialization method cannot be used for deserialization. In this case, a variable x of type any can be created. After variable x is created, temp.Content is deserialized into variable x using JSON (JavaScript Object Notation). The result of deserializing the common content in temp and instance x are combined to obtain the target structure. Subsequently, the target structure is converted into the message content of the message to be processed.

[0120] In this embodiment, when a custom deserialization method cannot be used for deserialization, a variable x of type 'any' is created to support deserialization of any type of message, ensuring the uniformity of the deserialization process. Furthermore, using a unified deserialization operation simplifies the selection of the response deserialization method based on different messages to be processed, significantly improving event processing speed and efficiency, and reducing the hard-coding cost of event processing logic.

[0121] In addition, in this embodiment, users can dynamically configure the field type through the cerberus.io / reason field or Reason, thereby allowing them to customize the deserialization function and effectively improve the system's flexibility in handling different types of events.

[0122] In addition, a flexible deserialization mechanism can improve system scalability, reduce downtime during system updates, and enhance the system's real-time performance and continuity.

[0123] The above describes a message processing method provided by an embodiment of this application. The following describes an apparatus for performing the above message processing method.

[0124] Please see Figure 6 , Figure 6 This is a schematic diagram of a message processing device provided in an embodiment of this application. Figure 6 As shown, the device includes:

[0125] Message acquisition module 11 is used to acquire messages to be processed;

[0126] The first processing module 12 is used to deserialize the public content in the message to be processed into a temporary structure; wherein, the temporary structure includes the result of deserializing the public content and the non-public content that has not undergone deserialization.

[0127] The second processing module 13 is used to perform deserialization operation on the non-public content in the temporary structure using the field types in the temporary structure, so as to obtain the message content of the message to be processed based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

[0128] In one implementation, the first processing module 12 includes:

[0129] The content extraction submodule is used to extract common content other than specified content from the message to be processed;

[0130] The first deserialization submodule is used to perform deserialization operations on the public content using public functions to obtain the structure to be processed;

[0131] Add a submodule to add specified content from the message to be processed as non-public content to the structure to be processed, thus obtaining a temporary structure.

[0132] In one implementation, the second processing module 13 includes:

[0133] The judgment submodule is used to determine whether the specified configuration information of the message to be processed is configured; the specified configuration information is configuration information that enables custom deserialization of the message to be processed.

[0134] The function determines the submodule, which, if applicable, determines the custom deserialization function corresponding to the field type in the temporary structure;

[0135] The second deserialization submodule is used to perform deserialization operations on the non-public content in the temporary structure using the custom deserialization function, so as to obtain the message content of the message to be processed based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

[0136] In one implementation, the judgment submodule includes:

[0137] The variable retrieval unit is used to retrieve specified environment variables;

[0138] The data processing unit, if the content representation of the specified environment variable supports custom deserialization, obtains the custom deserialization field in the temporary structure;

[0139] The judgment unit is used to determine that the specified configuration information of the message to be processed is configured if the field content of the custom deserialization field indicates that the custom deserialization operation has not been canceled.

[0140] In one implementation, the function determines the specific use of the submodule:

[0141] Based on the correspondence between field types and custom deserialization functions, the custom deserialization functions corresponding to the field types in the temporary structure are obtained.

[0142] In one implementation, the second deserialization submodule is specifically used for:

[0143] For the non-public content in the temporary structure, the custom deserialization function is executed to create an instance corresponding to the non-public content;

[0144] The message content of the message to be processed is determined by using the result of deserialization of the public content in the temporary structure and the instance.

[0145] In one implementation, the second processing module 13 further includes:

[0146] The third deserialization submodule is used to create a variable of arbitrary field type when the judgment submodule determines that no specified configuration information of the message to be processed is configured, deserialize the non-public content in the temporary structure into the variable, and obtain the message content of the message to be processed by using the result of the deserialization of the public content in the temporary structure and the variable.

[0147] In this embodiment, after obtaining the message to be processed, the common content in the message is first deserialized into a temporary structure. Then, using the field types in the temporary structure, the non-common content in the temporary structure is deserialized. Based on the results of the deserialization of the common content and the non-common content, the message content of the message to be processed is obtained. In this application, when processing messages, the deserialization operation is no longer performed using the deserialization methods configured separately for each type of message. Instead, the deserialization operation is uniformly performed by first deserializing the common content and then the non-common content, thus unifying the deserialization processing logic in the message processing process and improving the flexibility of message processing.

[0148] This application embodiment also provides an electronic device, including at least one processor and a memory connected to the processor, wherein:

[0149] The memory is used to store computer programs;

[0150] The processor is used to execute the computer program so that the electronic device can implement the message processing method described above.

[0151] refer to Figure 7 The diagram illustrates a structural schematic suitable for implementing the electronic device in the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (Personal Digital Assistants), PADs (Portable Application Devices), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0152] like Figure 7 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in ROM 602 or a program loaded from storage device 608 into RAM 603. When the electronic device is powered on, RAM 603 also stores various programs and data required for the operation of the electronic device. The processing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0153] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, memory cards, hard drives, etc.; and communication devices 609. Communication device 609 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0154] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the message processing methods provided in this application.

[0155] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the message processing methods provided in this application.

[0156] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0157] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, 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 readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0158] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0159] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line, DSL) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs (Digital Versatile Discs)), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A message processing method characterized by, include: Get pending messages; The public content in the message to be processed is deserialized into a temporary structure; wherein, the temporary structure includes the result of deserializing the public content and the non-public content that has not undergone deserialization. Using the field types in the temporary structure, the non-public content in the temporary structure is deserialized to obtain the message content of the message to be processed based on the deserialized result of the public content and the deserialized result of the non-public content.

2. The message processing method of claim 1, wherein, The step of deserializing the common content in the message to be processed into a temporary structure includes: Extract common content other than the specified content from the message to be processed; Using common functions, the common content is deserialized to obtain the structure to be processed; The specified content in the message to be processed is added as non-public content to the structure to be processed to obtain a temporary structure.

3. The message processing method of claim 1, wherein, The step involves using the field types in the temporary structure to perform deserialization on the non-public content within the temporary structure, and obtaining the message content of the message to be processed based on the deserialization results of the public content and the non-public content, including: Determine whether the specified configuration information for the message to be processed is configured; the specified configuration information is configuration information that enables custom deserialization of the message to be processed. If so, determine the custom deserialization function corresponding to the field type in the temporary structure; The custom deserialization function is used to deserialize the non-public content in the temporary structure, so that the message content of the message to be processed can be obtained based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

4. The message processing method of claim 3, wherein, The step of determining whether the specified configuration information for the message to be processed is configured includes: Get the specified environment variable; If the content representation of the specified environment variable supports custom deserialization, the custom deserialization field in the temporary structure is obtained; If the field content of the custom deserialization field indicates that the custom deserialization operation has not been cancelled, it is determined that the specified configuration information of the message to be processed is configured.

5. The message processing method of claim 3, wherein, The custom deserialization function that determines the field types in the temporary structure includes: Based on the correspondence between field types and custom deserialization functions, the custom deserialization functions corresponding to the field types in the temporary structure are obtained.

6. The message processing method of claim 3, wherein, The step of using the custom deserialization function to deserialize the non-public content in the temporary structure, and obtaining the message content of the message to be processed based on the deserialization results of the public content and the non-public content, includes: For the non-public content in the temporary structure, the custom deserialization function is executed to create an instance corresponding to the non-public content; The message content of the message to be processed is determined by using the result of deserialization of the public content in the temporary structure and the instance.

7. The message processing method of claim 3, wherein, Also includes: Without configuring the specified configuration information for the message to be processed, create a variable with an arbitrary field type, deserialize the non-public content in the temporary structure into the variable, and use the result of deserializing the public content in the temporary structure and the variable to obtain the message content of the message to be processed.

8. A message processing device, characterized by include: The message retrieval module is used to retrieve messages to be processed. The first processing module is used to deserialize the public content in the message to be processed into a temporary structure; wherein, the temporary structure includes the result of deserializing the public content and the non-public content that has not undergone deserialization. The second processing module is used to perform deserialization operations on the non-public content in the temporary structure using the field types in the temporary structure, so as to obtain the message content of the message to be processed based on the result of the deserialization of the public content and the result of the deserialization of the non-public content.

9. An electronic device, comprising: It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the message processing method as described in any one of claims 1 to 7.

10. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the message processing method as described in any one of claims 1 to 7.