A method, device and equipment for checking and verifying consumption information of consumption system
By implementing a method of actively checking consumption messages in the message middleware system, the stability and consistency problems of the message middleware system in the existing technology are solved, the ability to quickly discover and deal with problems is achieved, and the troubleshooting time and log occupation are reduced.
Patent Information
- Application Number
- CN202310174102.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-23
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2043-02-23
AI Technical Summary
The prior art has problems such as system stability reduction, distributed consistency, repeated message consumption, message loss, and unguaranteed message delivery order in the message middleware system, and lacks active verification and alarm mechanisms, resulting in lagging problem investigation.
Provide a method to check and verify the messages consumed by the consumption system. By starting the consumption program, initializing the relevant variables, pulling the messages from the message middleware for business processing, and checking the number of messages and the number of business processes within the preset inspection cycle. The consistency will be actively checked, and if there is any inconsistency, an alarm will be processed.
It realizes the ability to proactively discover problems, reduces the inability to locate problems caused by log deletion, shortens the time interval between the occurrence of problems and the intervention of troubleshooters, and supports regular and routine verification behaviors and active alarms for message loss.
Smart Images

Figure CN116541182B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software development, and in particular to a method, device and equipment for checking and verifying consumption messages of a consumption system. Background Art
[0002] Message middleware is suitable for distributed environments that require reliable data transmission. In a system that uses the message middleware mechanism, different objects activate each other's events by passing messages to complete corresponding operations.
[0003] While message middleware has advantages such as decoupling and peak load shaving, it also brings some inevitable disadvantages, such as reduced system stability, distributed consistency, repeated message consumption, message loss, unguaranteed message delivery order, partial success and partial failure of multiple system consumption, data inconsistency, etc. In order to ensure the consistency of data consumption, it is necessary to check the number of consumption items and the number of business processing items. Currently, after the relevant personnel raise the issue, a remedial investigation is often carried out based on the log and business order number, so a verification solution is needed to replace manual investigation.
[0004] The evaluation of the pros and cons of the verification mechanism solution is mainly based on whether the solution can proactively discover problems in a timely manner, and whether it can conveniently and quickly use the alarm information to conduct subsequent investigations and remedial measures such as re-consumption after the problems are discovered. Conventional verification solutions have the following disadvantages:
[0005] 1. After receiving the relevant questions, the troubleshooter may find that the required logs have been deleted and cannot locate the problem;
[0006] 2. It does not support regular and routine verification;
[0007] 3. It does not support the active alarm function for message loss. It only provides passive remediation and troubleshooting, which has a certain lag.
[0008] 4. The metadata related information (offset, partition, etc.) of the consumed messages is not recorded, and remedial measures such as re-consuming related messages cannot be quickly performed when problems are found;
[0009] 5. It does not support basic statistical analysis based on existing log information. Summary of the invention
[0010] The present invention provides a method, device and equipment for checking and verifying consumption messages of a consumption system, which solves the above-mentioned problem.
[0011] A method for checking and verifying consumption messages of a consumption system, comprising:
[0012] Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on the relevant variables based on the business processing results;
[0013] Determine whether an abnormality occurs during the business processing;
[0014] If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing;
[0015] If the current inspection cycle is over, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on the relevant variables, and if they are inconsistent, an alarm is issued;
[0016] After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
[0017] In one embodiment of the present invention, after starting the consumer program, the method further includes: recording the offset of the first message pulled from the message middleware in the current inspection cycle as the initial message offset; initializing the business processing number array, and determining the business scenario corresponding to each element in the business processing number array; the business processing number array is a one-dimensional array; initializing the inspection counter; and initializing the preset inspection cycle step.
[0018] In one embodiment of the present invention, the corresponding calculation of the relevant variables according to the business processing results specifically includes: determining the business scenario to which the currently processed message belongs, accumulating the values of the array elements corresponding to the business scenario in the business processing number array according to the processing result of the current message; and accumulating the check counter.
[0019] In one embodiment of the present invention, the consistency of the number of messages processed in the current inspection cycle and the number pulled from the message middleware is determined based on the relevant variables, specifically including: obtaining the current message offset, and calculating the offset difference between the current message offset and the initial message offset; calculating the sum of the values of each element in the business processing number array as the cumulative value of processed messages in the current inspection cycle; comparing the offset difference with the cumulative value of processed messages, and if the two are equal, it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware.
[0020] In one embodiment of the present invention, the determination of whether an abnormality occurs during the business processing specifically includes: if an abnormality occurs, initiating alarm processing; sending an alarm message to a relevant responsible person, the alarm message including an initial message offset, a current message offset and an array of business processing numbers; ending the current inspection cycle, recording the alarm message in a log and entering the next inspection cycle.
[0021] In one embodiment of the present invention, the determination of whether the current inspection cycle has ended specifically includes: determining the value of the inspection counter in the current inspection cycle, and comparing the value of the inspection counter with a preset inspection cycle step; if the value of the inspection counter is equal to the inspection cycle step, determining that the current inspection cycle has ended.
[0022] In one embodiment of the present invention, the ending of the current inspection cycle, updating related variables and entering the next inspection cycle specifically include: when the alarm processing is completed or when it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware, ending the current inspection cycle and recording the alarm information or information identical to the alarm information in the log; updating the initial message offset and the current message offset; clearing the business processing number array and the inspection counter; and entering the next inspection cycle.
[0023] A device for checking and verifying consumption messages of a consumption system, comprising:
[0024] The business processing module is used to start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing according to the pulled messages, and perform corresponding calculations on the relevant variables according to the business processing results;
[0025] A judgment module, used to judge whether an exception occurs during the business processing; if no exception occurs, judge whether the current inspection cycle is over, if the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; if the current inspection cycle is over, judge the consistency of the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware according to the relevant variables, and if they are inconsistent, perform alarm processing;
[0026] The updating module is used to end the current inspection cycle, update the related variables and enter the next inspection cycle after the alarm processing is completed.
[0027] A device for checking and verifying consumption messages of a consumption system, comprising:
[0028] at least one processor; and,
[0029] A memory connected to the at least one processor via a bus; wherein,
[0030] The memory stores instructions executable by the at least one processor, and the instructions are executed to implement:
[0031] Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on the relevant variables based on the business processing results;
[0032] Determine whether an abnormality occurs during the business processing;
[0033] If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing;
[0034] If the current inspection cycle is over, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on the relevant variables, and if they are inconsistent, an alarm is issued;
[0035] After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
[0036] A non-volatile storage medium stores computer executable instructions, wherein the computer executable instructions are executed by a processor to implement the following steps:
[0037] Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on the relevant variables based on the business processing results;
[0038] Determine whether an abnormality occurs during the business processing;
[0039] If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing;
[0040] If the current inspection cycle is over, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on the relevant variables, and if they are inconsistent, an alarm is issued;
[0041] After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
[0042] The present invention provides a method, device and equipment for checking and verifying consumption messages of a consumption system, which at least have the following beneficial effects:
[0043] 1. Active discovery. Regularly and proactively checking the pulled messages and business processing messages instead of passively waiting to discover problems can greatly reduce the number of cases where logs are deleted and the situation where the problem cannot be located, and shorten the time interval between the occurrence of the problem and the intervention of the troubleshooter.
[0044] 2. The timeliness of problem discovery can be controlled. The timeliness of problem discovery can be controlled by modifying the step length of the inspection cycle. For systems that are not sensitive to timeliness, the step length can be appropriately increased to reduce the overall number of inspections; for systems that are sensitive to timeliness, the step length can be appropriately reduced. In extreme cases, the step length is 1, that is, each message is checked for processing.
[0045] 3. Record the metadata of the message middleware. By recording the metadata of the message middleware, a convenient basis is provided for subsequent re-consumption in case of abnormal or lost message business processing (the message middleware supports the consumption mode of specifying the offset).
[0046] 4. Record business processing metadata. By recording business processing metadata, you can regularly analyze the distribution of messages consumed from the message middleware after they pass through business processing, and support statistics and analysis of the time dimension + business dimension.
[0047] 5. Reduce log printing. Only log printing at special time points (such as the end of the inspection cycle, consumer program exceptions, etc.) can greatly reduce the amount of logs for consumer programs, reduce disk usage and I / O (input and output) pressure. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0049] Figure 1 A schematic diagram of the steps of a method for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention;
[0050] Figure 2 A schematic diagram of a process for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention;
[0051] Figure 3 A schematic diagram of a device for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention;
[0052] Figure 4 A schematic diagram of a device for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be described clearly and completely in conjunction with the specific embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] It should be noted that it is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in the present invention can be combined with other embodiments without conflict. Unless otherwise defined, the technical terms or scientific terms involved in the present invention should be the usual meanings understood by people with ordinary skills in the technical field to which the present invention belongs. The words "one", "a", "a", "the" and the like involved in the present invention do not indicate a quantitative limitation and may represent the singular or plural. The terms "including", "comprising", "having" and any of their variations involved in the present invention are intended to cover non-exclusive inclusions; the terms "first", "second", "third", etc. involved in the present invention are merely to distinguish similar objects and do not represent a specific ordering of objects.
[0055] Currently, there is no solution that can support the overall dynamic real-time verification of consumption and business processing numbers. Often, after relevant personnel raise questions, a remedial investigation is conducted based on logs and business order numbers. This solution is not a coordinated proactive verification solution. This investigation and positioning method that relies on reports from downstream systems has a certain data delay, which is not allowed in specific business scenarios.
[0056] The present invention provides a method, device and equipment for checking and verifying consumption messages of a consumption system. The core point is to proactively and timely discover the problem of message inequality by recording message middleware metadata and business processing metadata and performing periodic (check cycle step length is configurable) comparison, thereby notifying the relevant responsible persons through alarms and other means, and performing simple statistical analysis based on this recorded information. The following is a specific description.
[0057] Figure 1 A schematic diagram of a method for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention may include the following steps:
[0058] S110: Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing according to the pulled messages, and perform corresponding calculations on relevant variables according to the business processing results.
[0059] In one embodiment of the present invention, after starting the consumer program, relevant variables are initialized, specifically including: recording the offset of the first message pulled from the message middleware in the current inspection cycle as the initial message offset; initializing the business processing number array, and determining the business scenario corresponding to each element in the business processing number array; the business processing number array is a one-dimensional array; initializing the inspection counter; and initializing the preset inspection cycle step.
[0060] Specifically, Figure 2 The figure shows a flow chart of a scheme for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention. When the consumption program starts, the initial message offset (initialOffset) of the first message pulled from the message middleware is recorded; the business processing number array processedCount[] is initialized, and the length of the business processing number array is the number of business scenarios corresponding to each message processed by the consumer application, which is convenient for recording how many messages correspond to each business scenario in the current inspection cycle (inspection cycle step length stepLength); the sum of the processedCount[] array elements is determined to be the cumulative value of processed messages in the current inspection cycle (processedSum); the inspection counter (stepCount) is determined to record the number of messages that have been iteratively processed in the current inspection cycle; the inspection cycle step length stepLength is preset, and the inspection cycle is controlled by comparing stepCount and stepLength to support regular and routine verification behavior.
[0061] In one embodiment of the present invention, relevant variables are calculated accordingly according to the business processing results, specifically including: determining the business scenario to which the currently processed message belongs, accumulating the values of array elements corresponding to the business scenario in the business processing number array according to the processing results of the current message; and accumulating the check counter.
[0062] Specifically, pull the message from the message middleware and perform corresponding business processing. Accumulate the corresponding array elements in processedCount[] according to the current message processing result and the business scenario to which the message belongs; after each business processing is completed, check the counter (stepCount) to accumulate.
[0063] S120: Determine whether an abnormality occurs during the business processing.
[0064] In one embodiment of the present invention, it is determined whether an abnormality occurs during business processing, specifically including: if an abnormality occurs, alarm processing is initiated; an alarm message is sent to a relevant responsible person, the alarm message including an initial message offset, a current message offset and an array of business processing numbers; the current inspection cycle ends, the alarm message is recorded in a log and then the next inspection cycle begins.
[0065] Specifically, during the business processing process, it is necessary to determine whether an exception occurs in the message pulled back from the message middleware during the current business processing process. If an exception occurs, an alarm is processed and the message middleware metadata (such as initialOffset, currentOffset, etc.), business processing metadata (such as processedCount[], processedSum, etc.) and other information are sent to the operation and maintenance and project team related staff for timely intervention.
[0066] Through proactive and timely alarm processing, it supports active alarm function for message loss, avoiding the problem of certain lag caused by only passive remedial troubleshooting.
[0067] By recording the metadata of the message middleware (such as offset, partition, etc.), remedial measures such as re-consumption of related messages can be quickly taken in the event of abnormal or lost message business processing, providing a convenient basis for subsequent re-consumption (the message middleware supports the consumption mode of specifying the offset).
[0068] By recording business processing metadata, we can regularly analyze the distribution of messages consumed from the message middleware after they pass through business processing, and support statistical analysis in dimensions such as time and business.
[0069] S130: If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing.
[0070] In one embodiment of the present invention, determining whether the current inspection cycle is over specifically includes: determining the value of the inspection counter in the current inspection cycle, and comparing the value of the inspection counter with a preset inspection cycle step; if the value of the inspection counter is equal to the inspection cycle step, determining that the current inspection cycle is over.
[0071] Specifically, if no exception occurs, check whether stepCount is equal to stepLength to determine whether the current check cycle is full. After the current check cycle ends, it is necessary to check the number of messages currently processed and the messages pulled from the message middleware to ensure that the message consumption process is correct and log it.
[0072] By setting the step length of the inspection cycle stepLength and regularly actively comparing rather than passively waiting to find problems, the situation where logs are deleted and the location cannot be located can be greatly reduced, and the time interval between the occurrence of the problem and the intervention of the troubleshooter can be shortened. stepLength can be modified according to actual needs. By modifying stepLength, the timeliness of problem discovery can be controlled. For systems that are not sensitive to timeliness, stepLength can be appropriately increased to reduce the overall number of inspections and verifications; for systems that are sensitive to timeliness, stepLength can be appropriately reduced. In extreme cases, stepLength is 1, that is, each message is checked and verified after business processing.
[0073] S140: If the current inspection cycle ends, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on relevant variables. If they are inconsistent, an alarm is issued.
[0074] In one embodiment of the present invention, the consistency of the number of messages processed in the current inspection cycle and the number pulled from the message middleware is determined based on relevant variables, specifically including: obtaining the current message offset, calculating the offset difference between the current message offset and the initial message offset; calculating the sum of the values of each element in the business processing number array as the cumulative value of processed messages in the current inspection cycle; comparing the offset difference with the cumulative value of processed messages, and if the two are equal, it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware.
[0075] Specifically, after the inspection cycle is over, the processed message cumulative value processedSum is compared with the difference between currentOffset and initialOffset to determine whether each message pulled from the message middleware in the current inspection cycle has been processed accordingly.
[0076] If it is determined that the number of messages processed in the current inspection cycle is inconsistent with the number of messages pulled from the message middleware, an alarm is processed and alarm information such as message middleware metadata and business processing metadata are sent to operation and maintenance and project team-related staff for timely intervention.
[0077] If it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware, no alarm processing is performed, but the same information as the above alarm information needs to be recorded in the log.
[0078] By only recording logs at special time points (such as the end of the current inspection cycle, abnormalities in the consumer program, etc.), we avoid the large amount of resources occupied by logging every time the business processing is completed, greatly reduce the amount of logs in the consumer program, and alleviate disk usage and I / O (input / output) pressure.
[0079] S150: After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
[0080] In one embodiment of the present invention, the current inspection cycle is ended, relevant variables are updated and the next inspection cycle is entered, which specifically includes: when the alarm processing is completed or it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware, the current inspection cycle is ended, and the alarm information or information identical to the alarm information is recorded in the log; the initial message offset and the current message offset are updated; the business processing number array and the inspection counter are cleared; and the next inspection cycle is entered.
[0081] Specifically, there are three ways to end the current inspection cycle:
[0082] 1. No exceptions occur during business processing during the current inspection cycle and the number of processed messages is equal to the number of messages pulled from the message middleware.
[0083] 2. If no exception occurs during business processing in the current inspection cycle, but the number of processed messages is not equal to the number of messages pulled from the message middleware, an alarm will be processed and the next cycle will be entered.
[0084] 3. If an exception occurs during business processing within the current inspection cycle, an alarm will be processed and the next cycle will be entered.
[0085] At the end of the current inspection cycle, the corresponding inspection and verification actions or abnormal alarm actions in business processing have been completed. Before entering the next inspection cycle, the relevant variable information (that is, the execution status in the inspection cycle that is about to end) needs to be recorded in the log to facilitate some basic statistics and analysis based on the existing log information later; the initial message offset initialOffset of the new inspection cycle is assigned to the offset currentOffset of the last message of the previous inspection cycle, and the processedount[] array and stepCount are cleared. After the above actions are completed, enter the next round of new inspection cycle.
[0086] The above is a method for checking and verifying consumption messages of a consumption system provided by an embodiment of the present invention. Based on the same inventive idea, an embodiment of the present invention also provides a corresponding device for checking and verifying consumption messages of a consumption system, such as Figure 3 shown.
[0087] The business processing module 302 is used to start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on relevant variables based on the business processing results; the judgment module 304 is used to judge whether an exception occurs during the business processing; if no exception occurs, judge whether the current inspection cycle is over, if the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; if the current inspection cycle is over, judge the consistency of the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware based on relevant variables, if they are inconsistent, perform alarm processing; the update module 306 is used to end the current inspection cycle after the alarm processing is completed, update relevant variables and enter the next inspection cycle.
[0088] The embodiment of the present invention also provides a corresponding device for checking and verifying consumption messages of a consumption system, such as Figure 4 As shown, including:
[0089] At least one processor 402, a communication interface 404, a memory 406, and a communication bus 408; wherein the processor 402, the communication interface 404, and the memory 406 communicate with each other through the communication bus 408; the processor 402 may call the logic instructions stored in the memory 406, so that at least one processor 402 executes:
[0090] Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and calculate relevant variables accordingly based on the business processing results; determine whether an exception occurs during the business processing; if no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; if the current inspection cycle is over, determine the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware based on relevant variables. If they are inconsistent, perform alarm processing; after the alarm processing is completed, end the current inspection cycle, update relevant variables and enter the next inspection cycle.
[0091] Based on the same idea, some embodiments of the present invention also provide a medium corresponding to the above method.
[0092] Some embodiments of the present invention provide a storage medium storing computer executable instructions, wherein the computer executable instructions are executed by a processor to implement the following steps:
[0093] Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and calculate relevant variables accordingly based on the business processing results; determine whether an exception occurs during the business processing; if no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; if the current inspection cycle is over, determine the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware based on relevant variables. If they are inconsistent, perform alarm processing; after the alarm processing is completed, end the current inspection cycle, update relevant variables and enter the next inspection cycle.
[0094] The various embodiments of the present invention are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0095] The devices and media provided in the embodiments of the present invention correspond one-to-one to the methods, and therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0096] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or method. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or method including the elements.
[0097] The above are only embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail above with general descriptions and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made on the basis of the present invention. Therefore, these modifications or improvements made on the basis of not departing from the spirit of the present invention all belong to the scope of protection claimed in the present invention.
Claims
1. A method for checking and verifying consumption messages of a consumption system, characterized in that: include: Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on the relevant variables based on the business processing results; The initialization of related variables specifically includes: recording the offset of the first message pulled from the message middleware in the current inspection cycle as the initial message offset; initializing the business processing number array, determining the business scenario corresponding to each element in the business processing number array; the business processing number array is a one-dimensional array; initializing the inspection counter; initializing the preset inspection cycle step; The performing corresponding calculations on the relevant variables according to the business processing results specifically includes: determining the business scenario to which the currently processed message belongs, accumulating the values of the array elements corresponding to the business scenario in the business processing number array according to the processing result of the current message; accumulating the check counter; Determine whether an abnormality occurs during the business processing; If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; If the current inspection cycle is over, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on the relevant variables, and if they are inconsistent, an alarm is issued; After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
2. The method according to claim 1, characterized in that The step of judging the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware according to the relevant variables specifically includes: Obtaining a current message offset, and calculating an offset difference between the current message offset and the initial message offset; Calculate the sum of the values of each element in the business processing number array as the cumulative value of processed messages in the current inspection cycle; The offset difference is compared with the accumulated value of processed messages. If the two are equal, it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware.
3. The method according to claim 1, characterized in that The determining whether an abnormality occurs during the business processing specifically includes: If an abnormality occurs, the alarm process is initiated; Sending warning information to relevant responsible persons, wherein the warning information includes an initial message offset, a current message offset and an array of business processing numbers; End the current inspection cycle, record the alarm information in the log and enter the next inspection cycle.
4. The method according to claim 1, characterized in that: The determining whether the current inspection cycle is finished specifically includes: Determine the value of the inspection counter in the current inspection cycle, and compare the value of the inspection counter with a preset inspection cycle step; If the value of the inspection counter is equal to the inspection cycle step length, it is determined that the current inspection cycle is ended.
5. The method according to claim 1, characterized in that: The process of ending the current inspection cycle, updating relevant variables and entering the next inspection cycle specifically includes: When the alarm processing is completed or when it is determined that the number of messages processed in the current inspection cycle is consistent with the number of messages pulled from the message middleware, the current inspection cycle is ended, and the alarm information or information identical to the alarm information is recorded in the log; Update the initial message offset and current message offset; Clear the business processing number array and the check counter; Enter the next inspection cycle.
6. A device for checking and verifying consumption messages of a consumption system, characterized in that: include: The business processing module is used to start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing according to the pulled messages, and perform corresponding calculations on the relevant variables according to the business processing results; the initialization of relevant variables specifically includes: recording the offset of the first message pulled from the message middleware in the current inspection cycle as the initial message offset; initializing the business processing number array, and determining the business scenario corresponding to each element in the business processing number array; the business processing number array is a one-dimensional array; initializing the inspection counter; initializing the preset inspection cycle step; the corresponding calculations on the relevant variables according to the business processing results specifically include: determining the business scenario to which the currently processed message belongs, and accumulating the values of the array elements corresponding to the business scenario in the business processing number array according to the processing result of the current message; accumulating the inspection counter; A judgment module, used to judge whether an exception occurs during the business processing; if no exception occurs, judge whether the current inspection cycle is over, if the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; if the current inspection cycle is over, judge the consistency of the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware according to the relevant variables, and if they are inconsistent, perform alarm processing; The updating module is used to end the current inspection cycle, update the related variables and enter the next inspection cycle after the alarm processing is completed.
7. A device for checking and verifying consumption messages of a consumption system, characterized in that: include: at least one processor; as well as, A memory connected to the at least one processor via a bus; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed to implement: Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on the relevant variables based on the business processing results; The initialization of related variables specifically includes: recording the offset of the first message pulled from the message middleware in the current inspection cycle as the initial message offset; initializing the business processing number array, determining the business scenario corresponding to each element in the business processing number array; the business processing number array is a one-dimensional array; initializing the inspection counter; initializing the preset inspection cycle step; The performing corresponding calculations on the relevant variables according to the business processing results specifically includes: determining the business scenario to which the currently processed message belongs, accumulating the values of the array elements corresponding to the business scenario in the business processing number array according to the processing result of the current message; accumulating the check counter; Determine whether an abnormality occurs during the business processing; If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; If the current inspection cycle is over, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on the relevant variables, and if they are inconsistent, an alarm is issued; After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
8. A non-volatile storage medium storing computer executable instructions, characterized in that: The computer executable instructions are executed by a processor to implement the following steps: Start the consumer program, initialize relevant variables, pull messages from the message middleware, perform business processing based on the pulled messages, and perform corresponding calculations on the relevant variables based on the business processing results; The initialization of related variables specifically includes: recording the offset of the first message pulled from the message middleware in the current inspection cycle as the initial message offset; initializing the business processing number array, determining the business scenario corresponding to each element in the business processing number array; the business processing number array is a one-dimensional array; initializing the inspection counter; initializing the preset inspection cycle step; The performing corresponding calculations on the relevant variables according to the business processing results specifically includes: determining the business scenario to which the currently processed message belongs, accumulating the values of the array elements corresponding to the business scenario in the business processing number array according to the processing result of the current message; accumulating the check counter; Determine whether an abnormality occurs during the business processing; If no exception occurs, determine whether the current inspection cycle is over. If the current inspection cycle is not over, continue to pull messages from the message middleware for business processing; If the current inspection cycle is over, the consistency between the number of messages processed in the current inspection cycle and the number of messages pulled from the message middleware is determined based on the relevant variables, and if they are inconsistent, an alarm is issued; After the alarm processing is completed, the current inspection cycle ends, the relevant variables are updated and the next inspection cycle begins.
Citation Information
Patent Citations
Monitoring method of message-oriented middleware and related equipment
CN110213068A
Stable high-throughput asynchronous task processing method based on kafka
CN110377486A
Message consumption method and device, computer equipment and storage medium
CN115202898A