A method and apparatus for message processing
By determining the sending time of the service message in the message middleware, delaying the sending of the service message is realized, and real-time calculation indicators are triggered, the problem that the unreached messages in the prior art cannot be calculated in real time is solved, and the computing efficiency is improved and the cost is reduced.
Patent Information
- Application Number
- CN202210984554.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-08-17
AI Technical Summary
The existing technology is difficult to calculate unreached messages in real time and cannot effectively solve the problem of timeout statistics under massive data.
By sending the service message of the target service to the message middleware, it is enabled to determine the sending time of the service message when the service message has a preset identifier, thereby realizing the delayed transmission of the service message and triggering the calculation of the real-time calculation indicator.
Real-time statistics of unreached messages are realized, the calculation cost is reduced, the calculation rate is increased, and the timeout statistics problem under massive data is solved.
Smart Images

Figure CN115396434B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent medical technologies, and in particular, to a method and apparatus for message processing. Background Art
[0002] With the development of Internet technologies, intelligent electronic devices have been widely used in people's lives. In the field of big data technologies, a large amount of data is generated by using intelligent electronic devices. For the real-time statistics scenario of a large amount of data, the time for data synchronization is uncertain, and the time span for data statistics is relatively long. Therefore, the data timeout problem is a problem that needs to be solved in real-time statistics. However, the prior art is difficult to calculate unarrived messages and cannot solve the timeout statistics problem. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a method and apparatus for message processing, which can trigger the calculation of real-time calculation metrics by delaying the sending of service messages, realize real-time statistics of unarrived messages, reduce the calculation cost, improve the calculation rate, and can solve the timeout statistics problem under a large amount of data.
[0004] To achieve the above object, according to one aspect of the embodiments of the present invention, there is provided a method for a method and apparatus for message processing, including:
[0005] Sending a service message of a target service to a message middleware, so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric;
[0006] Receiving the service message sent by the message middleware when the sending time is reached;
[0007] Determining a calculation result corresponding to the real-time calculation metric according to the service message.
[0008] Optionally, the service message includes a processing time, and the sending time of the service message is determined by the message middleware according to the processing time and a delay duration.
[0009] Optionally, the delay duration is obtained by the message middleware from API setting parameters of the message middleware, or is obtained by the message middleware from delay configuration parameters of a topic corresponding to the service message.
[0010] Optionally, the message middleware includes a time wheel having a plurality of time slots. After sending a service message of a target service to the message middleware, the service message is stored by the message middleware in a time slot corresponding to the service message determined according to the sending time.
[0011] Optionally, determining a calculation result corresponding to the real-time calculation metric according to the service message includes:
[0012] Judging whether the target service meets the statistical rule of the real-time calculation metric according to the service message;
[0013] When the statistical rule is met, updating the calculation result corresponding to the real-time calculation metric.
[0014] Optionally, judging whether the target service meets the statistical rule of the real-time calculation metric according to the service message includes:
[0015] Judging whether the service node corresponding to the real-time calculation metric in the target service has been completed before the sending time;
[0016] When the node is not completed, determining that the target service meets the statistical rule of the real-time calculation metric.
[0017] According to still another aspect of the embodiments of the present invention, there is provided a message processing device, including:
[0018] A sending module that sends a service message of a target service to a message middleware, so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric;
[0019] A receiving module that receives the service message sent by the message middleware when the sending time is reached;
[0020] A determining module that determines a calculation result corresponding to the real-time calculation metric according to the service message.
[0021] According to still another aspect of the embodiments of the present invention, there is provided a message processing system, including: a message processing device and a message middleware;
[0022] The message processing device sends a service message of a target service to the message middleware;
[0023] After receiving the service message, the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier, and sends the service message to the message processing device when the sending time is reached, the preset identifier corresponding to a real-time calculation metric;
[0024] After receiving the service message sent by the message middleware when the sending time is reached, the message processing device determines a calculation result corresponding to the real-time calculation metric according to the service message.
[0025] According to another aspect of the embodiments of the present invention, an electronic device is provided, including:
[0026] One or more processors;
[0027] A storage device for storing one or more programs,
[0028] When the one or more programs are executed by the one or more processors, the one or more processors implement the message processing method provided by the present invention.
[0029] According to still another aspect of the embodiments of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the message processing method provided by the present invention is implemented.
[0030] One embodiment of the above invention has the following advantages or beneficial effects: By sending the service message of the target service to the message middleware, the message middleware determines the sending time of the service message when determining the preset identifier for storing the service message, so that the message middleware sends the service message when the sending time arrives, thereby realizing the delayed sending of the service message. After receiving the service message sent by the message middleware, the calculation of real-time calculation metrics is triggered to obtain a calculation result. This method can realize the real-time statistics of unarrived messages, save computing resources, reduce computing costs, improve computing speed, and can solve the timeout statistics problem under massive data.
[0031] The further effects of the above non-conventional optional manner will be described in conjunction with specific embodiments below. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The drawings are used to better understand the present invention and do not constitute an improper limitation to the present invention. Among them:
[0033] Figure 1 is a schematic diagram of the main process of a message processing method according to an embodiment of the present invention;
[0034] Figure 2 is a schematic diagram of the main process of another message processing method according to an embodiment of the present invention;
[0035] Figure 3 is a schematic diagram of the main process of still another message processing method according to an embodiment of the present invention;
[0036] Figure 4 is a schematic diagram of the main modules of a message processing device according to an embodiment of the present invention;
[0037] Figure 5 is an exemplary system architecture diagram to which the embodiments of the present invention can be applied;
[0038] Figure 6 It is a schematic structural diagram of a computer system of a terminal device or a server suitable for implementing the embodiments of the present invention. Detailed implementation manners
[0039] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings. Various details of the embodiments of the present invention are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted below.
[0040] Figure 1 It is a schematic diagram of the main process of a message processing method according to an embodiment of the present invention. As Figure 1 shown, the message processing method includes the following steps:
[0041] Step S101: Send the service message of the target service to the message middleware, so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric;
[0042] Step S102: Receive the service message sent by the message middleware when the sending time arrives;
[0043] Step S103: Determine the calculation result corresponding to the real-time calculation metric according to the service message.
[0044] In the embodiments of the present invention, the service message may include the detailed data of the target service. For example, if the target service is an order placement service, the service message may be a message including order data. The detailed data of the target service may be obtained by the data collection system and stored in a distributed file system after data sinking. The data collection system can obtain data such as logs and records from microservices, front-end services, imaging services, and web services, and can also obtain user behavior data from applications, applets, and IOT. It can be the health data of users, such as the order data for users to conduct online medical consultations and purchase medicines. The data collection system converts the collected data into messages, such as the service messages of the target service, and then pushes the service messages to the real-time calculation engine. For example, a Flink (a distributed processing engine for stream data and batch data) calculation engine is used for real-time calculation to summarize real-time calculation metrics. After receiving the service messages of the target service pushed by the data collection system, Flink sends the service messages to the message middleware.
[0045] Using the Flink big data computing engine can trigger the calculation of real-time computing metrics through the delayed sending of business messages when the business nodes have not been executed; and Flink has a perfect backpressure mechanism, which can ensure scenarios where the RPS is uncontrollable; when using Flink for real-time computing, it calculates using the processing time of business messages, which can well solve the problem of the order of business messages.
[0046] In the embodiment of the present invention, the message middleware can be kafka (a high-throughput distributed publish-subscribe message system). After the message middleware receives a business message, it determines whether the business message has a preset identifier, which corresponds to the real-time computing metrics, and determines whether the business message is a business message that needs to calculate real-time computing metrics. If the business message has a preset identifier, it means that the business message needs to participate in the calculation of real-time computing metrics, then the message middleware needs to delay the sending of the business message.
[0047] In the case where the message middleware determines that the business message is a business message that needs to be delayed for sending, it is necessary to determine the sending time of the business message. Specifically, the business message includes processing time, and the sending time of the business message is determined by the message middleware according to the processing time and the delay duration. Among them, the delay duration is determined according to the real-time computing metrics. For example, if the real-time computing metric is to count the number of orders that have not been picked up for delivery 1 hour after placing an order, the delay duration is 1 hour, and the sending time of the business message is to add 1 hour to the processing time. For example, if the business message is the order data placed at 14:00 and the delay duration is 1 hour, the sending time of the business message is 15:00.
[0048] In the embodiment of the present invention, the delay duration is obtained by the message middleware from the API setting parameters of the message middleware, or obtained by the message middleware from the delay configuration parameters of the topic corresponding to the business message. That is, the delay duration is set in the API setting parameters of the message middleware in advance, or the delay configuration parameters are set in the topic corresponding to the business message in advance, and the delay configuration parameters include the delay duration. By setting the delay time in the API setting parameters or the delay configuration parameters of the topic, the delayed sending or delayed reading of messages can be realized, thereby being able to solve the problem of a relatively large statistical span of data timeout.
[0049] In an embodiment of the present invention, the message middleware includes a time wheel with multiple time slots. After a service message of a target service is sent to the message middleware, the service message is stored by the message middleware in the time slot corresponding to the service message determined according to the sending time. That is, after the message middleware receives a service message with a preset identifier and determines the sending time of the service message, it stores the service message according to the sending time. Each time slot of the time wheel in the message middleware corresponds to a sending time, and the service message corresponding to the sending time is stored in the time slot corresponding to the sending time. That is, according to the sending time of the service message and the corresponding relationship between the sending time and the time slot, the time slot corresponding to the service message can be determined, and then the service message is stored in the corresponding time slot. When a certain sending time arrives, the service message in the time slot corresponding to the sending time is sent. Thus, the delayed sending of service messages can be achieved through the message middleware.
[0050] In an embodiment of the present invention, after receiving a service message that occurs when the message middleware reaches the sending time, as Figure 2 shown, determining a calculation result corresponding to a real-time calculation metric according to the service message includes:
[0051] Step S201: Determine whether the target service meets the statistical rule of the real-time calculation metric according to the service message;
[0052] Step S202: Update the calculation result corresponding to the real-time calculation metric when the statistical rule is met.
[0053] In an embodiment of the present invention, after receiving a service message sent by the message middleware, the calculation of the real-time calculation metric is triggered. It is necessary to determine whether the target service meets the statistical rule of the real-time calculation metric. If it meets, the calculation result corresponding to the real-time calculation metric is updated. If it does not meet, the calculation result is not updated. Among them, the statistical rule can be set according to the real-time calculation metric. For example, if the real-time calculation metric is the number of orders that have not been picked up for delivery 1 hour after placing an order, the statistical rule can be that the order has not been picked up for delivery 1 hour after placing an order.
[0054] In an embodiment of the present invention, as Figure 3 shown, determining whether the target service meets the statistical rule of the real-time calculation metric according to the service message includes:
[0055] Step S301: Determine whether the service node corresponding to the real-time calculation metric in the target service has been completed before the sending time;
[0056] Step S302: Determine that the target service meets the statistical rule of the real-time calculation metric when the service node is not completed.
[0057] In an embodiment of the present invention, for example, the real-time calculation indicator is the number of orders that have not been delivered or collected one hour after the order is placed. The target business and the business node corresponding to the real-time calculation indicator are the delivery and collection nodes. It is then determined whether the business node meets the statistical rules of the real-time statistical indicator, that is, whether the delivery and collection node has been completed within one hour of the order being placed, that is, before the time the business message is sent. If the business node is not completed, the statistical rules are met, that is, the calculation result of the real-time calculation indicator can be updated, such as by adding 1 to the calculation result.
[0058] In an embodiment of the present invention, the business message of the target business can be sent to the message middleware through the first task thread of the Flink computing engine, such as Flink job1, and the business message sent by the message middleware when the sending time is reached can be received through the second task thread of the Flink computing engine, such as Flinkjob2, thereby triggering the calculation of the real-time computing index. Flink job1 can also calculate the preset real-time index to obtain the calculation result of the preset index, and then Flink job2 can perform dual-stream aggregation of the calculation result of the real-time calculation index and the calculation result of the preset index obtained by Flink job1 to obtain the aggregation result.
[0059] When using Flink job2 to calculate real-time computing indicators, after receiving the business message sent by the message middleware, the time callback function corresponding to the real-time computing indicator, that is, the processing operator, is used to calculate the real-time computing indicator, obtain the business data of the target business, to determine whether the business node is completed, to obtain the calculation result, and store the calculation result in a database, such as Redis database, OLAP (Online Analytical Processing, online analytical processing query) database, ClickHouse (an open source column storage database with MPP architecture for online analytical processing query), etc., so that the data synchronization system can export the data and provide it to the business party for analysis or display. Among them, the storage of the entire business data of the target business depends on Flink's CheckPoint State (a snapshot of the data state at a certain moment).
[0060] The embodiment of the present invention adopts the Flink big data computing engine to achieve delayed sending of business messages through the message middleware when the business node is not executed, that is, the message has not arrived, so as to trigger the calculation of real-time computing indicators; and Flink has a complete back pressure mechanism, which can guarantee the scenario where RPS is uncontrollable; when Flink is used for real-time computing, the processing time of the business message is used for calculation, which can well solve the problem of the order of business messages.
[0061] The message processing method of the embodiment of the present invention can be applied to the field of intelligent medical technology. For example, users can access platforms (such as applications and mini-programs) that provide Internet medical services through intelligent electronic devices such as smartphones, smart bracelets, and smart watches to conduct online consultations. After the consultation, users can purchase drugs according to the prescription issued by the doctor. After the drug purchase is completed, a drug order is generated, and logistics distribution is carried out according to the drug order, and the logistics status of the drug order is monitored. For a large number of user intelligent electronic devices, a large number of drug orders will be generated. If it is necessary to count the number of overdue orders in real time, such as after the user completes the drug purchase and the warehouse ships, and in real time count the number of orders that have not been picked up for delivery for more than 1 hour, it can be achieved through the real-time data overdue statistics architecture of the smart city health. The real-time overdue statistics process is as follows: The data acquisition system obtains the message of the completion of shipment sent by the warehouse at 13:00 after receiving the message of the completion of the drug order sent by the intelligent electronic device; then the data acquisition system synchronizes the message sent at 13:00 in real time to the real-time computing engine of the task scheduling system, and Flink job1 in the real-time computing engine sends the message to kafka; Since it is necessary to perform real-time overdue statistics on the drug order, that is, it is necessary to determine whether the drug order is picked up for delivery 1 hour later, the time wheel in kafka is used to store the message in the time slot of the time wheel corresponding to 14:00; When it reaches 14:00, kafka sends the message to Flink job2; After receiving the message, Flink job2 determines whether the drug order is picked up for delivery according to the data collected by the data acquisition system corresponding to the drug order. If it is not picked up for delivery, the cumulative order quantity is incremented by 1. Through the real-time data overdue statistics architecture of the smart city health, it is possible to provide users with timely abnormal warnings, follow-up consultation reminders, data synchronization reminders, service follow-up, etc., so as to maximize the establishment of the user's health portrait, establish a relatively complete health database for users, and provide more timely and perfect health protection.
[0062] The message processing method provided by the embodiment of the present invention sends the business message with a preset identifier of the target business to the message middleware, so that the message middleware determines the sending time of the business message according to the processing time (EventTime, event time) and the delay time of the business message to delay the sending of the business message, so as to trigger the calculation of real-time calculation metrics after receiving the business message, so as to realize the update of real-time calculation metrics. This method uses the message middleware to realize the delayed sending of messages, and uses the Flink computing engine to trigger real-time statistics after receiving the messages, so that it can perform overdue statistics on unarrived messages, can solve the problem of overdue statistics under massive data, and can improve the calculation rate, save calculation costs and calculation resources by adopting this method.
[0063] Such as Figure 4As shown in the figure, another aspect of the embodiment of the present invention provides a message processing device 400, including:
[0064] A sending module 401 that sends the service message of the target service to the message middleware, so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric;
[0065] A receiving module 402 that receives the service message sent by the message middleware when the sending time arrives;
[0066] A determining module 403 that determines the calculation result corresponding to the real-time calculation metric according to the service message.
[0067] In the embodiment of the present invention, the service message includes a processing time, and the sending time of the service message is determined by the message middleware according to the processing time and the delay duration.
[0068] In the embodiment of the present invention, the delay duration is obtained by the message middleware from the API setting parameters of the message middleware, or is obtained by the message middleware from the delay configuration parameters of the topic corresponding to the service message.
[0069] In the embodiment of the present invention, the message middleware includes a time wheel with multiple time slots. After sending the service message of the target service to the message middleware, the service message is stored by the message middleware in the time slot corresponding to the service message determined according to the sending time.
[0070] In the embodiment of the present invention, the determining module 403 is further configured to: determine whether the target service meets the statistical rules of the real-time calculation metric according to the service message; and update the calculation result corresponding to the real-time calculation metric when the statistical rules are met.
[0071] In the embodiment of the present invention, the determining module 403 is further configured to: determine whether the service node corresponding to the real-time calculation metric in the target service has been completed before the sending time; and determine that the target service meets the statistical rules of the real-time calculation metric when the service node is not completed.
[0072] According to yet another aspect of the embodiment of the present invention, a message processing system is provided, including: a message processing device and a message middleware;
[0073] The message processing device sends the service message of the target service to the message middleware;
[0074] After receiving the service message, the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier, and sends the service message to the message processing device when the sending time arrives. The preset identifier corresponds to a real-time calculation metric;
[0075] After receiving the service message sent by the message middleware at the arrival time, the message processing device determines the calculation result corresponding to the real-time calculation metric according to the service message.
[0076] In an embodiment of the present invention, in the message processing system, the service message includes a processing time, and the message middleware determines the sending time of the service message according to the processing time and the extension duration. The delay duration is obtained by the message middleware from its API setting parameters, or is obtained by the message middleware from the delay configuration parameters of the topic corresponding to the service message.
[0077] In the message processing system, the message middleware includes a time wheel with multiple time slots. After determining the sending time of the service message, the message middleware stores the service message in the time slot corresponding to the service message determined according to the sending time.
[0078] In the message processing system, when the message processing device determines the calculation result corresponding to the real-time calculation metric according to the service message, it may include: judging whether the target service meets the statistical rule of the real-time calculation metric according to the service message; and updating the calculation result corresponding to the real-time calculation metric when the statistical rule is met. Further, judging whether the target service meets the statistical rule of the real-time calculation metric according to the service message includes: judging whether the service node corresponding to the real-time calculation metric in the target service has been completed before the sending time; and determining that the target service meets the statistical rule of the real-time calculation metric when the service node is not completed.
[0079] In an embodiment of the present invention, the message processing system further includes an offline calculation engine device, which can be implemented by using Hive (a data warehouse tool based on Hadoop) and Spark (a big data processing framework built around speed, ease of use, and complex analysis) to perform statistics of historical data and summary of metrics.
[0080] According to another aspect of the embodiments of the present invention, there is provided an electronic device, including: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the message processing method provided by the present invention.
[0081] According to still another aspect of the embodiments of the present invention, there is provided a computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the message processing method provided by the present invention is implemented.
[0082] Figure 5An exemplary system architecture 500 for a method of message processing or a device for message processing to which embodiments of the present invention can be applied is shown.
[0083] As Figure 5 shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0084] Users can use the terminal devices 501, 502, 503 to interact with the server 505 through the network 504 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0085] The terminal devices 501, 502, 503 may be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, and desktop computers, etc.
[0086] The server 505 may be a server providing various services, such as a background management server (only for example) that supports shopping websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process data such as product information query requests received, and feedback the processing results (such as target push information, product information - only for example) to the terminal devices.
[0087] It should be noted that the method of message processing provided by the embodiments of the present invention is generally executed by the server 505. Correspondingly, the device for message processing is generally set in the server 505.
[0088] It should be understood that Figure 5 the numbers of the terminal devices, the network, and the server in
[0089] are merely illustrative. According to actual needs, there may be any number of terminal devices, networks, and servers. Figure 6 are merely illustrative. According to actual needs, there may be any number of terminal devices, networks, and servers. Figure 6 The terminal device shown is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.
[0090] As Figure 6As shown, computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or programs loaded from a storage section 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0091] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is mounted on the drive 610 as needed so that a computer program read therefrom can be installed into the storage section 608 as needed.
[0092] Specifically, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowchart can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above functions defined in the system of the present invention are executed.
[0093] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0094] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0095] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, it can be described as: a processor includes a sending module, a receiving module, and a determining module. Among them, the names of these modules do not constitute a limitation to the module itself in some cases. For example, the receiving module can also be described as "receiving the service message sent by the message middleware when the sending time arrives".
[0096] As another aspect, the present invention also provides a computer-readable medium, which can be included in the device described in the above embodiments; or can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device includes: sending the service message of the target service to the message middleware so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric; receiving the service message sent by the message middleware when the sending time arrives; and determining the calculation result corresponding to the real-time calculation metric according to the service message.
[0097] According to the technical solution of the embodiments of the present invention, by sending the service message with a preset identifier of the target service to the message middleware, the message middleware determines the sending time of the service message according to the processing time and the delay time of the service message, so as to delay the sending of the service message, thereby triggering the calculation of the real-time calculation metric after receiving the service message, so as to realize the update of the real-time calculation metric. This method uses the message middleware to realize the delayed sending of messages, and uses the Flink computing engine to trigger real-time statistics after receiving the messages, so that it can perform timeout statistics on the unarrived messages, can solve the timeout statistics problem under massive data, and can improve the calculation rate and save the calculation cost and calculation resources by using this method.
[0098] The above specific embodiments do not limit the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for message processing, characterized in that, comprising: sending a service message of a target service to a message middleware, so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric; receiving the service message sent by the message middleware when the sending time is reached; determining a calculation result corresponding to the real-time calculation metric according to the service message; wherein, the service message includes a processing time, and the sending time of the service message is determined by the message middleware according to the processing time and a delay duration; determining a calculation result corresponding to the real-time calculation metric according to the service message includes: judging whether the target service meets the statistical rules of the real-time calculation metric according to the service message; and updating the calculation result corresponding to the real-time calculation metric when the statistical rules are met; judging whether the target service meets the statistical rules of the real-time calculation metric according to the service message includes: judging whether a service node corresponding to the real-time calculation metric in the target service has been completed before the sending time; and determining that the target service meets the statistical rules of the real-time calculation metric when the service node is not completed.
2. The method according to claim 1, characterized in that, the delay duration is obtained by the message middleware from the API setting parameters of the message middleware, or is obtained by the message middleware from the delay configuration parameters of the topic corresponding to the service message.
3. The method according to claim 1, characterized in that, the message middleware includes a time wheel with multiple time slots. After sending the service message of the target service to the message middleware, the service message is stored by the message middleware in a time slot corresponding to the service message determined according to the sending time.
4. A message processing device, characterized in that, comprising: a sending module, which sends a service message of a target service to a message middleware, so that the message middleware determines the sending time of the service message when it determines that the service message has a preset identifier; the preset identifier corresponds to a real-time calculation metric; a receiving module, which receives the service message sent by the message middleware when the sending time is reached; a determining module, which determines a calculation result corresponding to the real-time calculation metric according to the service message; wherein, the service message includes a processing time, and the sending time of the service message is determined by the message middleware according to the processing time and a delay duration; the determining module is further configured to: judge whether the target service meets the statistical rules of the real-time calculation metric according to the service message; and update the calculation result corresponding to the real-time calculation metric when the statistical rules are met; The determining module is further configured to: determine whether a service node corresponding to the real-time calculation metric in the target service has been completed before the sending time; and if the service node has not been completed, determine that the target service meets the statistical rule of the real-time calculation metric.
5. A message processing system, characterized in that it includes: the message processing device and the message middleware according to claim 4; the message processing device sends a service message of a target service to the message middleware; after receiving the service message, when determining that the service message has a preset identifier, the message middleware determines the sending time of the service message, and sends the service message to the message processing device when the sending time is reached, where the preset identifier corresponds to a real-time calculation metric; after receiving the service message sent by the message middleware when the sending time is reached, the message processing device determines a calculation result corresponding to the real-time calculation metric according to the service message; wherein, the service message includes a processing time, and the sending time of the service message is determined by the message middleware according to the processing time and a delay duration; the message processing device determines whether the target service meets the statistical rule of the real-time calculation metric according to the service message; and if the statistical rule is met, updates the calculation result corresponding to the real-time calculation metric; the message processing device determines whether a service node corresponding to the real-time calculation metric in the target service has been completed before the sending time; and if the service node has not been completed, determines that the target service meets the statistical rule of the real-time calculation metric.
6. An electronic device, characterized in that it includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the method according to any one of claims 1-3.
7. A computer-readable medium, on which a computer program is stored, characterized in that when the program is executed by a processor, it implements the method according to any one of claims 1-3.
Citation Information
Patent Citations
Message processing method and device
CN113064740A
Flow control method and device, electronic equipment and storage medium
CN113206797A