Data processing method, device, system, electronic device and storage medium

By performing pre-processing, pre-storage and pre-reporting operations in the data consumption queue, and restoring to the state before reading in case of failure, the problem of repeated data consumption caused by consumer device abnormalities is solved, and the atomicity and atomicity of data processing are achieved. Integrity.

CN112181686BActive Publication Date: 2024-09-06BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202011039859.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-28
Publication Date
2024-09-06
Estimated Expiration
2040-09-28

AI Technical Summary

Technical Problem

An exception occurred after the consumer device stored the read data and the offset was not committed, causing the problem of repeated data consumption.

Method used

Read the data to be processed in the preset data consumption queue, and perform pre-processing, pre-storage and pre-report offset operations. If any operation fails, it will be restored to the state before reading to ensure the atomicity of data consumption.

Benefits of technology

It avoids the problems of data loss and repeated consumption, ensures the atomicity of the data processing process, and avoids exceptions caused by automatic offset submission and manual offset submission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112181686B
    Figure CN112181686B
Patent Text Reader

Abstract

Embodiments of the present invention provide a data processing method, device, system, electronic device and storage medium. The method includes: reading the data to be processed in a preset data consumption queue, executing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed and a third preprocessing operation for pre-reporting an offset, and when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, restoring the data state to the state before reading the data to be processed from the preset data consumption queue. In an embodiment of the present invention, when at least one of the first, second and third preprocessing operations fails to execute, the entire first, second and third preprocessing operations fail, so that the data consumption process satisfies atomicity, avoiding data loss caused by the use of the automatic submission offset method and the problem of repeated consumption of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device, system, electronic equipment and storage medium. Background Art

[0002] Currently, producer devices can send produced data to a Kafka message queue to store the data through the Kafka message queue. In addition, consumer devices can obtain data from the Kafka consumer queue for consumption. Among them, the Kafka message queue is a high-throughput distributed publish / subscribe message queue.

[0003] In addition, the consumer device can be configured to submit the offset corresponding to the read data to the Kafka consumer queue after successfully writing the read data, that is, manually submit the offset to inform the Kafka consumer queue of the location of the data that the consumer device has read.

[0004] The inventors found in the process of implementing the present invention that the consumer device may have the following situation: an exception occurs after storing the read data A (for example, the consumer device crashes), but the offset corresponding to the data A is not submitted. In this case, when the consumer device returns to normal, the data A will be read and stored from the Kafka consumption queue again, which will cause repeated consumption of data A. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a data processing method, device, system, electronic device and storage medium to prevent consumer devices from losing data when an abnormality occurs. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a data processing method, the method comprising:

[0007] Read the data to be processed in the preset data consumption queue;

[0008] Performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0009] When at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, the data state is restored to a state before the to-be-processed data is read from the preset data consumption queue.

[0010] Optionally, the method further comprises:

[0011] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the first preprocessing operation, the storage of the data to be processed is completed based on the second preprocessing operation, and the reporting of the offset is completed based on the third preprocessing operation.

[0012] Optionally, the performing of a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset includes:

[0013] Allocating a first service resource for a first preprocessing operation for preprocessing the data to be processed, the first service resource comprising a computing resource and a cache resource; performing the first preprocessing operation using the first service resource to obtain a preprocessing result of the data to be processed;

[0014] Allocating a second service resource for a second preprocessing operation for pre-storing the data to be processed, the second service resource comprising a computing resource and a storage resource; performing the second preprocessing operation using the second service resource to obtain a pre-stored result of the data to be processed;

[0015] A third service resource is allocated for a third preprocessing operation for pre-reporting an offset, wherein the third service resource includes computing resources, interface resources, and cache resources; the third preprocessing operation is performed using the third service resource to obtain a pre-reporting offset result of the data to be processed.

[0016] Optionally, when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all executed successfully, completing the processing of the data to be processed based on the first preprocessing operation, completing the storage of the data to be processed based on the second preprocessing operation, and completing the step of reporting the offset based on the third preprocessing operation includes:

[0017] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reported offset result.

[0018] In a second aspect, an embodiment of the present invention provides a data processing method, the method comprising:

[0019] receiving a read request for data to be processed;

[0020] Sending the data to be processed to a consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0021] The offset sent by the consumer device is received, and the data storage state is updated.

[0022] Optionally, the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset, including:

[0023] Read the data to be processed in the preset data consumption queue;

[0024] Allocating a first service resource for a first preprocessing operation for preprocessing the data to be processed, the first service resource comprising a computing resource and a cache resource; performing the first preprocessing operation using the first service resource to obtain a preprocessing result of the data to be processed;

