Mail batch processing method, device, equipment and storage medium

By encoding and status identification processing of the function data in the target business system, and using distributed thing locks for parallel processing, the problems of excessive server pressure and insufficient stability in the prior art are solved, and the effect of improving throughput and stability is achieved.

CN111444013BActive Publication Date: 2025-05-09CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010182241.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-16
Publication Date
2025-05-09
Estimated Expiration
2040-03-16

AI Technical Summary

Technical Problem

In the prior art, when processing tasks to be generated, the server is under too much pressure, which can easily lead to server downtime and insufficient throughput and stability.

Method used

By adding letter encoding and status identification to the letter data in the target business system, query the letter data to be generated by paging, configure the number of thread pool threads in real time, and use distributed thing locks based on remote dictionary services for parallel processing, and batch generate push letters.

Benefits of technology

Improve the throughput and stability of handling tasks to be generated, avoiding excessive server pressure and downtime.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111444013B_ABST
    Figure CN111444013B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of research and development management, and discloses a letter batch processing method, device, equipment and storage medium, which are used to improve the throughput and stability of a target business system that processes letter tasks to be generated. The method comprises: adding letter codes to letter data in the target business system, and sorting the letter data according to the letter codes; querying and acquiring letter data in the letter state to be generated according to the state of the letter data by paging; adding a to-be-converted state identifier to the letter data in the letter state to be generated, and adding a converted state identifier to the letter data in the letter state to be generated; configuring the number of threads in a thread pool in real time according to the order of magnitude of the letter data in the letter state to be generated; generating a task queue according to the letter tasks to be generated corresponding to the letter data in the letter state to be generated; calling threads in the thread pool, using a distributed transaction lock based on a remote dictionary service to parallelly process the letter tasks to be generated in the task queue, and batch generating corresponding push letters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of R&D process optimization of R&D management, and in particular to a letter batch processing method, device, equipment and storage medium. Background Art

[0002] The processing flow of many business systems involves sending letters, which need to be generated before they are sent. In the existing letter generation mechanism, each task to be generated needs to start the corresponding thread one by one. Since the number of threads on the server is limited, when the number of tasks to be generated is large, it is easy to cause excessive pressure on the server, and in severe cases, it may even cause the server to crash. Summary of the invention

[0003] The main purpose of the present invention is to improve the throughput and stability of the target business system for processing the task of generating mail.

[0004] To achieve the above object, the present invention provides a first aspect of a mail batch processing method, comprising:

[0005] Adding a letter code to the letter data in the target business system, and sorting the letter data according to the letter code, wherein the status of the letter data includes a letter status to be generated and a letter status that has been generated;

[0006] According to the status of the letter data, query and obtain the letter data of the letter status to be generated in pages, wherein the letter data of the letter status to be generated is the data of the push letter to be generated;

[0007] Adding a to-be-converted state identifier to the mail data in the mail-to-be-generated state, and adding a converted state identifier to the mail data in the mail-to-be-generated state;

[0008] According to the magnitude of the mail data of the mail status to be generated, the number of threads in the thread pool is configured in real time;

[0009] Generate a task queue according to the tasks of the letters to be generated corresponding to the mail data in the mail status to be generated, wherein the tasks of the letters to be generated are tasks for processing the mail data in the mail status to be generated and pushing mails;

[0010] The threads in the thread pool are called, and the distributed transaction lock based on the remote dictionary service is used to parallelly process the tasks of the mails to be generated in the task queue, and push mails corresponding to the mail data of the mail status to be generated are generated in batches.

[0011] Optionally, in another implementation of the first aspect of the present invention, the parallel processing of the to-be-generated mail tasks in the task queue using a distributed transaction lock based on a remote dictionary service includes:

[0012] Using a distributed transaction lock based on a remote dictionary service to lock the letter data of the to-be-generated letter state in which the push letter is being generated;

[0013] Acquire the correspondence data corresponding to the locked state, and modify the to-be-converted state identifier of the correspondence data in the locked state to the locked state identifier;

[0014] Assembling the locked-state letter data and preset letter template data into hypertext markup language format data using input and output character streams and a preset toolkit;

[0015] Using the input and output file streams to generate corresponding hypertext markup language format files from the hypertext markup language format data;

[0016] Using a preset format conversion plug-in to convert the hypertext markup language format file into a push email in a corresponding portable document format;

[0017] Modify the locked state mark of the letter data corresponding to the push letter in the portable document format to a converted state mark;

[0018] Uploading the push letter in the portable document format to the business system that requires the push letter;

[0019] The distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

[0020] Optionally, in another implementation of the first aspect of the present invention, the threads in the calling thread pool use a distributed transaction lock based on a remote dictionary service to parallelly process the tasks of the mails to be generated in the task queue, and after batches of push mails corresponding to the mail data of the mail status to be generated are generated, the method includes:

[0021] Receive user's letter delivery request;

[0022] Searching for the corresponding generated push letter according to the letter sending request;

[0023] The thread in the calling thread pool sends the corresponding generated push email to the user.

[0024] Optionally, in another implementation of the first aspect of the present invention, after using the input and output file streams to generate a corresponding hypertext markup language format file from the hypertext markup language format data, the method further comprises:

[0025] Determining whether the generation of the corresponding hypertext markup language format file from the hypertext markup language format data is successful;

[0026] If it is determined that the generation is unsuccessful, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

