Home > Back-end >  Multithreaded processing data, modify data, how to ensure that data have results in line with expect
Multithreaded processing data, modify data, how to ensure that data have results in line with expect

Time:05-21

Such as title description: as a large quantities of data import, need to modify a database table field information and the need to use multi-thread asynchronous processing, if make sure asynchronous processing data consistent with the expected results, how to solve the asynchronous processing may occur when abnormal happen so database table, data rewriting the failure to deal with, search solution scheme, welcome comments

CodePudding user response:

CompletableFuture is not do this thing

CodePudding user response:

Suggest not to import and do the data processing, import file exists on the file server, or will the parsed data exists in the database or redis, generated by the import file number, contain a timestamp, and then provide the front-end processing interface or timing task polling data processing and
1, upload a file, parse the data, the database import table, generate fileNo, createTime and status (initial state is 0, pending), data can be found redis, key for fileNo
2, the front page provides query import untreated or process failure data in the table, can choose to deal with one of the import request or batch processing. Or by timing task processing, according to the createTime positive sequence processing, first create the first treatment, treatment success will import the status changed to 2 in the table, successful, otherwise into 1, deal with failure, next time continue to process,
  • Related