[0025] Allocating a second service resource for a second preprocessing operation for pre-storing the data to be processed, the second service resource comprising a computing resource and a storage resource; performing the second preprocessing operation using the second service resource to obtain a pre-stored result of the data to be processed;

[0026] A third service resource is allocated for a third preprocessing operation for pre-reporting an offset, wherein the third service resource includes computing resources, interface resources, and cache resources; the third preprocessing operation is performed using the third service resource to obtain a pre-reporting offset result of the data to be processed.

[0027] Optionally, the method further comprises:

[0028] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the first preprocessing operation, the storage of the data to be processed is completed based on the second preprocessing operation, and the reporting of the offset is completed based on the third preprocessing operation.

[0029] Optionally, when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all executed successfully, completing the processing of the data to be processed based on the first preprocessing operation, completing the storage of the data to be processed based on the second preprocessing operation, and completing the step of reporting the offset based on the third preprocessing operation includes:

[0030] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reported offset result.

[0031] In a third aspect, an embodiment of the present invention provides a data processing device, the device comprising:

[0032] A reading unit, used for reading the data to be processed in a preset data consumption queue;

[0033] an execution unit, configured to execute a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0034] A rollback unit is used to restore the data state to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed.

[0035] Optionally, the device further comprises:

[0036] A processing unit, used for completing the processing of the data to be processed based on the first preprocessing operation, completing the storage of the data to be processed based on the second preprocessing operation, and completing the reporting of the offset based on the third preprocessing operation when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully.

[0037] Optionally, the execution unit includes:

[0038] A first sub-execution unit is configured to allocate a first service resource for a first preprocessing operation for preprocessing the data to be processed, wherein the first service resource includes a computing resource and a cache resource; and use the first service resource to perform the first preprocessing operation to obtain a preprocessing result of the data to be processed;

[0039] A second sub-execution unit is used to allocate a second service resource for a second preprocessing operation for pre-storing the data to be processed, wherein the second service resource includes a computing resource and a storage resource; and use the second service resource to perform the second preprocessing operation to obtain a pre-stored result of the data to be processed;

[0040] The second sub-execution unit is used to allocate a third service resource for a third preprocessing operation for pre-reporting an offset, wherein the third service resources include computing resources, interface resources, and cache resources; and use the third service resources to perform the third preprocessing operation to obtain a pre-reporting offset result of the data to be processed.

[0041] Optionally, the processing unit is specifically configured to:

[0042] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reported offset result.

[0043] In a fourth aspect, an embodiment of the present invention provides a data processing device, the device comprising:

[0044] A receiving unit, configured to receive a read request for data to be processed;

[0045] a sending unit, configured to send the data to be processed to a consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0046] The updating unit is used to receive the offset sent by the consumer device and update the data storage state.

[0047] In a fifth aspect, an embodiment of the present invention further provides a data processing system, the data processing system comprising: a producer device, a data consumption queue and a consumer device;

[0048] The producer device is used to generate data and send the generated data to the data consumption queue;

[0049] The data consumption queue is used to receive the data sent by the producer device, store the data, and when receiving a read request for the data to be processed sent by the consumer device, send the data to be processed to the consumer device, receive the offset sent by the consumer device, and update the data storage state;

[0050] The consumer device is used to send a read request for pending data to the data consumption queue, read the pending data in the data consumption queue, and perform a first preprocessing operation for preprocessing the pending data, a second preprocessing operation for pre-storing the pending data, and a third preprocessing operation for pre-reporting an offset, and when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, restore the data state to a state before reading the pending data from the preset data consumption queue.

[0051] In a sixth aspect, an embodiment of the present invention further provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0052] Memory, used to store computer programs;

[0053] The processor is used to implement the method steps described in the first aspect or any one of the second aspects when executing the program stored in the memory.

[0054] In the seventh aspect, an embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium, and a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the method steps described in the first aspect or any one of the second aspects are implemented.

[0055] In an eighth aspect, an embodiment of the present invention further provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute: any one of the method steps described in the first aspect or the second aspect.

[0056] In the embodiment of the present invention, since the data state can be restored to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, so that the data consumption process satisfies atomicity, avoids data loss caused by the use of the automatic submission offset method, and avoids the existing use of manual submission offset, when the consumer device stores data but does not submit the offset, an exception occurs, and the problem of repeated data consumption after recovery. Of course, any product or method implementing the present invention does not necessarily need to achieve all the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 A flowchart of a data processing method provided by an embodiment of the present invention;

[0059] Figure 2 A schematic diagram of a flow chart of another data processing method provided by an embodiment of the present invention;

[0060] Figure 3 A flowchart of another data processing method provided by an embodiment of the present invention;