[0027] Optionally, in another implementation of the first aspect of the present invention, after using the preset format conversion plug-in to convert the hypertext markup language format file into a push email in a corresponding portable document format, the method includes:

[0028] Determining whether the conversion of the hypertext markup language format file into a corresponding push mail in a portable document format is successful;

[0029] If it is determined that the conversion is unsuccessful, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

[0030] Optionally, in another implementation of the first aspect of the present invention, the use of a distributed transaction lock based on a remote dictionary service to lock the mail data of the mail to be generated, in which the mail data of the push mail is being generated, comprises:

[0031] Use remote dictionary-based services to obtain distributed transaction locks;

[0032] The thread corresponding to the mail data that is generating the push mail is locked according to the distributed transaction lock to obtain the mail data in the corresponding locked state.

[0033] Optionally, in another implementation of the first aspect of the present invention, before assembling the locked letter data and the preset letter template data into hypertext markup language format data using the input and output character streams and the preset toolkit, the method includes:

[0034] Determining whether the preset letter template data exists in a remote dictionary service storage system or a database based on distributed file storage;

[0035] If it is determined that the preset mail template data does not exist, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked mail data is completed;

[0036] If it is determined that the preset letter template data exists, the preset letter template data is retrieved from the remote dictionary service storage system or the database based on distributed file storage.

[0037] A second aspect of the present invention provides a mail batch processing device, comprising:

[0038] A coding and sorting module, used to add a letter code to the letter data in the target business system and sort the letter data according to the letter code, wherein the status of the letter data includes a letter status to be generated and a letter status that has been generated;

[0039] A paging query module, used for paging query and obtaining the mail data of the mail status to be generated according to the status of the mail data, wherein the mail data of the mail status to be generated is the data of the mail to be generated;

[0040] A status identification adding module, used for adding a to-be-converted status identification to the mail data in the mail status to be generated, and adding a converted status identification to the mail data in the mail status to be generated;

[0041] A thread configuration module, used for configuring the number of threads in the thread pool in real time according to the magnitude of the mail data of the mail status to be generated;

[0042] A task queue generation module, used for generating a task queue according to the tasks of the letters to be generated corresponding to the mail data in the mail status to be generated, wherein the tasks of the letters to be generated are tasks for processing the mail data in the mail status to be generated and pushing mails;

[0043] The letter batch generation module is used to call threads in the thread pool, use the distributed transaction lock based on the remote dictionary service to parallelly process the letter tasks to be generated in the task queue, and batch generate push letters corresponding to the letter data of the letter status to be generated.

[0044] Optionally, in another implementation of the second aspect of the present invention, the task queue generation module further includes:

[0045] A transaction lock unit, used for locking the letter data of the push letter being generated among the letter data in the state of the letter to be generated, using a distributed transaction lock implemented based on a remote dictionary service;

[0046] A first state identification modification unit is used to obtain the correspondence data corresponding to the locked state, and modify the to-be-converted state identification of the correspondence data in the locked state to the locked state identification;

[0047] A hypertext markup language format data assembling unit, used for assembling the locked letter data and the preset letter template data into hypertext markup language format data by using input and output character streams and a preset toolkit;

[0048] A hypertext markup language format file generating unit, used for generating a corresponding hypertext markup language format file from the hypertext markup language format data using an input and output file stream;

[0049] A file conversion unit, used for converting the hypertext markup language format file into a push mail in a corresponding portable document format using a preset format conversion plug-in;

[0050] A second state identification modification unit, used for modifying the locked state identification of the letter data corresponding to the push letter in the portable document format to a converted state identification;

[0051] An uploading unit, used for uploading the push letter in the portable document format to a business system that needs the push letter;

[0052] The distributed transaction lock releasing unit is used to release the distributed transaction lock and determine whether the processing of the to-be-generated letter task corresponding to the locked letter data is completed.

[0053] Optionally, in another implementation of the second aspect of the present invention, the letter batch processing device further includes:

[0054] A letter sending request receiving module is used to receive a letter sending request from a user;

[0055] A generated push letter search module is used to search for the corresponding generated push letter according to the letter sending request;

[0056] The mail sending module is used to call the thread in the thread pool to send the corresponding generated push mail to the user.

[0057] Optionally, in another implementation of the second aspect of the present invention, the hypertext markup language format file generating unit is further used to:

[0058] Determining whether the generation of the corresponding hypertext markup language format file from the hypertext markup language format data is successful;

[0059] If it is determined that the generation is unsuccessful, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

[0060] Optionally, in another implementation of the second aspect of the present invention, the file conversion unit is further used to:

[0061] Determining whether the conversion of the hypertext markup language format file into a corresponding push mail in a portable document format is successful;

[0062] If it is determined that the conversion is unsuccessful, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

[0063] Optionally, in another implementation of the second aspect of the present invention, the transaction lock unit is further used to:

[0064] The method of using a distributed transaction lock based on a remote dictionary service to lock the mail data of the mail to be generated and the mail data of the push mail being generated includes:

[0065] Use remote dictionary-based services to obtain distributed transaction locks;

[0066] The thread corresponding to the mail data that is generating the push mail is locked according to the distributed transaction lock to obtain the mail data in the corresponding locked state.

[0067] Optionally, in another implementation of the second aspect of the present invention, the letter task to be generated further includes:

[0068] A template data judging unit, used for judging whether there is preset letter template data in the remote dictionary service storage system or in the database based on distributed file storage;

[0069] A release unit, for releasing the distributed transaction lock if it is determined that the preset mail template data does not exist, and determining that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed;

[0070] The template data acquisition unit is used to retrieve the preset letter template data from the remote dictionary service storage system or the database based on distributed file storage if it is determined that the preset letter template data exists.

[0071] The third aspect of the present invention provides a mail batch processing device, comprising: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a line; the at least one processor calls the instructions in the memory so that the mail batch processing device executes the method described in the first aspect above.

[0072] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in the first aspect.

[0073] In the technical solution provided by the present invention, a letter code is added to the letter data in the target business system, and the letter data is sorted according to the letter code, and the status of the letter data includes a letter status to be generated and a generated letter status; according to the status of the letter data, the letter data in the letter status to be generated is queried and obtained in pages, and the letter data in the letter status to be generated is the data of the push letter to be generated; a to-be-converted state identifier is added to the letter data in the letter status to be generated, and a converted state identifier is added to the letter data in the generated letter status; according to the order of magnitude of the letter data in the letter status to be generated, the number of threads in the thread pool is configured in real time; a task queue is generated according to the letter tasks to be generated corresponding to the letter data in the letter status to be generated, and the letter tasks to be generated are tasks for processing the push letters in the letter data in the letter status to be generated; the threads in the thread pool are called, and the letter tasks to be generated in the task queue are processed in parallel using the distributed transaction lock implemented based on the remote dictionary service, so as to batch generate the push letters corresponding to the letter data in the letter status to be generated. The embodiment of the present invention realizes calling threads in a thread pool to process the tasks of mails to be generated in parallel, so as to achieve the effect of batch generating and pushing mails, thereby improving the throughput and stability of the target business system for processing the tasks of mails to be generated. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 A schematic diagram of an embodiment of a method for batch processing of letters in an embodiment of the present invention;

[0075] Figure 2 A schematic diagram of another embodiment of the method for batch processing of letters in an embodiment of the present invention;

[0076] Figure 3 A schematic diagram of an embodiment of a mail batch processing device in an embodiment of the present invention;

[0077] Figure 4 It is a schematic diagram of another embodiment of the mail batch processing device in the embodiment of the present invention;

[0078] Figure 5 Schematic diagram of an embodiment of a mail batch processing device in an embodiment of the present invention. DETAILED DESCRIPTION

[0079] The embodiments of the present invention provide a method, device, equipment and storage medium for batch processing of mails, which are used to realize batch generation of push mails, so as to improve the throughput and stability of a target business system for processing tasks of mails to be generated.

[0080] In order to enable those skilled in the art to better understand the solutions of the present invention, the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0081] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0082] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the mail batch processing method in the embodiment of the present invention includes:

[0083] 101. Add a letter code to the letter data in the target business system and sort the letter data by the letter code. The status of the letter data includes the status of the letter to be generated and the status of the letter that has been generated.

[0084] Specifically, the processing flow of the target business system of the present invention involves the sending of letters, and the letter data includes information such as the content and format of the letter; the server adds a status identifier and a letter code to the letter data in the target business system, and sorts them according to the letter code. By adding a status identifier to the letter data, it is possible to quickly distinguish in the target business system which letter data has generated a push letter and which letter data has not yet generated a push letter state, so as to facilitate querying or detecting the status of the letter data in the target business system. By adding a letter code to the letter data in the target business system and sorting them according to the letter code, the present invention can facilitate further cyclic processing of the letter tasks to be generated corresponding to the letter data in the state of generating a letter.

[0085] 102. According to the status of the letter data, query and obtain the letter data in the status of the letter to be generated by paging, where the letter data in the status of the letter to be generated is the data of the push letter to be generated.

[0086] Specifically, the server queries and obtains the mail data in the state of the mail to be generated according to the state of the mail data, and the mail data in the state of the mail to be generated is the data of the push mail to be generated. In the specific implementation, since the mail data has been added with the mail code, the sorted mail data can be queried in pages, and the mail data in the state of the mail to be generated can be obtained, that is, the data of the push mail to be generated in the target business system, such as the data of the push mail to be generated containing information such as the mail content and mail format.

[0087] 103. A pending conversion status mark is added to the correspondence data in the status of to-be-generated correspondence, and a converted status mark is added to the correspondence data in the status of already-generated correspondence.

[0088] Specifically, the server adds a pending conversion status flag to the letter data in the letter status to be generated, and adds a converted status flag to the letter data in the letter status to be generated. The above-mentioned pending conversion status flag and converted status flag in the present invention can be set according to specific needs and are not limited here.

[0089] 104. According to the magnitude of the mail data of the mail status to be generated, the number of threads in the thread pool is configured in real time.

[0090] Specifically, the server configures the number of threads in the thread pool in real time according to the order of magnitude of the letter data of the letter status to be generated. The present invention configures the number of threads in the thread pool in real time according to the order of magnitude of the letter data of the letter status to be generated, and can predict in advance the amount of tasks that the server should handle, thereby preventing the problem of excessive server load.

[0091] 105. Generate a task queue according to the letter-to-be-generated task corresponding to the letter data in the letter-to-be-generated state, where the letter-to-be-generated task is a task for processing the push letter being generated in the letter data in the letter-to-be-generated state.

