Message processing method, device, system, equipment and storage medium
By implementing logical grayscale and flexible configuration among message producers and consumers, the problems of low resource utilization and high cost during grayscale release are solved, and the ability to switch consumer types without shutting down is realized, which improves compatibility and efficiency.
Patent Information
- Application Number
- CN202310938499.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-27
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2043-07-27
AI Technical Summary
When grayscale release, the prior art requires special configuration of system resources to support the operation of grayscale services and middleware, resulting in low resource utilization and increased cost, while the grayscale release cannot be performed in the event that grayscale version and official version are incompatible.
By implementing logical grayscale for message producers and message consumers, allowing flexible configuration of grayscale configuration information, enabling message consumers to switch consumer types without shutting down, reducing costs and improving compatibility.
The logical grayscale and flexible grayscale configuration of message consumers are realized, reducing costs and improving compatibility, making grayscale release more efficient.
Smart Images

Figure CN117033015B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a message processing method, apparatus, system, device and storage medium. Background Art
[0002] In the related art, when grayscale release of a product is carried out, the corresponding system resources need to be specially configured to support the operation of grayscale services and corresponding middleware. Grayscale services consume more system resources than formal services, resulting in low system resource utilization and increased costs. In addition, the related art cannot carry out grayscale release when the grayscale version and the formal version are incompatible. Summary of the invention
[0003] The present application provides a message processing method, device, electronic device and storage medium. The method can realize the logical grayscale of message producers and message consumers, and can configure grayscale configuration information more flexibly, so that message consumers can switch consumer types without downtime based on grayscale configuration information, and the implementation cost is low and the compatibility is good.
[0004] In a first aspect, an embodiment of the present application provides a message processing method, which is applied to a message consumer, and the method includes: enabling a first consumption service corresponding to the message consumer; wherein the first consumption service is a service provided by a consumption group currently corresponding to the message consumer; obtaining a pending message from a message queue based on the first consumption service; determining a message type of the pending message; obtaining a consumer type of the message consumer; and processing the pending message based on the message type and the consumer type.
[0005] In an optional implementation, enabling the first consumption service corresponding to the message consumer includes: determining the configuration information of the message consumer; obtaining the grayscale configuration information of the network side device configuration; and enabling the corresponding first consumption service based on the configuration information of the message consumer and the grayscale configuration information.
[0006] In an optional implementation, enabling the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information includes: determining a target consumer type from multiple consumer types according to the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a different consumption service; enabling the first consumption service corresponding to the target consumer type, and disabling other consumption services.
[0007] In an optional implementation, enabling the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information includes: obtaining the current consumer type of the message consumer; determining a target consumer type from multiple consumer types according to the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a first consumption service; in response to the current consumer type being different from the target consumer type, determining the target consumer type as a new current consumer type; enabling the first consumption service corresponding to the target consumer type, and disabling other consumption services.
[0008] In one implementation, the message to be processed includes a message type tag, and determining the message type of the message to be processed includes: determining the message type of the message to be processed according to the message type tag.
[0009] In one implementation, the processing of the pending message based on the message type and the consumer type includes: determining the message type that can be processed by the message consumer based on the consumer type; and processing the pending message in response to the message type of the pending message being the same as the message type that can be processed by the message consumer.
[0010] In one implementation, the processing of the pending message based on the message type and the consumer type includes: determining the message type that can be processed by the message consumer based on the consumer type; and ignoring the pending message in response to the message type of the pending message being different from the message type that can be processed by the message consumer.
[0011] In a second aspect, an embodiment of the present application provides a message processing method, which is applied to a message producer, and the method includes: obtaining request information; wherein the request information includes an information type tag; generating a message to be processed based on the request information; wherein the message to be processed includes a message type tag; providing the message to be processed to a message consumer through a message queue, wherein the message consumer is used to process the message to be processed based on the consumer type of the message consumer and the message type.
[0012] In the third aspect, an embodiment of the present application provides a message processing device, which is applied to a message consumer, and the device includes: a first processing module, used to enable a first consumption service corresponding to the message consumer; wherein the first consumption service is a service provided by a consumption group currently corresponding to the message consumer; a first acquisition module, used to obtain a pending message from a message queue based on the first consumption service; a second processing module, used to determine the message type of the pending message; a second acquisition module, used to obtain the consumer type of the message consumer; a third processing module, used to process the pending message based on the message type and the consumer type.
[0013] In one implementation, the first processing module is specifically used to: determine the configuration information of the message consumer; obtain the grayscale configuration information of the network side device configuration; and enable the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information.
[0014] In an optional implementation, the first processing module is specifically used to determine a target consumer type from multiple consumer types based on the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a different consumer service; enable a first consumer service corresponding to the target consumer type, and disable other consumer services.
[0015] In an optional implementation, the first processing module is specifically used to obtain the current consumer type of the message consumer; determine the target consumer type from multiple consumer types according to the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a first consumption service; in response to the current consumer type being different from the target consumer type, determine the target consumer type as a new current consumer type; enable the first consumption service corresponding to the target consumer type, and disable other consumption services.
[0016] In one implementation, the second processing module is specifically configured to determine the message type of the message to be processed according to the message type tag.
[0017] In one implementation, the third processing module is specifically used to: determine the message type that the message consumer can process based on the consumer type; and process the message to be processed in response to the message type of the message to be processed being the same as the message type that the message consumer can process.
[0018] In one implementation, the third processing module is specifically used to: determine the message type that the message consumer can process based on the consumer type; in response to the message type of the to-be-processed message being different from the message type that the message consumer can process, ignore the to-be-processed message.
[0019] In a fourth aspect, an embodiment of the present application provides a message processing device, which is applied to a message producer, and the device includes: an acquisition module, used to obtain request information; wherein the request information includes an information type tag; a processing module, used to generate a message to be processed according to the request information; wherein the message to be processed includes a message type tag; a push module, used to provide the message to be processed to a message consumer through a message queue, wherein the message consumer is used to process the message to be processed based on the consumer type of the message consumer and the message type.
[0020] In a fifth aspect, an embodiment of the present application provides a message processing system, including: a message consumer, used to execute the method as described in the first aspect; a message consumer, used to execute the method as described in the second aspect.
[0021] In a sixth aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message processing method as described in the first aspect, or execute the message processing method as described in the second aspect.
[0022] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium for storing instructions, which, when executed, enables the method described in the first aspect to be implemented, or enables the method described in the second aspect to be implemented.
[0023] In an eighth aspect, an embodiment of the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of the message processing method as described in the first aspect, or implements the steps of the message processing method as described in the second aspect.
[0024] The technical solution provided by the embodiments of the present application may include the following beneficial effects: it can realize the logical grayscale of message producers and message consumers, and can configure the grayscale configuration information more flexibly, so that message consumers can implement consumer type switching without downtime based on the grayscale configuration information, and the implementation cost is low.
[0025] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0027] Figure 1 is a schematic diagram of a message processing method provided in an embodiment of the present application;
[0028] Figure 2 is a schematic diagram of another message processing method provided in an embodiment of the present application;
[0029] Figure 3 is a schematic diagram of another message processing method provided in an embodiment of the present application;
[0030] Figure 4 is a schematic diagram of another message processing method provided in an embodiment of the present application;
[0031] Figure 5 is a schematic diagram of another message processing method provided in an embodiment of the present application;
[0032] Figure 6 is a schematic diagram of another message processing method provided in an embodiment of the present application;
[0033] Figure 7 It is a schematic diagram of a message processing solution provided in an embodiment of the present application;
[0034] Figure 8 is a schematic diagram of a message processing device provided in an embodiment of the present application;
[0035] Fig. 9 is a schematic diagram of another message processing device provided in an embodiment of the present application;
[0036] Fig.10 is a schematic block diagram of an example electronic device that can be used to implement embodiments of the present application. DETAILED DESCRIPTION
[0037] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0038] In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The various numbers such as first, second, etc. involved in this application are only distinguished for the convenience of description, and are not used to limit the scope of the embodiments of this application, nor do they indicate the order of precedence.
[0039] See also Figure 1 , Figure 1 Schematic diagram of a message processing method provided by an embodiment of the present application. The method can be applied to message consumers. Figure 1 As shown, the method may include but is not limited to the following steps:
[0040] Step S101: Activate a first consumption service corresponding to a message consumer.
[0041] Among them, in an embodiment of the present application, the first consumption service is a service provided by the consumption group currently corresponding to the message consumer.
[0042] Specifically, a first consumption service corresponding to the message consumer is enabled, where the first consumption service is a service provided by a consumption group currently corresponding to the message consumer.
[0043] It can be understood that a consumer group may include multiple message consumers, and the message consumers in the same consumer group are of the same category.
[0044] Step S102: Obtain a to-be-processed message from a message queue based on the first consumption service.
[0045] For example, the message consumer can obtain the to-be-processed message from the message queue through the currently corresponding consumer group based on the first consumption service.
[0046] In an embodiment of the present application, the message queue may be a topic of a stream processing platform KAFKA, and the consumer group may be a consumer group in KAFKA.
[0047] Step S103: Determine the message type of the message to be processed.
[0048] For example, the content of the message to be processed is identified to determine the message type of the message to be processed.
[0049] Among them, in the embodiments of the present application, the above message types include but are not limited to formal messages and grayscale messages.
[0050] Step S104: Obtain the consumer type of the message consumer.
[0051] Specifically, determine the consumer type of the message consumer at the current moment.
[0052] Among them, in the embodiments of the present application, the above consumer types include but are not limited to formal consumers and gray consumers.
[0053] Step S105: Process the message to be processed based on the message type and the consumer type.
[0054] For example, it can be preset that each consumer type of message consumer can only process pending messages of one message type. Thus, it can be determined whether the message consumer of the consumer type can process pending messages of the message type according to the consumer type of the message consumer, and the pending messages can be processed accordingly according to the determination result.
[0055] By implementing the embodiments of the present application, the message consumer can obtain the pending message based on the enabled first consumption service, and thus process the pending message accordingly according to the consumer type of the message consumer and the message type of the pending message. It is possible to implement isolated processing of pending messages of different message types to achieve the logical grayscale of the message consumer, and the implementation cost is low.
[0056] In one implementation, the corresponding first consumption service can be enabled according to the grayscale configuration information and the configuration information of the message consumer itself. As an example, see Figure 2 , Figure 2 is a schematic diagram of another message processing method provided in an embodiment of the present application. The method can be applied to message consumers. Figure 2 As shown, the method may include but is not limited to the following steps:
[0057] Step S201: Determine the configuration information of the message consumer.
[0058] Specifically, determine the configuration information of the message consumer itself.
[0059] In the embodiment of the present application, the above configuration information may include but is not limited to version information.
[0060] Step S202: Obtain grayscale configuration information of network-side device configuration.
[0061] In the embodiment of the present application, the grayscale configuration information may include but is not limited to grayscale version information.
[0062] Step S203: according to the configuration information and grayscale configuration information of the message consumer, enable the corresponding first consumption service.
[0063] As an example, in response to the configuration information of the message consumer being the same as the grayscale configuration information, the message consumer enables the first consumption service corresponding to the grayscale consumption group, wherein the grayscale consumption group is a consumption group composed of grayscale consumers.
[0064] As another example, in response to the fact that the configuration information of the message consumer itself is different from the grayscale configuration information, the message consumer enables the first consumption service corresponding to the formal consumption group, wherein the formal consumption group is a consumption group composed of formal consumers.
[0065] In an optional implementation, the above-mentioned enabling of the corresponding first consumption service according to the configuration information and the grayscale configuration information of the message consumer may include the following steps:
[0066] a1: According to the configuration information and grayscale configuration information of the message consumer, determine the target consumer type from multiple consumer types; wherein each consumer type corresponds to a different consumer service.
[0067] As an example, take the case where the consumer types include formal consumers and grayscale consumers. If the configuration information of the message consumer is the same as the grayscale configuration information, it is determined that the target consumer type is a grayscale consumer.
[0068] As another example, the grayscale configuration information may include multiple grayscale version information. Take the grayscale configuration information including the first grayscale version information and the second grayscale version information as an example. If the configuration information of the message consumer is the same as the first grayscale version information, the target consumer type corresponding to the message consumer is determined to be the first grayscale consumer; if the configuration information of the message consumer is the same as the second grayscale version information, the target consumer type corresponding to the message consumer is determined to be the second grayscale consumer; if the configuration information of the message consumer is different from both the first grayscale version information and the second grayscale version information, the target consumer type corresponding to the message consumer is determined to be a formal consumer.
[0069] a2: Enable the first consumer service corresponding to the target consumer type and disable other consumer services.
[0070] As an example, taking the target consumer type as a formal consumer, the first consumption service corresponding to the formal consumer is enabled, which is a message service provided by the formal consumption group corresponding to the formal consumer, and consumption services provided by other consumption groups are disabled.
[0071] In an optional implementation, according to the configuration information and the grayscale configuration information of the message consumer, enabling the corresponding first consumption service includes:
[0072] b1: Get the current consumer type of the message consumer.
[0073] Specifically, the consumer type of the message consumer at the current moment is obtained as the current consumer type.
[0074] b2: Determine the target consumer type from multiple consumer types based on the configuration information of the message consumer and the grayscale configuration information.
[0075] b3: In response to the current consumer type being different from the target consumer type, determining the target consumer type as a new current consumer type.
[0076] As an example, if the current consumer type is a grayscale consumer and the target consumer type is a formal consumer, the formal consumer is determined as the new current consumer type.
[0077] b4: Enable the first consumer service corresponding to the target consumer type and disable other consumer services.
[0078] As an example, taking the target consumer type as a formal consumer, the first consumption service corresponding to the formal consumer is enabled, which is a message service provided by the formal consumption group corresponding to the formal consumer, and consumption services provided by other consumption groups are disabled.
[0079] Step S204: Obtain a to-be-processed message from the message queue based on the first consumption service.
[0080] In the embodiments of the present application, step S204 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0081] Step S205: Determine the message type of the message to be processed.
[0082] In the embodiments of the present application, step S205 can be implemented in any of the ways in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0083] Step S206: Obtain the consumer type of the message consumer.
[0084] In the embodiments of the present application, step S206 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0085] Step S207: Process the message to be processed based on the message type and the consumer type.
[0086] In the embodiments of the present application, step S207 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0087] By implementing the embodiment of the present application, the grayscale consumer can enable the corresponding first consumption service according to the grayscale configuration information and the configuration information of the message consumer itself. Thus, the grayscale configuration information can be configured more flexibly, so that the message consumer can switch the consumer type without downtime based on the grayscale configuration information.
[0088] In one implementation, the message type of the message to be processed may be determined based on information used to identify the message type in the message to be processed. As an example, see Figure 3 , Figure 3 is a schematic diagram of another message processing method provided in an embodiment of the present application. The method can be applied to message consumers. Figure 3 As shown, the method may include but is not limited to the following steps:
[0089] Step S301: Activate a first consumption service corresponding to a message consumer.
[0090] In the embodiments of the present application, step S301 can be implemented in any of the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0091] Step S302: Obtain a to-be-processed message from a message queue based on the first consumption service.
[0092] In an embodiment of the present application, the above-mentioned message to be processed includes a message type tag.
[0093] Step S303: Determine the message type of the message to be processed according to the message type tag.
[0094] Specifically, different message type tags may be pre-set for different message types. After receiving a message to be processed, a message consumer may identify the message type tag of the message to be processed to determine the message type of the message to be processed according to the identification result.
[0095] As an example, take the message type tag as a gray tag value. If the gray tag value of the message to be processed is true, the message to be processed is determined to be a gray message; if the gray tag value of the message to be processed is false, the message to be processed is determined to be a formal message.
[0096] As another example, take the message type tag as gray Tag value. If the gray Tag value of the message to be processed is 0, the message to be processed is determined to be a formal message; if the gray Tag value of the message to be processed is 1, the message to be processed is determined to be a first gray message; if the gray Tag value of the message to be processed is 2, the message to be processed is determined to be a second gray message.
[0097] Step S304: Process the message to be processed based on the message type and the consumer type.
[0098] In the embodiments of the present application, step S304 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0099] By implementing the embodiments of the present application, the message consumer can determine the message type of the message to be processed based on the information used to identify the message type in the message to be processed, and thus process the message to be processed accordingly based on the consumer type of the message consumer and the message type of the message to be processed. The separate processing of messages to be processed of different message types can be achieved to realize the logical grayscale of the message consumer, and the implementation cost is low.
[0100] In one implementation, the specific way in which a message consumer processes a pending message can be determined based on the consumer type of the message consumer and the message type of the pending message. Figure 4 , Figure 4 is a schematic diagram of another message processing method provided in an embodiment of the present application. The method can be applied to message consumers. Figure 4 As shown, the method may include but is not limited to the following steps:
[0101] Step S401: Activate a first consumption service corresponding to a message consumer.
[0102] In the embodiments of the present application, step S401 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0103] Step S402: Obtain a to-be-processed message from a message queue based on the first consumption service.
[0104] In the embodiments of the present application, step S402 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0105] Step S403: Determine the message type of the message to be processed.
[0106] In the embodiments of the present application, step S403 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0107] Step S404: Obtain the consumer type of the message consumer.
[0108] In the embodiments of the present application, step S404 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0109] Step S405: Based on the consumer type, determine the message type that the message consumer can process.
[0110] For example, each message consumer of a consumer type may be pre-specified to process messages of a message type, so that the message types that the message consumer can process may be determined based on the consumer type of the message consumer.
[0111] Step S406: In response to the message type of the to-be-processed message being the same as the message type that can be processed by the message consumer, the to-be-processed message is processed.
[0112] Specifically, in response to the message type of the to-be-processed message being the same as the message type that can be processed by the message consumer, the message consumer processes the to-be-processed message.
[0113] In some embodiments of the present application, when a message consumer has a downstream service, the message consumer can add a type tag to the processed pending messages. The type tag is used to identify the message type of the pending messages processed by the message consumer, so that the downstream service can use the messages processed by the message consumer.
[0114] As an example, after processing a grayscale message, a grayscale message consumer may add a type tag to the processed message, where the type tag is used to identify the processed message as a grayscale message.
[0115] By implementing the embodiments of the present application, a message consumer can determine a specific method for processing a pending message based on the consumer type of the message consumer and the message type of the pending message, thereby implementing isolated processing of pending messages of different message types, thereby realizing the logic grayscale of the message consumer, and the implementation cost is relatively low.
[0116] In one implementation, the message consumer can determine how to process pending messages based on the consumer type of the message consumer and the message type of the pending message. Figure 5 , Figure 5 is a schematic diagram of another message processing method provided in an embodiment of the present application. The method can be applied to message consumers. Figure 5 As shown, the method may include but is not limited to the following steps:
[0117] Step S501: Activate a first consumption service corresponding to a message consumer.
[0118] In the embodiments of the present application, step S501 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0119] Step S502: Obtain a to-be-processed message from a message queue based on the first consumption service.
[0120] In the embodiments of the present application, step S502 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0121] Step S503: Determine the message type of the message to be processed.
[0122] In the embodiments of the present application, step S503 can be implemented by any of the methods in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0123] Step S504: Obtain the consumer type of the message consumer.
[0124] In the embodiments of the present application, step S504 can be implemented in any of the ways in the embodiments of the present application, and the embodiments of the present application do not limit this and will not be described in detail.
[0125] Step S505: Based on the consumer type, determine the message type that the message consumer can process.
[0126] For example, each message consumer of a consumer type may be pre-specified to process messages of a message type, so that the message types that the message consumer can process may be determined based on the consumer type of the message consumer.
[0127] Step S506: In response to the message type of the to-be-processed message being different from the message type that the message consumer can process, the to-be-processed message is ignored.
[0128] Specifically, in response to the message type of the to-be-processed message being different from the message type that the message consumer can process, the consumer is ignored from processing the to-be-processed message.
[0129] By implementing the embodiments of the present application, a message consumer can determine a specific method for processing a pending message based on the consumer type of the message consumer and the message type of the pending message, thereby implementing isolated processing of pending messages of different message types, thereby realizing the logic grayscale of the message consumer, and the implementation cost is relatively low.
[0130] In the above-mentioned embodiments provided by the present application, the message processing method provided by the embodiments of the present application is introduced from the perspective of a message consumer. Next, the message processing method provided by the embodiments of the present application will be further introduced from the perspective of a message producer.
[0131] As an example, see Figure 6 , Figure 6 is a schematic diagram of another message processing method provided in an embodiment of the present application. This method can be applied to message producers. Figure 6 As shown, the method may include but is not limited to the following steps:
[0132] Step S601: Obtain request information.
[0133] In an embodiment of the present application, the request information includes an information type tag.
[0134] For example, the request information sent by the software platform is obtained, where the request information includes an information type tag that identifies the type of the request information.
[0135] Step S602: Generate a message to be processed according to the request information.
[0136] The message to be processed includes a message type tag for indicating the message type.
[0137] In an embodiment of the present application, the request information may include request identification information (eg, request ID (Identity document)).
[0138] For example, the message producer uses the request identification information of the request information as the specific value of key, and uses the information type tag of the request information as the specific value of value to generate a key-value pair, and stores the key-value pair in the local cache. Therefore, when it is necessary to process the pending message, a data message of the pending message is generated based on the request information, and the information type tag of the request information is obtained based on the request identification information of the request information, so as to generate a message type tag of the pending message based on the information tag, and add the message type tag to the data message, and delete the corresponding key-value pair in the local cache.
[0139] Among them, in the embodiment of the present application, the above-mentioned message type tag can be added to any part of the cookie, body or header of the data message.
[0140] Step S603: Provide the to-be-processed message to the message consumer through the message queue.
[0141] For example, a message producer pushes pending messages to a topic in KAFKA.
[0142] In an embodiment of the present application, a message consumer is used to process a message to be processed based on a consumer type and a message type of the message consumer.
[0143] It should be noted that in an embodiment of the present application, there may be multiple message producers, so that request information with different information type tags can be sent to different message producers, and different producers can generate to-be-processed messages of different message types based on the received request information.
[0144] As an example, take the case where the request information includes a formal request and a grayscale request, and the message producers include a formal message producer and a grayscale message producer. Through a pre-established software architecture, the request information with a formal information type tag can be sent to the formal message producer, and the request information with a grayscale information type tag can be sent to the grayscale message producer. Thus, the formal message producer can generate a formal message based on the received formal request information. The grayscale message producer can generate a grayscale message based on the received grayscale request. And the formal message producer and the grayscale message producer push the generated messages to the same message queue.
[0145] By implementing the embodiments of the present application, the message producer can generate a to-be-processed message of the corresponding message type based on the information type tag of the request information, thereby realizing the logical grayscale of the message producer with low implementation cost.
[0146] See also Figure 7 , Figure 7 Schematic diagram of a message processing solution provided by an embodiment of the present application. Figure 7 As shown, in this scheme, the formal message producer can receive formal request information and generate a formal message based on the formal request information. The grayscale message producer can receive grayscale request information and generate a grayscale message based on the grayscale request information. The formal message producer and the grayscale message producer push the generated messages to the same message queue.
[0147] When the message consumer is started, it obtains the grayscale configuration information through the network-side device, and compares the grayscale configuration information with its own configuration information to determine whether it is a grayscale consumer or a formal consumer based on the comparison results. If it is determined to be a formal message consumer, the service corresponding to the formal consumer group is started, and the service corresponding to the grayscale consumer group is closed. If it is determined to be a grayscale message consumer, the service corresponding to the grayscale consumer group is started, and the service corresponding to the formal consumer group is closed. In this way, the message consumer can obtain pending messages from the message queue through the corresponding consumer group. The message consumer can re-obtain the grayscale configuration information from the network-side device at regular intervals, and re-determine whether it is a formal message consumer or a grayscale message consumer according to the above steps, and start the service of the corresponding consumer group according to the determination result.
[0148] After the message consumer obtains the pending message, it can determine whether the pending message is a formal message or a grayscale message based on the tag information in the pending message. If the pending message is a formal message and the message consumer is a formal message consumer, the formal message consumer processes the formal message accordingly. If the pending message is a formal message and the message consumer is a grayscale message consumer, the grayscale message consumer ignores the formal message. This achieves the isolation of formal messages and grayscale messages.
[0149] See also Figure 8 , Figure 8 Schematic diagram of a message processing device provided in an embodiment of the present application. The device can be applied to message consumers. Figure 8 As shown, the device 800 includes: a first processing module 801, used to enable a first consumption service corresponding to a message consumer; wherein the first consumption service is a service provided by a consumption group currently corresponding to the message consumer; a first acquisition module 802, used to obtain a message to be processed from a message queue based on the first consumption service; a second processing module 803, used to determine a message type of the message to be processed; a second acquisition module 804, used to obtain a consumer type of the message consumer; and a third processing module 805, used to process the message to be processed based on the message type and the consumer type.
[0150] In one implementation, the first processing module 801 is specifically used to: determine the configuration information of the message consumer; obtain the grayscale configuration information of the network side device configuration; and enable the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information.
[0151] In an optional implementation, the first processing module 801 is specifically used to determine the target consumer type from multiple consumer types based on the configuration information and grayscale configuration information of the message consumer; wherein each consumer type corresponds to a different consumer service; enable the first consumer service corresponding to the target consumer type, and disable other consumer services.
[0152] In an optional implementation, the first processing module 801 is specifically used to obtain the current consumer type of the message consumer; determine the target consumer type from multiple consumer types based on the configuration information and grayscale configuration information of the message consumer; wherein each consumer type corresponds to a first consumption service; in response to the current consumer type being different from the target consumer type, determine the target consumer type as the new current consumer type; enable the first consumption service corresponding to the target consumer type, and disable other consumption services.
[0153] In one implementation, the second processing module 803 is specifically configured to: determine the message type of the message to be processed according to the message type tag.
[0154] In one implementation, the third processing module 805 is specifically used to: determine the message type that the message consumer can process based on the consumer type; and process the message to be processed in response to the message type of the message to be processed being the same as the message type that the message consumer can process.
[0155] In one implementation, the third processing module 805 is specifically used to: determine the message type that the message consumer can process based on the consumer type; and ignore the message to be processed in response to the message type of the message to be processed being different from the message type that the message consumer can process.
[0156] Through the device of the embodiment of the present application, the message consumer can obtain the pending message based on the enabled first consumption service, and thus process the pending message accordingly according to the consumer type of the message consumer and the message type of the pending message. It is possible to implement separate processing of pending messages of different message types to achieve the logical grayscale of the message consumer, and the implementation cost is low.
[0157] See also Fig. 9 , Fig. 9 Schematic diagram of another message processing device provided in an embodiment of the present application. The device is applied to a message producer. Fig. 9 As shown, the device 900 includes: an acquisition module 901, used to obtain request information; a processing module 902, used to generate a message to be processed according to the request information; wherein the message to be processed includes a message type tag; a push module 903, used to provide the message to be processed to a message consumer through a message queue, wherein the message consumer is used to process the message to be processed based on the consumer type and message type of the message consumer.
[0158] Through the device of the embodiment of the present application, the message producer can generate a to-be-processed message of the corresponding message type based on the information type tag of the request information, thereby realizing the logical grayscale of the message producer with low implementation cost.
[0159] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0160] The present application also provides a message processing system, which includes the above Figure 8 The message consumer in the embodiment and the aforementioned Fig. 9 A message producer in an embodiment.
[0161] Based on the embodiments of the present application, the present application also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message processing method of any of the aforementioned embodiments.
[0162] Based on the embodiments of the present application, the present application also provides a computer-readable storage medium, wherein computer instructions are used to enable a computer to execute the message processing method of any of the foregoing embodiments provided according to the embodiments of the present application.
[0163] See also Fig.10 ,like Fig.10 , is a schematic block diagram of an example electronic device that can be used to implement an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0164] like Fig.10 As shown, the device 1000 includes a computing unit 1001, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1002 or a computer program loaded from a storage unit 1008 to a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the device 1000 can also be stored. The computing unit 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0165] A number of components in the device 1000 are connected to the I / O interface 1005, including: an input unit 1006, such as a keyboard, a mouse, etc.; an output unit 1007, such as various types of displays, speakers, etc.; a storage unit 1008, such as a disk, an optical disk, etc.; and a communication unit 1009, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1009 allows the device 1000 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0166] The computing unit 1001 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1001 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSP), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1001 performs the various methods and processes described above, such as message processing methods. For example, in some embodiments, the message processing method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1008. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1000 via the ROM 1002 and / or the communication unit 1009. When the computer program is loaded into the RAM 1003 and executed by the computing unit 1001, one or more steps of the message processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1001 may be configured to execute the message processing method in any other appropriate manner (eg, by means of firmware).
[0167] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard parts (ASSPs), system on chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a dedicated or general programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0168] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0169] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0170] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a cathode ray tube (CRT) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0171] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN), the Internet, and blockchain networks.
[0172] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS (Virtual Private Server) services. The server may also be a server of a distributed system, or a server combined with a blockchain.
[0173] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in the present application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution of the present application can be achieved, and this document does not limit this.
[0174] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A message processing method, characterized in that: The method is applied to a message consumer, and the method comprises: Determining configuration information of the message consumer; Obtaining grayscale configuration information of a network-side device configuration, wherein the grayscale configuration information includes multiple grayscale version information; According to the configuration information of the message consumer and the grayscale configuration information, enable the corresponding first consumption service; wherein the first consumption service is a service provided by the consumption group currently corresponding to the message consumer; Obtaining a to-be-processed message from a message queue based on the first consumer service; Determine the message type of the message to be processed, wherein the message type includes a formal message and a grayscale message; Obtaining the consumer type of the message consumer, where the consumer type includes a formal consumer and a grayscale consumer; Based on the message type and the consumer type, processing the to-be-processed message; The enabling of the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information includes: Determine a target consumer type from a plurality of consumer types according to the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a different consumption service; The first consumer service corresponding to the target consumer type is enabled, and other consumer services are disabled.
2. The method according to claim 1, characterized in that The enabling of the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information also includes: Get the current consumer type of the message consumer; Determine a target consumer type from a plurality of consumer types according to the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a first consumption service; In response to the current consumer type being different from the target consumer type, determining the target consumer type as a new current consumer type; The first consumer service corresponding to the target consumer type is enabled, and other consumer services are disabled.
3. The method according to claim 1, characterized in that The message to be processed includes a message type tag, and determining the message type of the message to be processed includes: The message type of the message to be processed is determined according to the message type tag.
4. The method according to claim 1, characterized in that The processing of the to-be-processed message based on the message type and the consumer type includes: Based on the consumer type, determining the message type that the message consumer can process; In response to the message type of the to-be-processed message being the same as the message type processable by the message consumer, the to-be-processed message is processed.
5. The method according to claim 1, characterized in that The processing of the to-be-processed message based on the message type and the consumer type includes: Based on the consumer type, determining the message type that the message consumer can process; In response to the message type of the to-be-processed message being different from the message type that can be processed by the message consumer, the to-be-processed message is ignored.
6. A message processing method, characterized in that: The method is applied to a message producer, and the method comprises: Obtaining request information; wherein the request information includes an information type tag; Generate a message to be processed according to the request information; wherein the message to be processed includes a message type tag; The to-be-processed message is provided to a message consumer through a message queue, wherein the message consumer is used to process the to-be-processed message according to the message processing method according to any one of claims 1 to 5.
7. A message processing device, characterized in that: The device is applied to a message consumer, and the device comprises: A first processing module, configured to enable a first consumption service corresponding to the message consumer; wherein the first consumption service is a service provided by a consumption group currently corresponding to the message consumer; A first acquisition module, used to acquire a to-be-processed message from a message queue based on the first consumption service; A second processing module, configured to determine a message type of the message to be processed, wherein the message type includes a formal message and a gray message; A second acquisition module is used to acquire the consumer type of the message consumer, where the consumer type includes a formal consumer and a grayscale consumer; A third processing module, used for processing the to-be-processed message based on the message type and the consumer type; The enabling of a first consumption service corresponding to the message consumer includes: Determining configuration information of the message consumer; Obtaining grayscale configuration information of a network-side device configuration, wherein the grayscale configuration information includes multiple grayscale version information; According to the configuration information of the message consumer and the grayscale configuration information, enable the corresponding first consumption service; The enabling of the corresponding first consumption service according to the configuration information of the message consumer and the grayscale configuration information includes: Determine a target consumer type from a plurality of consumer types according to the configuration information of the message consumer and the grayscale configuration information; wherein each of the consumer types corresponds to a different consumption service; The first consumer service corresponding to the target consumer type is enabled, and other consumer services are disabled.
8. A message processing device, characterized in that: The device is applied to a message producer, and comprises: An acquisition module, used to acquire request information; wherein the request information includes an information type tag; A processing module, configured to generate a message to be processed according to the request information; wherein the message to be processed includes a message type tag; A push module, used to provide the pending message to a message consumer through a message queue, wherein the message consumer is used to process the pending message according to the message processing method as described in any one of claims 1 to 5.
9. A message processing system, characterized in that: include: A message consumer, configured to execute the method according to any one of claims 1 to 5; A message producer, configured to execute the method as claimed in claim 6.
10. An electronic device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message processing method described in any one of claims 1 to 5, or execute the message processing method described in claim 6.
11. A computer-readable storage medium for storing instructions, characterized in that: When the instructions are executed, the method according to any one of claims 1 to 5 is implemented, or the method according to claim 6 is implemented.
Citation Information
Patent Citations
Message queue configuration method and device, computer device and storage medium
CN110032459A
Internet of Things message processing method and device, electronic equipment and storage medium
CN115914346A