[0061] Figure 4 A flowchart of a data processing method provided by an embodiment of the present invention;

[0062] Figure 5 A schematic diagram of the structure of a data processing device provided by an embodiment of the present invention;

[0063] Figure 6 A schematic diagram of the structure of another data processing device provided by an embodiment of the present invention;

[0064] Figure 7 A schematic diagram of the structure of a data processing system provided by an embodiment of the present invention;

[0065] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0066] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of 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.

[0067] Currently, producer devices can send produced data to a Kafka message queue to cache the data through the Kafka message queue. In addition, consumer devices can obtain data from the Kafka consumer queue for consumption. Among them, the Kafka message queue is a high-throughput distributed publish / subscribe message queue.

[0068] In addition, the consumer device can be configured to submit the offset corresponding to the read data to the Kafka consumer queue after successfully writing the read data, that is, manually submit the offset to inform the Kafka consumer queue of the location of the data that the consumer device has read.

[0069] The inventors found in the process of implementing the present invention that the consumer device may have the following situation: an exception occurs after storing the read data A (for example, the consumer device crashes), but the offset corresponding to the data A is not submitted. In this case, when the consumer device returns to normal, the data A will be read and stored from the Kafka consumption queue again, which will cause repeated consumption of data A.

[0070] In order to solve the above technical problems, an embodiment of the present invention provides a data processing method, which may include:

[0071] Read the data to be processed in the preset data consumption queue;

[0072] Performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0073] When at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, the data state is restored to a state before the to-be-processed data is read from the preset data consumption queue.

[0074] In the embodiment of the present invention, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the data state can be restored to the state before reading the to-be-processed data from the preset data consumption queue, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, so that the data consumption process satisfies atomicity, avoids data loss caused by the automatic submission of offsets, and avoids the existing use of manual submission of offsets, when the consumer device stores data but does not submit the offset, an exception occurs, and the problem of repeated data consumption after recovery. It can be understood that the method of the embodiment of the present invention can be applied to Kafka, which is used as an example in the embodiment of the present invention, but the present invention is not limited to this.

[0075] The following is a detailed description of a data processing method provided by an embodiment of the present invention:

[0076] A data processing method provided in an embodiment of the present invention can be applied to a Kafka cluster, which is a distributed messaging system. In an embodiment of the present invention, the data processing method is applied to a Kafka cluster as an example for illustration. The Kafka cluster may include producer devices, consumer devices, and Kafka consumer queues, etc. Among them, consumer devices may include but are not limited to servers, computers, and mobile phones, etc.

[0077] In actual applications, consumer devices may set the function of automatically submitting offsets, which means that after the consumer device reads data from the Kafka consumer queue, it immediately submits the offset corresponding to the data it reads to the Kafka consumer queue. However, this way of submitting offsets is likely to cause the following situation: an exception occurs in the consumer device after reading the data and before storing the data, resulting in the submission of the offset corresponding to the data to the Kafka consumer queue, but the data is not stored. The consumer device will read data from the offset next time, resulting in the loss of the previously read data.

[0078] In order to avoid data loss caused by automatic submission of offset when the consumer device sets the function of automatically submitting offset, in an embodiment of the present invention, it can be pre-agreed in the Kafka cluster that the consumer device uses a manual submission offset method to notify the Kafka consumer queue of the offset corresponding to the data consumption completed by the consumer device.

[0079] like Figure 1 As shown, Figure 1 A flowchart of a data processing method provided by an embodiment of the present invention. The data processing method can be applied to a consumer device, and the method may include the following steps:

[0080] S101, reading data to be processed in a preset data consumption queue.

[0081] In an embodiment of the present invention, the preset data consumption queue may be a Kafka consumption queue in a Kafka cluster. It is understandable that the consumer device may read the data to be processed from the Kafka consumption queue, and there may be two results of reading the data to be processed: successful reading and failed reading. After successfully reading the data to be processed, the consumer device will execute step S102.

[0082] In the embodiment of the present invention, the read data to be processed may include picture data, text data and audio data, but is certainly not limited thereto.

[0083] As a preferred implementation of the embodiment of the present invention, the embodiment of the present invention can introduce a transaction mechanism to put the reading of the data to be processed, the related operations on the read data to be processed, and the operation of submitting the offset into the same transaction, that is, the consumption of the data to be processed by the consumer device at one time is put into one transaction for operation. In this way, it can be ensured that all operations in a transaction are either successfully completed or not completed, and will not stop at a certain operation in the middle.

[0084] The transaction mechanism refers to a series of operations performed as a logical unit. When data is updated synchronously, the transaction mechanism can be used to prevent data inconsistency. For a logical unit of work to become a transaction, it must meet the properties of atomicity, consistency, isolation, and persistence. These properties are existing concepts and will not be described in detail here.