[0092] Specifically, the server generates a task queue for the letter task to be generated corresponding to the letter data of the letter status to be generated. Since the existing business system has the problem of starting the corresponding threads one by one when processing each letter task to be generated, the present invention generates a task queue for each letter task to be generated, which can improve the efficiency of batch processing of letter generation tasks.

[0093] 106. Call the threads in the thread pool, use the distributed transaction lock based on the remote dictionary service to parallelly process the tasks of the letters to be generated in the task queue, and batch generate push letters corresponding to the letter data of the status of the letters to be generated.

[0094] Specifically, the server calls the threads in the thread pool, and uses the distributed transaction lock based on the remote dictionary service to parallelly process the letter tasks to be generated in the task queue, thereby batch generating the push letters corresponding to the letter data in the letter status to be generated. In the specific implementation, the server calls the threads in the thread pool, and uses the distributed transaction lock based on the remote dictionary service to parallelly process the letter tasks to be generated in the task queue, so as to obtain the push letters in batches, solving the problem that the current processing of each letter task to be generated requires starting the corresponding thread one by one, resulting in excessive pressure on the server and causing the server to crash when the number of letter tasks to be generated is large. The letter batch processing method of the present invention improves the throughput of the target business system that processes the letter tasks to be generated, and improves the stability of the target business system.

[0095] Furthermore, the server can also cyclically process the letter tasks to be generated corresponding to the letter data in the letter status to be generated according to the sorting order of the letter codes, thereby improving the efficiency of batch generation of push letters. By cyclically processing the letter tasks to be generated, push letters can be generated in batches.

[0096] Furthermore, the server can also detect whether the push mail corresponding to the mail data in the mail state to be generated is lost according to the mail code of the mail data in the target business system, as well as the state identification to be converted and the converted state identification. If a certain push mail is determined to be lost, a thread called from the thread pool processes the mail task to be generated corresponding to the push mail, or puts the mail task to be generated corresponding to the push mail into the task queue. For example, some mail data with a locked state identification added is lost because the push mail generated by it is lost, resulting in the mail data in the target business system corresponding to this part of the lost push mail having neither the state identification to be converted nor the converted state identification. Therefore, according to the mail code of the mail data in the target business system, as well as the state identification to be converted and the converted state identification, it can be detected whether the push mail corresponding to the mail data in the mail state to be generated is lost. If a certain push mail is determined to be lost, it is necessary to reprocess the mail task to be generated corresponding to the push mail.

[0097] In addition, the server can also predict the current mail generation task processing volume based on the historical mail generation task processing volume, and dynamically adjust the number of threads in the thread pool based on the predicted current mail generation task processing volume.

[0098] Specifically, after the server processes the batch generation of push mails in parallel, it calls the thread in the thread pool to handle the task of sending mails to the user side according to the letter sending request received from the user. In specific implementation, after calling the thread in the thread pool, the distributed transaction lock based on the remote dictionary service is used to parallelly process the tasks of the mails to be generated in the task queue, and the push mails corresponding to the mail data of the mail status to be generated are generated in batches, the server can also receive the user's mail sending request; and according to the letter sending request, the corresponding generated push mail is found in all the push mails generated in batches; further, the server also calls the thread in the thread pool to send the corresponding generated push mail to the user, so as to achieve the purpose of quickly feeding back the generated corresponding push mail to the user according to the user's needs.

[0099] Furthermore, before generating a task queue for the letter task to be generated corresponding to the letter data of the letter status to be generated, it also includes: when a user's letter generation request for a push letter is received, a high priority mark is added to the letter task to be generated corresponding to the push letter, and the letter task to be generated corresponding to the push letter is placed in front of all other letter tasks to be generated in the letter data of the letter status to be generated for priority processing; or the letter task to be generated corresponding to the push letter is placed at the first place in the task queue for priority processing, so as to complete the priority processing of the letter task to be generated corresponding to the push letter, so as to quickly feed back the generated push letter to the user, thereby achieving the effect of priority processing of special letters.

[0100] Furthermore, the server may also use a counter to monitor idle threads in the thread pool, and reduce the value of the counter by one each time a thread in the thread pool is called.

[0101] In specific implementation, the server monitors the idle threads in the thread pool through a counter, and reduces the counter value by one each time a thread in the thread pool is called. When the counter value is zero, the current to-be-generated mail task in the mail data of the to-be-generated mail status is added to the task queue. That is, the processing status of the threads in the thread pool is monitored through the counter. When the counter is zero, it means that all threads in the thread pool are processing tasks and there are no idle threads. The to-be-generated mail task generation task queue corresponding to the mail data of the to-be-generated mail status continues to process while waiting for an idle thread.

[0102] As can be seen from the above, the method of the present invention adds a letter code to the letter data in the target business system, and sorts the letter data according to the letter code; according to the status of the letter data, paging query and obtain the letter data of the letter status to be generated; add a to-be-converted status mark to the letter data of the letter status to be generated, and add a converted status mark to the letter data of the generated letter status; according to the order of magnitude of the letter data of the letter status to be generated, the number of threads in the thread pool is configured in real time; according to the letter tasks to be generated corresponding to the letter data of the letter status to be generated, a task queue is generated; the threads in the thread pool are called, and the distributed transaction lock based on the remote dictionary service is used to parallelly process the letter tasks to be generated in the task queue, and the corresponding push letters are generated in batches. The present invention realizes calling the threads in the thread pool to parallelly process the letter tasks to be generated, so as to generate push letters in batches; and improves the throughput and stability of the target business system that processes the letter tasks to be generated.

