Multi-data-source transaction processing method and system based on advertisement putting
By adopting a multi-data source transaction processing method in the advertising delivery system and utilizing the Kafka message queue and message status confirmation system, the problem of data inconsistency is solved, the consistency and integrity of data in different storage media are achieved, and users are provided with for a convenient data usage experience.
Patent Information
- Application Number
- CN202410737966.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-13
AI Technical Summary
Existing technology cannot simultaneously save data through transaction operations in multiple data sources, resulting in data inconsistency issues and affecting subsequent data use.
Adopting a multi-data source transaction processing method based on advertising, through the connection between the advertising data end and the mysql database and the elasticSearch open source search engine library, using the kafka message queue and message status confirmation system to achieve asynchronous processing and status synchronization of data, and use scheduled tasks For message recovery and status confirmation, it ensures the consistency of data in different storage media.
It achieves data consistency in data storage from different data sources, ensures the integrity and reliability of data storage, and provides convenience for subsequent data use.
Smart Images

Figure CN118644288A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a multi-data source transaction processing method, system, intelligent terminal and storage medium based on advertisement delivery. Background Art
[0002] Advertising involves a large amount of data processing, such as demographic data, label data, and user portrait data. When big data processes this data, many business scenarios need to be considered. For example, for demographic data, users are not so concerned about timeliness. Today, it is sufficient to count the usage of the crowd before yesterday. Label data and user portraits are very time-sensitive and must be returned to users immediately (in seconds). Therefore, when saving data, the business end needs to consider how to save the data in different storage engines to meet the needs of different business scenarios.
[0003] However, the data processing architecture of the existing technology cannot guarantee data consistency, because they belong to different data sources, and it is impossible to ensure that data is saved successfully and failed at the same time in MySQL (a database) and ElasticSearch (an open source search engine library) through transaction operations in one method. The same batch of data may be saved successfully in MySQL, but fail to be saved in ElasticSearch, which will cause data inconsistency problems in the storage of data from different data sources, causing inconvenience to subsequent data use.
[0004] Therefore, the existing technology still needs to be improved and developed. Summary of the invention
[0005] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a multi-data source transaction processing method, system, intelligent terminal and storage medium based on advertising delivery are provided. The present invention can solve the problem of data inconsistency stored in data from different data sources, and provide convenience for subsequent data use.
[0006] The technical solution adopted by the present invention to solve the problem is as follows:
[0007] A multi-data source transaction processing method based on advertisement delivery, wherein the multi-data source transaction processing method is implemented based on a preset data processing architecture, the preset data processing architecture includes: an advertisement data end, a MySQL database, an elasticSearch open source search engine library, and a message status confirmation system for confirming whether data is received and a message recovery system for starting message retransmission; the advertisement data end is connected to the MySQL database, and the advertisement data end is also connected to the elasticSearch open source search engine library through a Kafka message queue; one end of the message status confirmation system is connected to the MySQL database and the other end is connected to the elasticSearch open source search engine library, and one end of the message recovery system is connected to the MySQL database and the other end is connected to the Kafka message queue; the multi-data source transaction processing method includes the following steps:
[0008] Acquire advertisement data, save the advertisement data into a MySQL database through a local transaction, and mark the data processing state of the advertisement data as an initial first state;
[0009] At the same time, the advertisement data is sent to the kafka message queue. When the sending is successful, the state of the advertisement data in the mysql database is updated to the second state of successful data sending;
[0010] Control the consumer program to monitor the advertisement data in the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library;
[0011] When it is detected that the advertising data is successfully saved to the elasticSearch open source search engine library, the status of the advertising data in the elasticsearch open source search engine library is marked as the initial first state, and the message status confirmation system is called to update the status of the advertising data in the MySQL database to the third state of successful processing, and update the status of the advertising data in the elasticsearch open source search engine library to the third state of successful processing.
[0012] The method for processing transactions from multiple data sources based on advertising delivery, wherein the step of updating the state of the advertising data in the elasticsearch open source search engine library to successfully process the state 3 includes:
[0013] Start the scheduled task of the message recovery system, execute the scheduled task every 3 seconds, scan the advertisement data in the MySQL database with status 0 and status 1 for more than one minute, resend the message to the kafka message queue, and control the advertisement data to be resent to the elasticSearch open source search engine library for storage.
[0014] The method for processing transactions from multiple data sources based on advertising delivery, wherein the step of updating the state of the advertising data in the elasticsearch open source search engine library to successfully process the state 3 includes:
[0015] Start the scheduled task of the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the mysql database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3.
[0016] The multi-data source transaction processing method based on advertising delivery, wherein the steps of obtaining advertising data, saving the advertising data into a MySQL database through a local transaction, and marking the data processing state of the advertising data as an initial state 0, include:
[0017] The states of the pre-set advertisement data include: a first state which is an initial state 0, a second state which is a data sending success state 1, and a third state which is a data processing success state 3.
[0018] The multi-data source transaction processing method based on advertising delivery, wherein the steps of obtaining advertising data, saving the advertising data into a MySQL database through a local transaction, and marking the data processing state of the advertising data as an initial first state include:
[0019] The advertisement data is obtained from the advertisement data terminal, the advertisement data is saved in the MySQL database through a local transaction, and the data processing state of the advertisement data is marked as 0, which is the initial first state.
[0020] The multi-data source transaction processing method based on advertising delivery, wherein the step of simultaneously sending the advertising data to the Kafka message queue and, when the sending is successful, updating the state of the advertising data in the MySQL database to the second state of successful data sending comprises:
[0021] At the same time, the advertisement data is sent to the kafka message queue. When the sending is successful, the state of the advertisement data in the MySQL database is updated to 1, which is the second state of successful data sending.
[0022] The multi-data source transaction processing method based on advertising delivery, wherein the steps of calling the message status confirmation system, updating the status of the advertising data in the MySQL database to the third status of successful processing, and updating the status of the advertising data in the elasticsearch open source search engine library to the third status of successful processing include:
[0023] The message status confirmation system is called to update the status of the advertisement data in the MySQL database to 3, which is the third status of successful processing, and to update the status of the advertisement data in the elasticsearch open source search engine library to 3, which is the third status of successful processing.
[0024] A multi-data source transaction processing system based on advertising delivery, wherein the system includes: an advertising data terminal, a MySQL database, an elasticSearch open source search engine library, and a message status confirmation system for confirming whether data has been received and a message recovery system for starting message retransmission; the advertising data terminal is connected to the MySQL database, and the advertising data terminal is also connected to the elasticSearch open source search engine library through a Kafka message queue; one end of the message status confirmation system is connected to the MySQL database and the other end is connected to the elasticSearch open source search engine library, and one end of the message recovery system is connected to the MySQL database and the other end is connected to the Kafka message queue; the system also includes:
[0025] An acquisition marking module is used to acquire advertisement data, save the advertisement data into a MySQL database through a local transaction, and mark the data processing state of the advertisement data as an initial first state;
[0026] A message queue sending and marking module is used to send the advertisement data to the kafka message queue at the same time, and when the sending is successful, update the state of the advertisement data in the mysql database to the second state of successful data sending;
[0027] The monitoring and saving module is used to control the consumer program to monitor the advertisement data of the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library;
[0028] The detection and marking module is used to mark the state of the advertisement data in the elasticsearch open source search engine library as the initial first state when detecting that the advertisement data is successfully saved in the elasticsearch open source search engine library, and call the message state confirmation system to update the state of the advertisement data in the mysql database to the third state of successful processing, and update the state of the advertisement data in the elasticsearch open source search engine library to the third state of successful processing;
[0029] The message recovery control module is used to start the scheduled task of the message recovery system. It executes the scheduled task every 3 seconds, scans the advertisement data in the MySQL database whose status is 0 and 1 for more than one minute, resends the message to the Kafka message queue, and controls the advertisement data to be resent to the elasticSearch open source search engine library for storage;
[0030] The message status confirmation control module is used to control the scheduled task of starting the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the mysql database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3.
[0031] An intelligent terminal includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, including the method for executing any one of the methods described above.
[0032] A non-transitory computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods described above.
[0033] The beneficial effects of the present invention are as follows: the present invention provides a multi-data source transaction processing method, system, intelligent terminal and storage medium based on advertising delivery. The present invention can perform message confirmation and message recovery on data storages of different data sources, achieve data consistency of data storages of different data sources, ensure the integrity of data storage, provide convenience for subsequent data use, and provide convenience for user use. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] 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 recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 It is a schematic diagram of the data processing architecture structure of the prior art.
[0036] Figure 2 It is a flowchart of a multi-data source transaction processing method based on advertisement delivery provided by an embodiment of the present invention.
[0037] Figure 3 It is a flowchart of a multi-data source transaction processing method based on advertisement delivery provided by a specific application embodiment of the present invention.
[0038] Figure 4 It is a principle block diagram of an embodiment of a multi-data source transaction processing system based on advertisement delivery provided by the present invention.
[0039] Figure 5 It is a block diagram of the internal structure principle of the intelligent terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0041] It should be noted that if the embodiments of the present invention involve directional indications (such as up, down, left, right, front, back, etc.), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0042] The inventors have found that the data processing architecture of the prior art is as follows: Figure 1 As shown, in the prior art, when processing data, the big data end saves the data in MySQL and ElasticSearch at the same time through Kafka messages. However, in the prior art, when processing transactions with multiple data sources, the consistency of data cannot be guaranteed, because they belong to different data sources, and it is impossible to ensure that the data is saved successfully and failed at the same time in MySQL and ElasticSearch through transaction operations in one method. The same batch of data may be saved successfully in MySQL, but fail to be saved in ElasticSearch.
[0043] In the prior art, sometimes the crowd data can be queried on the same day, but it cannot be found when it is queried again after a few days. This is because the data processing cannot meet the data consistency. Because the exposure data is queried in the elasticsearch database, the exposure data is statistical data, and the real-time performance is not so high. The data with low real-time requirements are uniformly queried through elasticsearch, and the data with high timeliness requirements are directly queried in mysql. After investigation, the inventor found that the exposure data of some groups of people were successfully saved in mysql, so there was no problem on the same day. However, when querying elasticsearch a few days later, it was found that elasticsearch did not save the exposure data of this group of people, resulting in a lot less exposure on the operation interface. That is, the data processing architecture of the prior art cannot guarantee data consistency.
[0044] Among them, MySQL is an open source relational database that is widely used for back-end data storage and management of Web applications. It supports the SQL language and provides a reliable, high-performance data storage engine. MySQL can be used for a variety of different types of applications, from small websites to large enterprise applications.
[0045] Elasticsearch is an open source search engine based on Apache Lucene, focusing on real-time search, analysis, and data visualization. It is widely used to build complex search applications and data analysis tools, providing a distributed data storage system. Elasticsearch can quickly store, search, and analyze large amounts of data.
[0046] Elasticsearch's data storage model is based on documents. Each document is a JSON data with custom fields and corresponding values. Documents can be organized into indexes. Indexes can contain multiple documents and support complex query and analysis operations. Elasticsearch provides powerful full-text retrieval, aggregation analysis, real-time data processing and high availability functions. Therefore, it is widely used in log analysis, enterprise search, real-time monitoring, e-commerce platforms and big data analysis.
[0047] Kafka is a message engine, and the message here is the main object processed by Kafka; Kafka is a high-throughput distributed publish-subscribe message.
[0048] Kafka is a distributed message queue system designed to process large amounts of real-time data streams and provides a high-performance, scalable, and reliable messaging mechanism. Kafka is often used to build real-time data stream processing systems to transmit, store, and process large amounts of real-time data.
[0049] Kafka uses topics to organize messages. Producers can publish messages to specific topics, and consumers can subscribe to messages from topics and process them. Kafka's message queue features include persistent storage, high throughput, horizontal scalability, and fault tolerance. Due to these features, Kafka is widely used in scenarios such as log collection, real-time data analysis, event-driven architecture, message notification, and data replication.
[0050] like Figure 3 As shown, a multi-data source transaction processing method based on advertising delivery is provided in Embodiment 1 of the present invention, wherein the multi-data source transaction processing method is implemented based on a preset data processing architecture, and the preset data processing architecture includes: an advertising data terminal 10, a mysql database 20, an elasticSearch open source search engine library 30, and a message status confirmation system 40 for confirming whether data is received and a message recovery system 50 for starting message retransmission; the advertising data terminal 10 is connected to the mysql database 20, and the advertising data terminal 10 is also connected to the elasticSearch open source search engine library 30 through a kafka message queue 60; one end of the message status confirmation system 40 is connected to the mysql database 20, and the other end is connected to the elasticSearch open source search engine library 30, and one end of the message recovery system 50 is connected to the mysql database 20, and the other end is connected to the kafka message queue 60;
[0051] like Figure 2 As shown, the multi-data source transaction processing method described in the embodiment of the present invention includes the following steps:
[0052] Step S100, acquiring advertisement data, saving the advertisement data into a MySQL database through a local transaction, and marking the data processing state of the advertisement data as an initial first state;
[0053] In the embodiment of the present invention, advertisement data is taken as an example for explanation. Before specific implementation, the states of advertisement data that need to be preset include: a first state represented by an initial state 0, a second state represented by a data sending success state 1, and a third state represented by a data processing success state 3.
[0054] In specific implementation, the advertisement data may be obtained from the advertisement data terminal, the advertisement data may be saved in a MySQL database through a local transaction, and the data processing state of the advertisement data may be marked as 0, which is the initial first state.
[0055] In this step, obtaining advertising data from the advertising data terminal refers to obtaining advertising data through various channels, such as advertising platforms, third-party data suppliers, etc., and these data include advertising content, advertiser information, advertising display conditions, etc. Saving the advertising data to the MySQL database through local transactions means saving the acquired advertising data to the MySQL database using transaction operations to ensure data integrity and consistency. Marking the data processing state of the advertising data as 0, that is, the initial first state, is to facilitate subsequent processing and management of the data.
[0056] In this step, data is saved to the MySQL database through local transactions, which can ensure data security and avoid data loss or damage. Using transaction operations can ensure data consistency and avoid data inconsistency. By marking the data processing status as 0, subsequent data processing and management can be convenient, such as recording the data saving status.
[0057] For example, when an e-commerce platform needs to save advertising data to the database for subsequent analysis and optimization, it first obtains the advertising data from the advertising data end, including advertising content, advertiser information, etc., and then saves this data to the MySQL database through local transactions, and marks the data processing status as 0. In this way, the integrity and consistency of the data can be ensured, and it is convenient for subsequent data processing and management. If new advertising data needs to be added, the same steps can be followed to ensure effective data management and tracking.
[0058] Step S200, simultaneously sending the advertisement data to the kafka message queue, and when the sending is successful, updating the state of the advertisement data in the mysql database to the second state where the data is successfully sent;
[0059] In the embodiment of this step, the advertisement data is sent to the kafka message queue at the same time. When the sending is successful, the state of the advertisement data in the MySQL database is updated to 1, which is the second state of successful data sending.
[0060] That is, the present invention sends the advertisement data to the kafka message queue in order to realize asynchronous processing and data decoupling. In the previous step, the present invention has saved the advertisement data in the mysql database and marked the status as 0. Now it is necessary to send these data to the kafka message queue, and after the sending is successful, update the advertisement data status in the mysql database to 1, indicating the second state of successful data sending.
[0061] The present invention realizes asynchronous processing of data by sending data to the Kafka message queue, avoiding the performance bottleneck caused by synchronous operation. After sending data to the message queue, the present invention can realize the decoupling of the database and the business logic, and enhance the scalability and flexibility of the system. The present invention adopts the message queue with high reliability and high availability, and can ensure the safe transmission and reliable consumption of data.
[0062] For example, continuing with the example of the e-commerce platform above, the purpose of sending advertising data to the Kafka message queue is to trigger the subsequent advertising display and statistical logic. After the advertising data is saved to the MySQL database and the status is marked as 0, the data is sent to the Kafka message queue. Once the data is successfully sent to the message queue, the corresponding advertising data status in the database is updated to 1, indicating the second state of successful data sending.
[0063] In this way, the decoupling of database operations and business logic can be achieved, and the scalability and maintainability of the system can be improved. At the same time, through the high reliability of the Kafka message queue, the secure transmission and reliable consumption of data can be ensured, and the integrity and consistency of the data can be guaranteed.
[0064] Step S300: Control the consumer program to monitor the advertisement data in the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library;
[0065] In this step, the consumer program is controlled to monitor the advertisement data in the kafka message queue in real time, and the advertisement data is consumed and saved to the Elasticsearch open source search engine library in order to realize real-time query and analysis of the data. In the previous steps, the present invention has sent the advertisement data to the kafka message queue and updated the database status to 1. Now it is necessary to write a consumer program to monitor the data in the message queue in real time and save the data to the Elasticsearch open source search engine library.
[0066] The present invention can realize real-time consumption and storage of advertising data by real-time monitoring of the Kafka message queue, ensuring the timeliness of the data. Saving the advertising data in Elasticsearch can realize efficient full-text search and complex query, improve query performance and user experience. The Elasticsearch open source search engine library has powerful data analysis functions, which can conduct in-depth analysis and mining of advertising data and provide data support for business decisions.
[0067] For example, in the scenario of an e-commerce platform, the consumer program can obtain advertising data in real time by listening to the Kafka message queue. Once new advertising data enters the message queue, the consumer program consumes it immediately and saves the data to Elasticsearch. In this way, real-time indexing and querying of advertising data can be achieved, and users can quickly search and find advertising information of interest. For example, users can query related advertising content by entering keywords in the search box, and Elasticsearch can quickly return matching advertising data to provide a better search experience. At the same time, advertising data can be analyzed through the aggregation function of Elasticsearch, such as counting the number of ad impressions, click-through rate and other indicators of a certain advertiser, to provide data support for advertising optimization and marketing strategies. In this way, real-time monitoring and analysis of advertising data is achieved, which improves the advertising effect and user experience of the platform.
[0068] Step S400: When it is detected that the advertising data is successfully saved to the elasticSearch open source search engine library, the status of the advertising data in the elasticsearch open source search engine library is marked as the initial first state, and the message status confirmation system is called to update the status of the advertising data in the MySQL database to the third state of successful processing, and update the status of the advertising data in the elasticsearch open source search engine library to the third state of successful processing.
[0069] In an embodiment of the present invention, when it is detected that the advertising data is successfully saved in the elasticSearch open source search engine library, the status of the advertising data in the elasticsearch open source search engine library is first marked as the initial first state; and the message status confirmation system is called to update the status of the advertising data in the MySQL database to 3, which is the third state of successful processing, and the status of the advertising data in the elasticsearch open source search engine library is updated to 3, which is the third state of successful processing.
[0070] Specifically, regarding marking the status of the advertising data in the Elasticsearch open source search engine library as the initial first state, that is, after saving the advertising data to the Elasticsearch open source search engine library, the status of the advertising data is marked as the initial first state to indicate that the data has been successfully saved in the search engine.
[0071] Then call the message status confirmation system to update the status of the advertisement data in the MySQL database to the third state of successful processing: By calling the message status confirmation system, the status of the corresponding advertisement data in the MySQL database is updated to the third state of successful processing. This step ensures the consistency of data in different storage media.
[0072] The status of the advertisement data in the Elasticsearch open source search engine library is updated to the third status of successful processing: At the same time, the status of the corresponding advertisement data in Elasticsearch also needs to be updated to the third status of successful processing to maintain consistency with the status in the database.
[0073] In this step, the status marking and update operations ensure that the advertising data in the Elasticsearch open source search engine library and the MySQL database are consistent, avoiding data inconsistency problems. In addition, the data can be updated synchronously in different storage media in a timely manner, ensuring the integrity and accuracy of the data. And by confirming the system call and status update operations, the stability and reliability of the system are improved, and the risk of data loss or error is reduced.
[0074] For example, in an e-commerce platform, for the processing flow of advertising data, when the advertising data is successfully saved in the Elasticsearch open source search engine library, the present invention will automatically mark the data status as the initial first status, and call the message status confirmation system to update the status of the advertising data in the MySQL database to the third status of successful processing. At the same time, the advertising data status in Elasticsearch is also updated to the third status of successful processing.
[0075] For example, when an advertiser adds a new piece of advertising data and successfully saves it in Elasticsearch, the present invention will mark the advertising data status as the initial state, call the message status confirmation system, update the corresponding advertising data status in the database to the state of successful processing, and update the advertising data status in Elasticsearch to the state of successful processing. In this way, the consistency of the advertising data status in the database and Elasticsearch is guaranteed, ensuring the accuracy and integrity of the data.
[0076] In the embodiment of the present invention, further, after step S400, the following steps are further included:
[0077] Step S500, start the scheduled task of the message recovery system, execute the scheduled task once every 3 seconds, scan the MySQL database for advertising data with status 0 and status 1 for more than one minute, resend the message to the kafka message queue, and control the advertising data to be resent to the elasticSearch open source search engine library for storage.
[0078] In the embodiment of this step, regarding starting the scheduled task of the message recovery system, the system scheduled task is set to be executed every 3 seconds, the purpose of which is to scan the data in the MySQL database to process the message recovery operation.
[0079] As for scanning the advertising data with status 0 and status 1 in the MySQL database for messages that have been there for more than one minute, it is specifically explained as follows: In the embodiment of the present invention, when the scheduled task is executed, the advertising data with status 0 and status 1 in the MySQL database will be scanned. Regarding the advertising data with status 0 and status 1, please refer to the previous steps.
[0080] The present invention is about resending messages to the Kafka message queue. Specifically, for the scanned advertisement data that has not been successfully processed, the system will resend these messages to the Kafka message queue, which can ensure that the messages can be processed again and improve the reliability and integrity of the data.
[0081] Then control the advertisement data to be sent to the Elasticsearch open source search engine library for storage: At the same time, the system will control the advertisement data to be sent to the Elasticsearch open source search engine library for storage to ensure that the data can be stored and indexed smoothly.
[0082] The present invention uses scheduled tasks to scan unsuccessfully processed data, so that the system can timely discover and reprocess the data to achieve data recovery and remediation. The execution of scheduled tasks can help the system maintain stability, process abnormal data in a timely manner, and reduce the possibility of system errors. Resending advertising data to the Kafka message queue and the Elasticsearch open source search engine library ensures the integrity and accuracy of the data.
[0083] For example, in an e-commerce platform, if some advertising data fails to be successfully saved to the Elasticsearch open source search engine library due to network failure or system error, the scheduled task will scan the advertising data with a status of 0 or 1 in the MySQL database, resend the data to the Kafka message queue, and control the resending of the advertising data to Elasticsearch for storage.
[0084] For example, when an advertiser encounters a network problem while posting an ad, resulting in the data not being saved successfully in Elasticsearch, a scheduled task will be executed every 3 seconds to scan the abnormal data in the database and resend the data to the Kafka message queue and Elasticsearch for storage. This ensures data integrity, avoids data loss, and ensures the accuracy of system data.
[0085] In the embodiment of the present invention, further, after step S500, the following steps are further included:
[0086] Step S600, start the scheduled task of the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the MySQL database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3.
[0087] In the embodiment of this step, regarding starting the scheduled task of the message status confirmation system, specifically, the system scheduled task is set to be executed once every second, the purpose of which is to scan the advertising data in the Elasticsearch open source search engine library to perform data status confirmation and update operations.
[0088] Then scan the advertisement data whose data status is 0 in the Elasticsearch open source search engine library: Specifically, when the scheduled task is executed, the present invention scans the advertisement data whose data status is 0 in the Elasticsearch open source search engine library.
[0089] Then the control updates the status of the corresponding advertising data in the MySQL database to the processing success status 3: For the scanned advertising data, the system will update the status of the corresponding advertising data in the MySQL database to the processing success status 3, indicating that the data has been successfully processed.
[0090] Update the status of the corresponding advertising data in the Elasticsearch open source search engine library to processing success status 3: At the same time, the present invention will also update the status of the corresponding advertising data in the Elasticsearch open source search engine library to processing success status 3 to maintain the consistency of the data status in the database and the search engine library.
[0091] The purpose of this step is to ensure that the state of the advertising data stored in the Elasticsearch open source search engine library is consistent with the state of the data stored in the MySQL database, ensuring the accuracy and integrity of the data.
[0092] In this step, the advertisement data in Elasticsearch with data status 0 is scanned periodically. The status of the corresponding advertisement data in the MySQL database is updated to the processing success status 3; and the status of the corresponding advertisement data in Elasticsearch is updated to the processing success status 3. The benefit of this process is that the data status of the two data storage locations is ensured to be consistent, avoiding problems that may be caused by data confusion and inconsistency.
[0093] The method of the present invention is further described in detail below through a more specific application example:
[0094] like Figure 3 As shown, a multi-data source transaction processing method based on advertisement delivery in this specific application embodiment includes the following steps:
[0095] Step S11, start,
[0096] The specific embodiment of the present invention adopts Figure 3 The data processing architecture shown, the multi-data source transaction processing method described in this specific embodiment is implemented based on a preset data processing architecture, and the preset data processing architecture includes: an advertising data end, a MySQL database, an elasticSearch open source search engine library, and a message status confirmation system for confirming whether the data is received and a message recovery system for starting message retransmission; the advertising data end is connected to the MySQL database, and the advertising data end is also connected to the elasticSearch open source search engine library through a kafka reliable message queue; one end of the message status confirmation system is connected to the MySQL database and the other end is connected to the elasticSearch open source search engine library, and one end of the message recovery system is connected to the MySQL database and the other end is connected to the kafka reliable message queue. The present invention solves the problem of data inconsistency stored in different data sources.
[0097] In this specific embodiment, the advertisement data is first saved to the MySQL database through a local transaction. At this time, the data processing state of the advertisement data is marked as 0, that is, the initial state.
[0098] Step S12: Send the advertisement data to the Kafka message queue at the same time. If the sending is successful, update the status of the advertisement data in MySQL to 1 (data sending is successful);
[0099] Step S13: Control the consumer program to monitor the advertisement data in the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library;
[0100] When it is detected that the advertisement data is successfully saved to the elasticSearch open source search engine library, the status of the advertisement data in the elasticsearch open source search engine library is marked as 0, and the message status confirmation system is called to update the status of the advertisement data in the MySQL database to the processing success status 3, update the advertisement data in elasticsearch to the processing success status 3, and update the status of the advertisement data in the elasticsearch open source search engine library to the processing success status 3;
[0101] Step S14, start the scheduled task of the message recovery system, execute the scheduled task once every 3 seconds, scan the advertising data with status 0 and status 1 in the MySQL database one minute later, resend the message to the Kafka message queue, and control the advertising data to be resent to the elasticSearch open source search engine library for storage to prevent the advertising data in the elasticSearch open source search engine library from being inconsistent with the advertising data in MySQL.
[0102] Step S15, start the scheduled task of the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the mysql database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3.
[0103] It can be seen from the above that the data processing architecture of the embodiment of the present invention ensures the eventual consistency of data in two different types of databases. Steps S14 and S15 are to ensure that under abnormal circumstances, the data can be finally processed and the message can be sent to the kafka message queue, which can be completed in milliseconds. If the advertising data in the MySQL database has not changed its status to successfully sent for one minute, it is very likely that the message has been lost. Therefore, the scheduled task of step S14 is required to asynchronously scan the advertising data in the MySQL database table, resend the data whose status has not changed for more than one minute to the kafka message queue, and control the advertising data to be resent to the elasticSearch open source search engine library for storage.
[0104] There is another situation in the embodiment of the present invention, the kafka message queue may fail, resulting in the advertisement data cannot be sent to the kafka message queue. This may also cause the table status of the mysql database to not be updated, or even network processing problems, etc. In short, the scheduled task is a means to ensure that the data that has not updated the data status for more than a certain period of time is finally processed.
[0105] The status update scheduled task system in step S5 also ensures that the status of the advertisement data that has been successfully processed (successfully saved to elasticsearch) can be updated in the MySQL database. If for some reason, for example, after the advertisement data is successfully saved to the elasticsearch open source search engine library, the survey status update interface fails to update the advertisement data in the MySQL database, the Kafka message queue does not receive the ack (confirmation character) and the network is disconnected, etc., this will cause a large amount of successfully processed data to be repeatedly sent to Kakfa. Therefore, a scheduled task is needed for asynchronous message confirmation.
[0106] Exemplary Devices
[0107] like Figure 3 and Figure 4 As shown, an embodiment of the present invention provides a multi-data source transaction processing system based on advertisement delivery, the system comprising:
[0108] Advertisement data terminal 10, mysql database 20, elasticSearch open source search engine library 30, and a message status confirmation system 40 for confirming whether data has been received and a message recovery system 50 for starting message retransmission; the advertisement data terminal 10 is connected to the mysql database 20, and the advertisement data terminal 10 is also connected to the elasticSearch open source search engine library 30 through a kafka message queue; one end of the message status confirmation system 40 is connected to the mysql database 20 and the other end is connected to the elasticSearch open source search engine library 30, and one end of the message recovery system 50 is connected to the mysql database 20 and the other end is connected to the kafka message queue; the system also includes:
[0109] An acquisition marking module 310 is used to acquire advertisement data, save the advertisement data to the MySQL database 20 through a local transaction, and mark the data processing state of the advertisement data as an initial first state;
[0110] The message queue sending and marking module 320 is used to send the advertisement data to the kafka message queue at the same time, and when the sending is successful, update the state of the advertisement data in the mysql database to the second state of successful data sending;
[0111] The monitoring and saving module 330 is used to control the consumer program to monitor the advertisement data of the kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library;
[0112] The detection and marking module 340 is used to mark the state of the advertisement data in the elasticsearch open source search engine library as the initial first state when it is detected that the advertisement data is successfully saved in the elasticsearch open source search engine library, and to call the message state confirmation system to update the state of the advertisement data in the mysql database to the third state of successful processing, and to update the state of the advertisement data in the elasticsearch open source search engine library to the third state of successful processing;
[0113] The message recovery control module 350 is used to start the scheduled task of the message recovery system, execute the scheduled task every 3 seconds, scan the advertisement data in the MySQL database whose status is 0 and status is 1 for more than one minute, resend the message to the Kafka message queue, and control the advertisement data to be resent to the elasticSearch open source search engine library for storage;
[0114] The message status confirmation control module 360 is used to control the scheduled task of starting the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the MySQL database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3, as described above.
[0115] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 5 As shown. The intelligent terminal can be a stress test server for stress testing of the Internet production environment, including a processor, a memory, a network interface, a display screen, and a database connected through a system bus. Among them, the processor of the intelligent terminal is used to provide computing and control capabilities. The memory of the intelligent terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the intelligent terminal is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a multi-data source transaction processing method based on advertising delivery is implemented. The database of the intelligent terminal is used to store a multi-data source transaction processing program based on advertising delivery.
[0116] Those skilled in the art will understand that Figure 5The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the smart terminal to which the scheme of the present invention is applied. The specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0117] In one embodiment, a smart terminal is provided, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations:
[0118] Acquire advertisement data, save the advertisement data into a MySQL database through a local transaction, and mark the data processing state of the advertisement data as an initial first state;
[0119] At the same time, the advertisement data is sent to the kafka message queue. When the sending is successful, the state of the advertisement data in the mysql database is updated to the second state of successful data sending;
[0120] Control the consumer program to monitor the advertisement data in the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library;
[0121] When it is detected that the advertising data is successfully saved to the elasticSearch open source search engine library, the status of the advertising data in the elasticsearch open source search engine library is marked as the initial first state, and the message status confirmation system is called to update the status of the advertising data in the MySQL database to the third state of successful processing, and update the status of the advertising data in the elasticsearch open source search engine library to the third state of successful processing, as described above.
[0122] Wherein, the step of updating the status of the advertisement data in the elasticsearch open source search engine library and processing the successful status 3 includes:
[0123] Start the scheduled task of the message recovery system, execute the scheduled task every 3 seconds, scan the advertisement data in the MySQL database with status 0 and status 1 for more than one minute, resend the message to the kafka message queue, and control the advertisement data to be resent to the elasticSearch open source search engine library for storage.
[0124] Wherein, the step of updating the status of the advertisement data in the elasticsearch open source search engine library and processing the successful status 3 includes:
[0125] Start the scheduled task of the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the mysql database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3, as described above.
[0126] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0127] In summary, the present invention provides a multi-data source transaction processing method, system, intelligent terminal and storage medium based on advertising delivery, including: saving the advertising data to a mysql database through a local transaction, and marking the data processing status of the advertising data as the initial first state. When it is detected that the advertising data is successfully saved to the open source search engine library, the status of the advertising data in the open source search engine library is marked as the initial first state, and the message status confirmation system is called to update the status of the advertising data in the mysql database to the third state of successful processing, and update the status of the advertising data in the elasticsearch open source search engine library to the third state of successful processing. The present invention can perform message confirmation and message recovery on different data source data storages, achieve data consistency of different data source data storages, ensure the integrity of data storage, provide convenience for subsequent data use, and provide convenience for user use.
Claims
1. A multi-data source transaction processing method based on advertisement delivery, characterized in that: The multi-data source transaction processing method is implemented based on a preset data processing architecture, which includes: an advertisement data end, a MySQL database, an elasticSearch open source search engine library, and a message status confirmation system for confirming whether data has been received and a message recovery system for starting message retransmission; the advertisement data end is connected to the MySQL database, and the advertisement data end is also connected to the elasticSearch open source search engine library through a kafka message queue; one end of the message status confirmation system is connected to the MySQL database and the other end is connected to the elasticSearch open source search engine library, and one end of the message recovery system is connected to the MySQL database and the other end is connected to the kafka message queue; the multi-data source transaction processing method includes the following steps: Acquire advertisement data, save the advertisement data into a MySQL database through a local transaction, and mark the data processing state of the advertisement data as an initial first state; At the same time, the advertisement data is sent to the kafka message queue. When the sending is successful, the state of the advertisement data in the mysql database is updated to the second state of successful data sending; Control the consumer program to monitor the advertisement data in the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library; When it is detected that the advertising data is successfully saved to the elasticSearch open source search engine library, the status of the advertising data in the elasticsearch open source search engine library is marked as the initial first state, and the message status confirmation system is called to update the status of the advertising data in the MySQL database to the third state of successful processing, and update the status of the advertising data in the elasticsearch open source search engine library to the third state of successful processing.
2. The multi-data source transaction processing method based on advertisement delivery according to claim 1, characterized in that: The updating of the status of the advertisement data in the elasticsearch open source search engine library includes the following steps after the successful status 3: Start the scheduled task of the message recovery system, execute the scheduled task every 3 seconds, scan the advertisement data in the MySQL database with status 0 and status 1 for more than one minute, resend the message to the kafka message queue, and control the advertisement data to be resent to the elasticSearch open source search engine library for storage.
3. The multi-data source transaction processing method based on advertisement delivery according to claim 1, characterized in that: The updating of the status of the advertisement data in the elasticsearch open source search engine library includes the following steps after the successful status 3: Start the scheduled task of the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the mysql database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3.
4. The multi-data source transaction processing method based on advertisement delivery according to claim 1, characterized in that: The steps of obtaining the advertisement data, saving the advertisement data into the MySQL database through a local transaction, and marking the data processing state of the advertisement data as the initial state 0 include: The states of the pre-set advertisement data include: a first state which is an initial state 0, a second state which is a data sending success state 1, and a third state which is a data processing success state 3.
5. The multi-data source transaction processing method based on advertisement delivery according to claim 1, characterized in that: The steps of acquiring the advertisement data, saving the advertisement data into a MySQL database through a local transaction, and marking the data processing state of the advertisement data as an initial first state include: The advertisement data is obtained from the advertisement data terminal, the advertisement data is saved in the MySQL database through a local transaction, and the data processing state of the advertisement data is marked as 0, which is the initial first state.
6. The multi-data source transaction processing method based on advertisement delivery according to claim 1, characterized in that: The step of simultaneously sending the advertisement data to the kafka message queue and, when the sending is successful, updating the state of the advertisement data in the mysql database to a second state where the data is successfully sent comprises: At the same time, the advertisement data is sent to the kafka message queue. When the sending is successful, the state of the advertisement data in the MySQL database is updated to 1, which is the second state of successful data sending.
7. The multi-data source transaction processing method based on advertisement delivery according to claim 1, characterized in that: The steps of calling the message status confirmation system, updating the status of the advertisement data in the MySQL database to the third status of successful processing, and updating the status of the advertisement data in the elasticsearch open source search engine library to the third status of successful processing include: The message status confirmation system is called to update the status of the advertisement data in the MySQL database to 3, which is the third status of successful processing, and to update the status of the advertisement data in the elasticsearch open source search engine library to 3, which is the third status of successful processing.
8. A multi-data source transaction processing system based on advertisement delivery, characterized in that: The system comprises: an advertisement data terminal, a MySQL database, an elasticSearch open source search engine library, and a message status confirmation system for confirming whether data has been received and a message recovery system for starting message retransmission; the advertisement data terminal is connected to the MySQL database, and the advertisement data terminal is also connected to the elasticSearch open source search engine library through a kafka message queue; one end of the message status confirmation system is connected to the MySQL database and the other end is connected to the elasticSearch open source search engine library, and one end of the message recovery system is connected to the MySQL database and the other end is connected to the kafka message queue; the system further comprises: An acquisition marking module is used to acquire advertisement data, save the advertisement data into a MySQL database through a local transaction, and mark the data processing state of the advertisement data as an initial first state; A message queue sending and marking module is used to send the advertisement data to the kafka message queue at the same time, and when the sending is successful, update the state of the advertisement data in the mysql database to the second state of successful data sending; The monitoring and saving module is used to control the consumer program to monitor the advertisement data of the Kafka message queue in real time, consume and save the advertisement data to the elasticSearch open source search engine library; The detection and marking module is used to mark the state of the advertisement data in the elasticsearch open source search engine library as the initial first state when detecting that the advertisement data is successfully saved in the elasticsearch open source search engine library, and call the message state confirmation system to update the state of the advertisement data in the mysql database to the third state of successful processing, and update the state of the advertisement data in the elasticsearch open source search engine library to the third state of successful processing; The message recovery control module is used to start the scheduled task of the message recovery system. It executes the scheduled task every 3 seconds, scans the advertisement data in the MySQL database whose status is 0 and 1 for more than one minute, resends the message to the Kafka message queue, and controls the advertisement data to be resent to the elasticSearch open source search engine library for storage; The message status confirmation control module is used to control the scheduled task of starting the message status confirmation system, execute the scheduled task once every second, scan the advertising data with a data status of 0 in the elasticsearch open source search engine library, and control the status of the corresponding advertising data in the mysql database to be updated to the processing success status 3, and the status of the corresponding advertising data in the elasticsearch open source search engine library is updated to the processing success status 3.
9. An intelligent terminal, characterized in that: The device comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include being used to execute the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as described in any one of claims 1 to 7.