[0085] S102, executing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset.

[0086] In an embodiment of the present invention, after successfully reading the data to be processed from the Kafka consumer queue, a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset can be executed. The execution results of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation can be success or failure. When the execution result indicates success, it means that the pre-operation of the data to be processed is successful. At this time, the pre-operation corresponding to the execution result indicating success of the data to be processed is only frozen, and the data processing corresponding to these pre-operations is not actually completed.

[0087] As a preferred implementation of an embodiment of the present invention, the implementation process of performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset may include:

[0088] A first service resource is allocated to a first preprocessing operation for preprocessing the data to be processed, and the first preprocessing operation is performed using the first service resource to obtain a preprocessing result of the data to be processed.

[0089] The first service resource may include computing resources and cache resources. The first preprocessing operation for preprocessing the data to be processed may include creating, modifying, filtering, and updating the read data to be processed. The preprocessing result of the data to be processed may be a result indicating that the preprocessing failed, and a result indicating that the preprocessing was successful, including a processing result obtained by preprocessing the data to be processed.

[0090] Exemplarily, the first preprocessing operation is to modify the data to be processed. Specifically, a first service resource is allocated to the first preprocessing operation for preprocessing the data to be processed, and the first preprocessing operation is performed using the first service resource to obtain the preprocessing result of the data to be processed. This can be: computing resources and cache resources are allocated to the first preprocessing operation, and then the computing resources allocated to the first preprocessing operation are used to calculate the modification amount of the data to be processed and the cache space of the modification amount, and the cache resources allocated to the first preprocessing operation are used to cache the modification amount of the data to be processed, so as to obtain the preprocessing result of the data to be processed.

[0091] A second service resource is allocated for a second preprocessing operation for pre-storing the data to be processed, and the second preprocessing operation is performed using the second service resource to obtain a pre-storage result of the data to be processed.

[0092] The second service resource may include: computing resources and cache resources, and the pre-storage result of the data to be processed may be a result indicating a pre-storage failure or a result indicating a pre-storage success.

[0093] Exemplarily, computing resources and cache resources can be allocated to the second preprocessing operation, and then the computing resources allocated to the second preprocessing operation are used to calculate the cache space required for pre-storing the data to be processed, and the cache resources allocated to the second preprocessing operation are used to cache the data to be processed.

[0094] A third service resource is allocated to a third preprocessing operation for pre-reporting an offset, and the third preprocessing operation is performed using the third service resource to obtain a pre-reporting offset result of the data to be processed.

[0095] The third service resource may include: computing resources, interface resources and cache resources, and the pre-reported offset result of the data to be processed may be a result indicating a failed report or a result indicating a successful report.

[0096] Exemplarily, computing resources, interface resources and cache resources can be allocated to the third preprocessing operation, and then the computing resources allocated to the third preprocessing operation can be used to calculate the network resources and cache space required for the pre-reporting offset, the pre-reporting offset can be cached using the cache resources allocated to the third preprocessing operation, and the pre-reporting offset can be pre-reported using the interface resources allocated to the third preprocessing operation.

[0097] S103, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed, restoring the data state to a state before reading the to-be-processed data from the preset data consumption queue.

[0098] In an embodiment of the present invention, a transaction mechanism can be introduced to place the reading of the data to be processed, the execution of a first preprocessing operation for preprocessing the data to be processed, the second preprocessing operation for pre-storing the data to be processed, and the third preprocessing operation for pre-reporting the offset in the same transaction to realize the consumption of the data to be processed. Furthermore, when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, it indicates that the attempt to consume the data to be processed has failed. At this time, the data state is restored to the state before the data to be processed is read from the preset data consumption queue, which can avoid the problem of repeated data consumption caused by the existing manual submission of offsets.

[0099] As a preferred implementation of the embodiment of the present invention, when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, or when an abnormality occurs in the consumer device, the data state can be restored to the state before the data to be processed is read from the preset data consumption queue. The abnormality of the consumer device includes a consumer device crash or a network abnormality.

[0100] As a preferred implementation of the embodiment of the present invention, the transaction mechanism introduced in the embodiment of the present invention can be a TCC (Try Confirm Cancel) type transaction mechanism. A TCC call to the business logic is only a temporary operation, and the consumer service that calls it reserves the subsequent cancellation right, that is, when the data consumption fails, the first preprocessing operation of preprocessing the data to be processed, the second preprocessing operation of pre-storing the data to be processed, and the third preprocessing operation for pre-reporting the offset are canceled.