[0103] For further information, see Figure 2 In another embodiment of the mail batch processing method in the embodiment of the present invention, the task of processing the mail data in the mail-to-be-generated state to generate a push mail specifically includes:

[0104] 201. Use a distributed transaction lock implemented based on a remote dictionary service to lock the letter data of the letter to be generated, which is currently generating the push letter.

[0105] Specifically, when the server processes the task of the letter to be generated, the letter data of the push letter being generated is locked by the distributed transaction lock based on the remote dictionary service. The red lock algorithm can be used to obtain the distributed transaction lock using the remote dictionary service; and the thread corresponding to the letter data of the push letter being generated is locked according to the distributed transaction lock to obtain the letter data in the corresponding locked state. And further set the timeout time of the distributed transaction lock, the timeout time of the distributed transaction lock is used to limit the execution time of the task of processing the letter data of the push letter being generated corresponding to the letter data to be generated. For example, when the thread corresponding to the letter data of the push letter being generated has not been executed after reaching the timeout time, the server will release the distributed transaction lock and automatically interrupt the thread to execute the thread of the next letter task to be generated. By locking each thread corresponding to the letter data of the push letter being generated, setting the corresponding timeout time, and processing the thread of the next letter task to be generated after releasing the distributed transaction lock, the purpose of processing all the letter tasks to be generated by polling is achieved. Therefore, the distributed transaction lock implemented based on the remote dictionary service can coordinate the tasks of the mails to be generated processed by multiple threads in the server to improve the operation stability of the server.

[0106] 202. Obtain mail data corresponding to the locked state, and modify the to-be-converted state identifier of the mail data in the locked state to the locked state identifier.

[0107] Specifically, after locking with a distributed transaction lock, the server further obtains the corresponding locked mail data and modifies the pending conversion status identifier of the locked mail data to a locked status identifier. The locked status identifier of the present invention can be set according to specific needs and is not limited here.

[0108] Furthermore, step 202 further includes:

[0109] Determine whether the modification of the pending state flag to the locked state flag is successful.

[0110] If it is determined that the modification is unsuccessful, the distributed transaction lock is released, and the processing of the to-be-generated mail task corresponding to the locked mail data is determined to be completed.

[0111] In specific implementation, the server determines whether the modification of the state identifier to be converted to the locked state identifier is successful. If it is determined that the modification fails, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked state mail data is completed. That is, when the modification of the identifier of the locked state mail data fails, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked state mail data is completed. Even if the modification of the identifier of the locked state mail data is unsuccessful, the processing of the generated mail task corresponding to the locked state mail data has been completed, and the next step of processing will not be performed. In this case, the distributed transaction lock should be released accordingly, and the thread processing the generated mail task should be vacated, so that the vacated idle thread can be transferred to process other tasks.

[0112] 203. Use input and output character streams and a preset toolkit to assemble locked-state letter data and preset letter template data into hypertext markup language format data.

[0113] Specifically, before the server uses the input and output character streams and the preset toolkit to assemble the locked-state letter data and the preset letter template data into the hypertext markup language format data, it needs to retrieve the preset letter template data from the remote dictionary service storage system or the database based on the distributed file storage. The preset toolkit is a unique Java toolkit using the standard universal markup language, such as the Jdom toolkit; the preset letter template data includes the fixed letter format, fixed letter tag, fixed letter signature and other contents, which are not limited here. The preset letter template data and the fixed-state letter data can be assembled into the hypertext markup language format data through the input and output character streams and the preset toolkit.

[0114] Furthermore, before step 203, the letter task to be generated also includes:

[0115] It is determined whether there is preset letter template data in the remote dictionary service storage system or in the database based on distributed file storage.

[0116] If it is determined that there is no preset mail template data, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked mail data is completed.

[0117] If it is determined that there is preset letter template data, the preset letter template data is retrieved from the remote dictionary service storage system or the database based on distributed file storage.

[0118] Specifically, the server pre-determines whether there is preset letter template data in the remote dictionary service storage system or the database based on distributed file storage. When it is determined that there is no preset letter template data in the remote dictionary service storage system or the database based on distributed file storage, that is, the letter template is not pre-set, the distributed transaction lock is released, and it is determined that the processing of the letter task to be generated corresponding to the locked letter data is completed. That is, if there is no preset letter template data in the remote dictionary service storage system or the database based on distributed file storage, the letter generation task corresponding to the locked letter data has been processed and no further processing is performed. Accordingly, the distributed transaction lock should be released, and the thread processing the letter generation task will be vacated, so that the vacated idle thread can be transferred to process other tasks.

[0119] 204. Use the input and output file streams to generate corresponding hypertext markup language format files from the hypertext markup language format data.

[0120] Specifically, the server further uses the input and output file streams to generate corresponding hypertext markup language format files from the hypertext markup language format data.

[0121] Furthermore, after step 204, the letter task to be generated also includes:

[0122] Determining whether the generation of the corresponding hypertext markup language format file from the hypertext markup language format data is successful;

[0123] If it is determined that the generation is unsuccessful, the distributed transaction lock is released, and the processing of the to-be-generated mail task corresponding to the locked mail data is determined to be completed.