[0101] In the embodiment of the present invention, since the data state can be restored to the state before the to-be-processed data is read from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, so that the data consumption process satisfies the atomicity, avoids data loss caused by the use of the automatic offset submission method, and avoids the problem of repeated data consumption caused by the existing use of manual offset submission, when the consumer device stores data but does not submit the offset, an exception occurs, and after recovery to normal.

[0102] like Figure 2 As shown, an embodiment of the present invention provides another data processing method, which may include the following steps:

[0103] S201, reading data to be processed in a preset data consumption queue.

[0104] S202, executing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset.

[0105] S203, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed, restoring the data state to a state before reading the to-be-processed data from the preset data consumption queue.

[0106] The implementation process of steps S201 - S203 may be the same as that of steps S101 - S103 , and will not be described in detail in the embodiment of the present invention.

[0107] S204, when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the first preprocessing operation, the storage of the data to be processed is completed based on the second preprocessing operation, and the reporting of the offset is completed based on the third preprocessing operation.

[0108] In an embodiment of the present invention, a transaction mechanism can be introduced to place the reading of the data to be processed, the execution of a first preprocessing operation for preprocessing the data to be processed, the second preprocessing operation for pre-storing the data to be processed, and the third preprocessing operation for pre-reporting the offset in the same transaction to realize the consumption of the data to be processed. Furthermore, when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all executed successfully, it indicates that the attempted consumption of the data to be processed is successful. At this time, the processing of the data to be processed is completed based on the first preprocessing operation, the storage of the data to be processed is completed based on the second preprocessing operation, and the reporting of the offset is completed based on the third preprocessing operation, that is, the consumption of the data to be processed is completed.

[0109] As a preferred implementation manner of an embodiment of the present invention, when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reported offset result.

[0110] In an embodiment of the present invention, when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the preprocessing result obtained by the first preprocessing operation on the data to be processed can be used to complete the processing of the data to be processed, the pre-storage result obtained by the second preprocessing operation on the data to be processed can be used to complete the storage of the data to be processed, and the pre-reporting offset result obtained by the third preprocessing operation on the data to be processed can be used to complete the reporting of the offset.

[0111] In the embodiment of the present invention, since the data state can be restored to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, the data consumption process satisfies atomicity, avoids data loss caused by the use of the automatic offset submission method, and avoids the problem of repeated data consumption caused by the existing use of manual offset submission, when the consumer device stores data but does not submit the offset, an exception occurs, and after recovery to normal.

[0112] like Figure 3 As shown, an embodiment of the present invention provides another data processing method, which can be applied to a Kafka cluster, and specifically can be applied to a Kafka consumer queue in a Kafka cluster. The method may include the following steps:

[0113] S301, receiving a read request for data to be processed.

[0114] In the embodiment of the present invention, the Kafka consumer queue in the Kafka cluster can receive a read request for the data to be processed, and then send the data to be processed to the consumer device.

[0115] S302, sending the data to be processed to the consumer device, so that the consumer device reads the data to be processed and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset.

[0116] In an embodiment of the present invention, the Kafka consumption queue in the Kafka cluster can send the data to be processed to the consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset, thereby completing the consumption of the data to be processed. Specifically, the consumer device reads the data to be processed, and the operation of consuming the data to be processed can be referred to the above introduction, and the embodiment of the present invention will not be repeated here.

[0117] S303, receiving the offset sent by the consumer device, and updating the data storage status.

[0118] When the consumer device successfully consumes the data to be processed, the Kafka consumer queue in the Kafka cluster can update the data storage status in the Kafka consumer queue according to the offset sent by the consumer device.

[0119] In an embodiment of the present invention, a Kafka consumer queue in a Kafka cluster receives a read request for data to be processed, and sends the data to be processed to a consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset, thereby completing the consumption of the data to be processed. The Kafka consumer queue further updates the data storage status in the Kafka consumer queue according to the offset sent by the received consumer device. Since the consumer device can restore the data state to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, so that the data consumption process satisfies atomicity, avoids data loss caused by the use of automatic offset submission, and avoids the problem of repeated data consumption caused by the existing use of manual offset submission, when the consumer device stores data but does not submit the offset, an exception occurs, and recovery to normal.

[0120] As a preferred implementation of an embodiment of the present invention, the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and an implementation process of a third preprocessing operation for pre-reporting an offset, which may include:

[0121] Read the data to be processed in the preset data consumption queue;

[0122] Allocating a first service resource for a first preprocessing operation for preprocessing the data to be processed, the first service resource including a computing resource and a cache resource; performing the first preprocessing operation using the first service resource to obtain a preprocessing result of the data to be processed;