[0124] Specifically, the server continues to determine whether the generation of the corresponding hypertext markup language format file from the hypertext markup language format data is successful, and when it is determined that the generation of the hypertext markup language format file from the hypertext markup language format data fails, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked mail data is completed. That is, if the generation of the hypertext markup language format file from the hypertext markup language format data fails, the mail generation task corresponding to the locked mail data has been processed and no further processing is performed. Accordingly, the distributed transaction lock should be released, and the thread processing the mail generation task should be vacated so that the vacated idle thread can be transferred to process other tasks.

[0125] 205. Use a preset format conversion plug-in to convert the hypertext markup language format file into a push email in a corresponding portable document format.

[0126] Specifically, the server further uses a preset format conversion plug-in to convert the hypertext markup language format file into a push email in the corresponding portable document format. When the present invention is implemented, the preset format conversion plug-in is used to convert the format of the file from a hypertext markup language format file to a corresponding portable document format, such as a wkhtmltopdf plug-in, which is not limited here.

[0127] Furthermore, after step 205, the task to be generated includes:

[0128] Determine whether the conversion of the hypertext markup language format file into the corresponding push mail in portable document format is successful.

[0129] If it is determined that the conversion is unsuccessful, the distributed transaction lock is released, and the processing of the to-be-generated mail task corresponding to the locked mail data is determined to be completed.

[0130] In specific implementation, the server determines whether the conversion of the hypertext markup language format file into the corresponding portable document format push mail is successful. When it is determined that the conversion of the hypertext markup language format file into the corresponding portable document format push mail fails, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked mail data is completed. That is, if the conversion of the hypertext markup language format file into the corresponding portable document format push mail fails, the processing of the generated mail task corresponding to the locked mail data has been completed, and the next step of processing will not be performed. Accordingly, the distributed transaction lock should be released, and the thread processing the generated mail task will be vacated, so that the vacated idle thread can be transferred to process other tasks.

[0131] 206. Modify the locked state flag of the letter data corresponding to the push letter in the portable document format to a converted state flag.

[0132] Specifically, the server further modifies the locked state flag of the letter data corresponding to the push letter in the portable document format into a converted state flag.

[0133] 207. Upload the push letter in portable document format to the business system that needs to push the letter.

[0134] Specifically, the server further uploads the push letter in the portable document format to the business system that needs to push the letter.

[0135] Furthermore, after step 205, the task to be generated includes:

[0136] Determine whether the push mail in portable document format is successfully uploaded to the business system that needs the push mail.

[0137] If it is determined that the upload is unsuccessful, the distributed transaction lock is released, and the processing of the to-be-generated mail task corresponding to the locked mail data is determined to be completed.

[0138] Specifically, the server determines whether the push mail in the portable document format is successfully uploaded to the business system that needs the push mail. When the generated push mail fails to be uploaded to the business system that needs the push mail, the distributed transaction lock is released, and it is determined that the task of the mail to be generated corresponding to the locked mail data has been processed. Even if the push mail upload is unsuccessful, and the task of generating mail corresponding to the push mail has been processed, the distributed transaction lock should be released accordingly, and the thread processing the task of generating mail should be vacated, so that the vacated idle thread can be transferred to process other tasks.

[0139] 208. Release the distributed transaction lock, and determine that the to-be-generated mail task corresponding to the locked mail data is completed.

[0140] Specifically, after uploading the push mail in the portable document format to the business system that needs to push the mail, the server releases the distributed transaction lock and determines that the task processing of the mail to be generated corresponding to the locked mail data is completed.

[0141] From the above, it can be seen that after using a distributed transaction lock to lock the letter data of the push letter being generated, the distributed transaction lock is released accordingly according to different specific situations, thereby achieving the effect of coordinating the letter tasks to be generated processed by multiple threads in the server, so as to improve the server operation throughput and stability.

[0142] The above describes the mail batch processing method in the embodiment of the present invention. The following describes the mail batch processing device in the embodiment of the present invention. Figure 3 , an embodiment of the mail batch processing device in the embodiment of the present invention includes:

[0143] The coding and sorting module 301 is used to add letter codes to the letter data in the target business system and sort the letter data according to the letter codes. The status of the letter data includes the status of the letter to be generated and the status of the letter that has been generated.

[0144] The paging query module 302 is used to query and obtain the mail data in the state of the mail to be generated according to the state of the mail data, and the mail data in the state of the mail to be generated is the data of the push mail to be generated.

[0145] The status identification adding module 303 is used to add a to-be-converted status identification to the mail data in the mail-generating status, and to add a converted status identification to the mail data in the mail-generating status.

[0146] The thread configuration module 304 is used to configure the number of threads in the thread pool in real time according to the magnitude of the mail data for which the mail status is to be generated.

[0147] The task queue generation module 305 is used to generate a task queue according to the letter tasks to be generated corresponding to the letter data in the letter status to be generated, and the letter tasks to be generated are tasks for processing the letter data in the letter status to be generated and pushing letters.

[0148] The mail batch generation module 306 is used to call threads in the thread pool, use the distributed transaction lock based on the remote dictionary service to parallelly process the mail tasks to be generated in the task queue, and batch generate push mails corresponding to the mail data of the mail status to be generated.

[0149] Optionally, in another implementation of the mail batch processing device of the present invention, as Figure 4 As shown, the task queue generation module 305 also includes:

[0150] The transaction lock unit 3051 is used to lock the mail data of the push mail being generated among the mail data in the mail-to-be-generated state by using the distributed transaction lock implemented based on the remote dictionary service.

[0151] The first state identification modifying unit 3052 is used to obtain the mail data corresponding to the locked state, and modify the to-be-converted state identification of the mail data in the locked state to the locked state identification.

[0152] The hypertext markup language format data assembling unit 3053 is used to assemble the locked letter data and the preset letter template data into hypertext markup language format data using the input and output character streams and the preset toolkit.

[0153] The hypertext markup language format file generating unit 3054 is used to generate a corresponding hypertext markup language format file from the hypertext markup language format data using the input and output file streams.

[0154] The file conversion unit 3055 is used to convert the hypertext markup language format file into a push email in the corresponding portable document format using a preset format conversion plug-in.

[0155] The second state flag modifying unit 3056 is used to modify the locked state flag of the letter data corresponding to the push letter in the portable document format to a converted state flag.

[0156] The uploading unit 3057 is used to upload the push mail in the portable document format to the business system that needs to push the mail.

[0157] The distributed transaction lock releasing unit 3058 is used to release the distributed transaction lock and determine whether the processing of the to-be-generated mail task corresponding to the locked mail data is completed.

[0158] Optionally, in another implementation of the mail batch processing device of the present invention, the mail batch processing device further includes:

[0159] A letter sending request receiving module is used to receive a letter sending request from a user;

[0160] A generated push letter search module is used to search for the corresponding generated push letter according to the letter sending request;

[0161] The mail sending module is used to call the threads in the thread pool to send the corresponding generated push mail to the user.

[0162] Optionally, in another implementation of the email batch processing device of the present invention, the hypertext markup language format file generating unit 3054 is further used to:

[0163] Determining whether the generation of the corresponding hypertext markup language format file from the hypertext markup language format data is successful;

[0164] If it is determined that the generation is unsuccessful, the distributed transaction lock is released, and the processing of the to-be-generated mail task corresponding to the locked mail data is determined to be completed.

[0165] Optionally, in another implementation of the mail batch processing device of the present invention, the file conversion unit 3055 is further used for:

[0166] Determine whether the conversion of the hypertext markup language format file into the corresponding push mail in portable document format is successful.

[0167] If it is determined that the conversion is unsuccessful, the distributed transaction lock is released, and the processing of the to-be-generated mail task corresponding to the locked mail data is determined to be completed.

[0168] Optionally, in another implementation of the mail batch processing device of the present invention, the transaction lock unit 3051 is further used to:

[0169] Use remote dictionary-based services to obtain distributed transaction locks;

[0170] The thread corresponding to the mail data of the push mail being generated is locked according to the distributed transaction lock to obtain the mail data in the corresponding locked state.

[0171] Optionally, in another implementation of the mail batch processing device of the present invention, the mail task to be generated further includes:

[0172] The template data judging unit is used to judge whether there is preset letter template data in the remote dictionary service storage system or the database based on distributed file storage.

[0173] The release unit is used to release the distributed transaction lock if it is determined that there is no preset letter template data, and determine that the processing of the to-be-generated letter task corresponding to the locked letter data is completed.

[0174] The template data acquisition unit is used to retrieve the preset letter template data from the remote dictionary service storage system or the database based on distributed file storage if it is determined that the preset letter template data exists.

[0175] above Figure 3 and Figure 4 The mail batch processing device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The mail batch processing device in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0176] Figure 5 1 is a schematic diagram of the structure of a mail batch processing device provided by an embodiment of the present invention. The mail batch processing device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 501 (for example, one or more processors) and a memory 509, and one or more storage media 508 (for example, one or more mass storage devices) storing application programs 507 or data 506. Among them, the memory 509 and the storage medium 508 can be short-term storage or permanent storage. The program stored in the storage medium 508 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the mail batch processing. Furthermore, the processor 501 can be configured to communicate with the storage medium 508 to execute a series of instruction operations in the storage medium 508 on the mail batch processing device 500.

[0177] The mail batch processing device 500 may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input and output interfaces 504, and / or one or more operating systems 505, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 5 The structure of the mail batch processing equipment shown in the figure does not constitute a limitation on the mail batch processing equipment, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.

[0178] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0179] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0180] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A mail batch processing method, characterized in that: include: Adding a letter code to the letter data in the target business system, and sorting the letter data according to the letter code, wherein the status of the letter data includes a letter status to be generated and a letter status that has been generated; According to the status of the letter data, query and obtain the letter data of the letter status to be generated in pages, wherein the letter data of the letter status to be generated is the data of the push letter to be generated; Adding a to-be-converted state identifier to the mail data in the mail-to-be-generated state, and adding a converted state identifier to the mail data in the mail-to-be-generated state; According to the magnitude of the mail data of the mail status to be generated, the number of threads in the thread pool is configured in real time; Generate a task queue according to the tasks of the letters to be generated corresponding to the mail data in the mail status to be generated, wherein the tasks of the letters to be generated are tasks for processing the mail data in the mail status to be generated and pushing mails; Calling threads in the thread pool, using a distributed transaction lock based on a remote dictionary service to parallelly process the tasks of the letters to be generated in the task queue, and batch generating push letters corresponding to the letter data of the states of the letters to be generated; The method of using a distributed transaction lock implemented based on a remote dictionary service to parallelly process the tasks of the letters to be generated in the task queue includes: using a distributed transaction lock implemented based on a remote dictionary service to lock the letter data of the letter data in the state of the letter to be generated, which is generating a push letter; obtaining the letter data corresponding to the locked state, and modifying the to-be-converted state identifier of the letter data in the locked state to a locked state identifier; using input and output character streams and a preset toolkit to assemble the letter data in the locked state and the preset letter template data into hypertext markup language format data; using input and output file streams to generate a corresponding hypertext markup language format file from the hypertext markup language format data; using a preset format conversion plug-in to convert the hypertext markup language format file into a corresponding push letter in a portable document format; modifying the locked state identifier of the letter data corresponding to the push letter in the portable document format to a converted state identifier; uploading the push letter in the portable document format to the business system that needs the push letter; releasing the distributed transaction lock, and determining that the processing of the letter task to be generated corresponding to the letter data in the locked state is completed.