[0123] Allocating a second service resource for a second preprocessing operation for pre-storing the data to be processed, the second service resource including a computing resource and a storage resource; performing the second preprocessing operation using the second service resource to obtain a pre-stored result of the data to be processed;

[0124] A third service resource is allocated for a third preprocessing operation for pre-reporting an offset, wherein the third service resource includes computing resources, interface resources, and cache resources; and the third preprocessing operation is performed using the third service resource to obtain a pre-reporting offset result of the data to be processed.

[0125] As a preferred implementation manner of an embodiment of the present invention, the consumer device can complete the processing of the data to be processed based on the first preprocessing operation, complete the storage of the data to be processed based on the second preprocessing operation, and complete the reporting of the offset based on the third preprocessing operation when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully.

[0126] As a preferred implementation of the embodiment of the present invention, when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all successfully executed, the consumer device completes the processing of the data to be processed based on the first preprocessing operation, completes the storage of the data to be processed based on the second preprocessing operation, and completes the implementation process of reporting the offset based on the third preprocessing operation, which may include:

[0127] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reporting offset result.

[0128] For example, Figure 4 As shown, Figure 4 A flow chart of a data processing method provided for an embodiment of the present invention. In an embodiment of the present invention, a Kafka cluster can be established based on a zookeeper cluster, which is a distributed, open source distributed application coordination service. Among them, producer devices may include: producer device 1, producer device 2, and producer device 3, etc. Consumer devices may include: consumer device 1, consumer device 2, and consumer device 3, etc. Kafka consumer queues may include: proxy server 1, proxy server 2, and proxy server 3, etc., that is, the data to be consumed in the proxy server is stored in the Kafka consumer queue. Among them, the consumer device, the producer device, and the proxy server all establish a communication connection with zookeeper.

[0129] Any producer device can send the produced data to the proxy server and store the data through the Kafka consumer queue. In addition, the consumer device can obtain data from the Kafka consumer queue for consumption. After reading the data, the consumer device can complete the consumption of the data based on the transaction mechanism and manually submitting the offset.

[0130] Specifically, the consumer device can submit the offset by introducing a transaction mechanism and manually submitting the offset after the consumer device stores the data as an operation in the transaction mechanism. Thus, when the transaction fails, the state of the consumer device can be restored, which can solve the problem of repeated data consumption caused by manually submitting the offset.

[0131] It is understandable that the transaction mechanism may be generated according to the specific business logic to be implemented by the consumer device, and the transaction mechanisms corresponding to different consumer devices may be different.

[0132] Exemplarily, the operations corresponding to the transaction mechanism generated by consumer device A consuming data may include: reading the data to be processed in the Kafka consumption queue, executing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset, and when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, restoring the data state to the state before reading the data to be processed from the preset data consumption queue.

[0133] Corresponding to the above Figure 1 The embodiment of the present invention also provides a corresponding device embodiment. Figure 5 As shown, an embodiment of the present invention provides a data processing device, which may include:

[0134] The reading unit 501 is used to read the data to be processed in the preset data consumption queue.

[0135] The execution unit 502 is used to execute a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset.

[0136] The rollback unit 503 is used to restore the data state to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed.

[0137] In the embodiment of the present invention, since the consumer device can restore the data state to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, the data consumption process satisfies atomicity, avoids data loss caused by the use of the automatic offset submission method, and avoids the problem of repeated data consumption caused by the existing manual offset submission, when the consumer device stores data but does not submit the offset, an exception occurs, and after recovery to normal.

[0138] Optionally, the above device further comprises:

[0139] A processing unit (not shown in the figure) is used to complete the processing of the data to be processed based on the first preprocessing operation, complete the storage of the data to be processed based on the second preprocessing operation, and complete the reporting of the offset based on the third preprocessing operation when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully.

[0140] Optionally, the execution unit 502 includes:

[0141] The first sub-execution unit is used to allocate a first service resource for a first preprocessing operation for preprocessing the data to be processed, the first service resource including computing resources and cache resources; and use the first service resource to perform the first preprocessing operation to obtain a preprocessing result of the data to be processed.

[0142] The second sub-execution unit is used to allocate second service resources for a second preprocessing operation for pre-storing the data to be processed, the second service resources including computing resources and storage resources; and use the second service resources to perform the second preprocessing operation to obtain the pre-storage result of the data to be processed.

[0143] The second sub-execution unit is used to allocate a third service resource for a third preprocessing operation for pre-reporting an offset, wherein the third service resource includes computing resources, interface resources, and cache resources; and use the third service resources to perform the third preprocessing operation to obtain a pre-reporting offset result of the data to be processed.

[0144] Optionally, the processing unit is specifically configured to:

[0145] When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reporting offset result.

[0146] Corresponding to the above Figure 3 The embodiment of the present invention also provides a corresponding device embodiment. Figure 6 As shown, an embodiment of the present invention provides a data processing device, which may include:

[0147] The receiving unit 601 is configured to receive a read request for data to be processed.

[0148] The sending unit 602 is used to send the data to be processed to the consumer device, so that the consumer device reads the data to be processed and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset.

[0149] The updating unit 603 is used to receive the offset sent by the consumer device and update the data storage state.

[0150] In an embodiment of the present invention, a data consumption queue can receive a read request for data to be processed, and send the data to be processed to a consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset, thereby completing the consumption of the data to be processed. The data consumption queue further updates the data storage state in the data consumption queue according to the offset sent by the received consumer device. Since the consumer device can restore the data state to the state before reading the data to be processed from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, that is, when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation, and the third preprocessing operation all fail, so that the data consumption process satisfies atomicity, avoids data loss caused by using the automatic submission of offsets, and the existing manual submission of offsets, when the consumer device stores data but does not submit the offset, an exception occurs, and the problem of repeated data consumption after recovery.

[0151] Corresponding to the above method embodiment, the present invention also provides a corresponding system embodiment. Figure 7 As shown, an embodiment of the present invention provides a data processing system, the data processing system includes: a producer device 701, a data consumption queue 702 and a consumer device 703;

[0152] The producer device 701 is used to generate data and send the generated data to the data consumption queue 702;

[0153] The data consumption queue 702 is used to receive the data sent by the producer device 701, store the data, and when receiving a read request for the data to be processed sent by the consumer device 703, send the data to be processed to the consumer device 703, receive the offset sent by the consumer device 703, and update the data storage state;

[0154] The consumer device 703 is used to send a read request for the data to be processed to the data consumption queue 702, read the data to be processed in the data consumption queue 702, and perform a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset, and when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, restore the data state to the state before reading the data to be processed from the preset data consumption queue.

[0155] In the embodiment of the present invention, since the consumer device can restore the data state to the state before reading the to-be-processed data from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, that is, when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to execute, the entire first preprocessing operation, the second preprocessing operation and the third preprocessing operation all fail, the data consumption process satisfies atomicity, avoids data loss caused by the use of the automatic offset submission method, and avoids the problem of repeated data consumption caused by the existing manual offset submission, when the consumer device stores data but does not submit the offset, an exception occurs, and after recovery to normal.

[0156] Corresponding to the above method embodiment, an embodiment of the present invention further provides an electronic device. Figure 8 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 8 , including a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804,

[0157] Memory 803, used for storing computer programs;

[0158] The processor 801 is used to execute the program stored in the memory 803 to implement the following steps:

[0159] Read the data to be processed in the preset data consumption queue;

[0160] Performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0161] When at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, the data state is restored to a state before the to-be-processed data is read from the preset data consumption queue.

[0162] Or implement the following steps:

[0163] receiving a read request for data to be processed;

[0164] Sending the data to be processed to the consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset;

[0165] Receive the offset sent by the consumer device and update the data storage status.

[0166] Corresponding to the above method embodiment, an embodiment of the present invention further provides a readable storage medium, which is a computer-readable storage medium. A computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the following steps are implemented:

[0167] Read the data to be processed in the preset data consumption queue;

[0168] Performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0169] When at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, the data state is restored to a state before the to-be-processed data is read from the preset data consumption queue.

[0170] Or implement the following steps:

[0171] receiving a read request for data to be processed;

[0172] Sending the data to be processed to the consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset;

[0173] Receive the offset sent by the consumer device and update the data storage status.

[0174] Corresponding to the above method embodiment, an embodiment of the present invention further provides a computer program product, which, when executed on an electronic device, enables the electronic device to perform the following steps:

[0175] Read the data to be processed in the preset data consumption queue;

[0176] Performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset;

[0177] When at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, the data state is restored to a state before the to-be-processed data is read from the preset data consumption queue.

[0178] Or follow these steps:

[0179] receiving a read request for data to be processed;

[0180] Sending the data to be processed to the consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting the offset;

[0181] Receive the offset sent by the consumer device and update the data storage status.

[0182] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0183] The communication interface is used for communication between the above electronic device and other devices.

[0184] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0185] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0186] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device 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, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0187] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, system, electronic device, storage medium and computer program product 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.

[0188] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A data processing method, characterized in that: The method comprises: Read the data to be processed in the preset data consumption queue; Performing a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset; When at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed, restoring the data state to a state before reading the to-be-processed data from the preset data consumption queue; When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the first preprocessing operation, the storage of the data to be processed is completed based on the second preprocessing operation, and the reporting of the offset is completed based on the third preprocessing operation.