2. The mail batch processing method according to claim 1, characterized in that: The threads in the calling thread pool use the distributed transaction lock based on the remote dictionary service to parallelly process the tasks of the mails to be generated in the task queue, and after batch generating the push mails corresponding to the mail data of the mail status to be generated, the method includes: Receive user's letter delivery request; Searching for the corresponding generated push letter according to the letter sending request; The thread in the calling thread pool sends the corresponding generated push email to the user.

3. The mail batch processing method according to claim 1, characterized in that: After the input and output file streams are used to generate the corresponding hypertext markup language format file from the hypertext markup language format data, the method includes: Determining whether the generation of the corresponding hypertext markup language format file from the hypertext markup language format data is successful; If it is determined that the generation is unsuccessful, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

4. The mail batch processing method according to claim 1, characterized in that: After the preset format conversion plug-in is used to convert the hypertext markup language format file into a push email in a corresponding portable document format, the method includes: Determining whether the conversion of the hypertext markup language format file into a corresponding push mail in a portable document format is successful; If it is determined that the conversion is unsuccessful, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the mail data in the locked state is completed.

5. The mail batch processing method according to claim 1, characterized in that: The method of using a distributed transaction lock based on a remote dictionary service to lock the mail data of the mail to be generated and the mail data of the push mail being generated includes: Use remote dictionary-based services to obtain distributed transaction locks; The thread corresponding to the mail data that is generating the push mail is locked according to the distributed transaction lock to obtain the mail data in the corresponding locked state.

6. The mail batch processing method according to any one of claims 1 to 5, characterized in that: Before the locked letter data and preset letter template data are assembled into hypertext markup language format data using input and output character streams and preset toolkit, the method includes: Determining whether the preset letter template data exists in a remote dictionary service storage system or a database based on distributed file storage; If it is determined that the preset mail template data does not exist, the distributed transaction lock is released, and it is determined that the processing of the to-be-generated mail task corresponding to the locked mail data is completed; If it is determined that the preset letter template data exists, the preset letter template data is retrieved from the remote dictionary service storage system or the database based on distributed file storage.

7. A mail batch processing device, characterized in that: include: A coding and sorting module, used to add a letter code to the letter data in the target business system and sort the letter data according to the letter code, wherein the status of the letter data includes a letter status to be generated and a letter status that has been generated; A paging query module, used for paging query and obtaining the mail data of the mail status to be generated according to the status of the mail data, wherein the mail data of the mail status to be generated is the data of the mail to be generated; A status identification adding module, used for adding a to-be-converted status identification to the mail data in the mail status to be generated, and adding a converted status identification to the mail data in the mail status to be generated; A thread configuration module, used for configuring the number of threads in the thread pool in real time according to the magnitude of the mail data of the mail status to be generated; A task queue generation module, used for generating a task queue according to the tasks of the letters to be generated corresponding to the mail data in the mail status to be generated, wherein the tasks of the letters to be generated are tasks for processing the mail data in the mail status to be generated and pushing mails; A letter batch generation module is used to call threads in a thread pool, use a distributed transaction lock based on a remote dictionary service to parallelly process letter tasks to be generated in the task queue, and batch generate push letters corresponding to letter data of the letter status to be generated; The method of using a distributed transaction lock implemented based on a remote dictionary service to parallelly process the tasks of the letters to be generated in the task queue includes: using a distributed transaction lock implemented based on a remote dictionary service to lock the letter data of the letter data in the state of the letter to be generated, which is generating a push letter; obtaining the letter data corresponding to the locked state, and modifying the to-be-converted state identifier of the letter data in the locked state to a locked state identifier; using input and output character streams and a preset toolkit to assemble the letter data in the locked state and the preset letter template data into hypertext markup language format data; using input and output file streams to generate a corresponding hypertext markup language format file from the hypertext markup language format data; using a preset format conversion plug-in to convert the hypertext markup language format file into a corresponding push letter in a portable document format; modifying the locked state identifier of the letter data corresponding to the push letter in the portable document format to a converted state identifier; uploading the push letter in the portable document format to the business system that needs the push letter; releasing the distributed transaction lock, and determining that the processing of the letter task to be generated corresponding to the letter data in the locked state is completed.

8. A mail batch processing device, characterized in that: The mail batch processing device comprises: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instructions in the memory to enable the mail batch processing device to execute the method according to any one of claims 1-6.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Data dumping method and device, electronic device and storage medium

    CN109165194A

  • Message transmission method based on encryption technology and terminal device

    CN109190394A