2. The method according to claim 1, characterized in that The performing of a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset includes: Allocating a first service resource for a first preprocessing operation for preprocessing the data to be processed, the first service resource comprising a computing resource and a cache resource; performing the first preprocessing operation using the first service resource to obtain a preprocessing result of the data to be processed; Allocating a second service resource for a second preprocessing operation for pre-storing the data to be processed, the second service resource comprising a computing resource and a storage resource; performing the second preprocessing operation using the second service resource to obtain a pre-stored result of the data to be processed; A third service resource is allocated for a third preprocessing operation for pre-reporting an offset, wherein the third service resource includes computing resources, interface resources, and cache resources; the third preprocessing operation is performed using the third service resource to obtain a pre-reporting offset result of the data to be processed.

3. The method according to claim 2, characterized in that The step of completing the processing of the data to be processed based on the first preprocessing operation, completing the storage of the data to be processed based on the second preprocessing operation, and completing the reporting of the offset based on the third preprocessing operation when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all successfully executed includes: When the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully, the processing of the data to be processed is completed based on the preprocessing result, the storage of the data to be processed is completed based on the pre-storage result, and the reporting of the offset is completed based on the pre-reported offset result.

4. A data processing method, characterized in that: The method comprises: receiving a read request for data to be processed; Sending the data to be processed to a consumer device so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset; when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, restoring the data state to a state before reading the data to be processed; and when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all executed successfully, completing the processing of the data to be processed based on the first preprocessing operation, completing the storage of the data to be processed based on the second preprocessing operation, and completing the reporting of the offset based on the third preprocessing operation; The offset sent by the consumer device is received, and the data storage state is updated.

5. A data processing device, characterized in that: The device comprises: A reading unit, used for reading the data to be processed in a preset data consumption queue; an execution unit, configured to execute a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset; a rollback unit, configured to restore the data state to a state before the to-be-processed data is read from the preset data consumption queue when at least one of the first preprocessing operation, the second preprocessing operation and the third preprocessing operation fails to be executed; A processing unit, used for completing the processing of the data to be processed based on the first preprocessing operation, completing the storage of the data to be processed based on the second preprocessing operation, and completing the reporting of the offset based on the third preprocessing operation when the first preprocessing operation, the second preprocessing operation and the third preprocessing operation are all executed successfully.

6. A data processing device, characterized in that: The device comprises: A receiving unit, configured to receive a read request for data to be processed; a sending unit, configured to send the data to be processed to a consumer device, so that the consumer device reads the data to be processed, and performs a first preprocessing operation for preprocessing the data to be processed, a second preprocessing operation for pre-storing the data to be processed, and a third preprocessing operation for pre-reporting an offset; when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to be executed, restore the data state to a state before reading the data to be processed; and when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all executed successfully, complete the processing of the data to be processed based on the first preprocessing operation, complete the storage of the data to be processed based on the second preprocessing operation, and complete the reporting of the offset based on the third preprocessing operation; The updating unit is used to receive the offset sent by the consumer device and update the data storage state.

7. A data processing system, characterized in that: The data processing system comprises: a producer device, a data consumption queue and a consumer device; The producer device is used to generate data and send the generated data to the data consumption queue; The data consumption queue is used to receive the data sent by the producer device, store the data, and when receiving a read request for the data to be processed sent by the consumer device, send the data to be processed to the consumer device, receive the offset sent by the consumer device, and update the data storage state; The consumer device is used to send a read request for pending data to the data consumption queue, read the pending data in the data consumption queue, and perform a first preprocessing operation for preprocessing the pending data, a second preprocessing operation for pre-storing the pending data, and a third preprocessing operation for pre-reporting an offset; and when at least one of the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation fails to execute, restore the data state to a state before reading the pending data from the data consumption queue; when the first preprocessing operation, the second preprocessing operation, and the third preprocessing operation are all executed successfully, complete the processing of the pending data based on the first preprocessing operation, complete the storage of the pending data based on the second preprocessing operation, and complete the reporting of the offset based on the third preprocessing operation.

8. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 3, or implementing the method steps described in claim 4, when executing a program stored in a memory.

9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the method steps of any one of claims 1 to 3 are implemented, or the method steps of claim 4 are implemented.

Citation Information

Patent Citations

  • Message loss prevention method and device

    CN107423145A

  • Message processing method and device, storage medium and equipment

    CN110941502A

  • Message processing method and device, electronic equipment and medium

    CN111381987A

  • Parallel Replication Across Formats

    US20190325055A1

  • Data transmission method, apparatus, device, and storage medium

    WO2020186791A1