Method and system for asynchronous conversion and synchronous notification of document

Through RabbitMQ message queue and object storage service, asynchronous document conversion and synchronous notification are realized, solving the problems of poor user experience, high server load and insufficient storage security, and improving the scalability and stability of the system.

CN119211356APending Publication Date: 2024-12-27SHENZHEN JINNIU TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411351662.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Existing document conversion solutions require users to keep the network connected until the conversion is completed, resulting in poor user experience, increased server load, difficult to scale, and insufficient storage security and stability.

Method used

The RabbitMQ message queue realizes asynchronous decoupling of business services and conversion services. The client uploads files to the object storage service, the conversion service converts format and stores the result files. The business service pushes the result file address to the client, allowing the business service to quickly return and Independent expansion.

Benefits of technology

It improves the user experience, enhances the scalability and fault tolerance of the system, ensures high availability and persistence of files, avoids file loss and insufficient storage space in traditional solutions, and improves system stability and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211356A_ABST
    Figure CN119211356A_ABST
Patent Text Reader

Abstract

The invention discloses a document asynchronous conversion and synchronous notification method and system. The method comprises the steps that a client uploads a to-be-converted file to an object storage service through a Web interface; the client submits a conversion request to the business service through a Web interface; the business service receives the conversion request and generates request information, and sends the request information to the conversion service through a RabbitMQ message queue; the conversion service downloads a to-be-converted file from the object storage service according to the request information and performs format conversion to obtain a result file, uploads the result file to the object storage service, generates a conversion completion message and sends the conversion completion message to the business service through a RabbitMQ message queue; the business service obtains a storage address of the result file according to the conversion completion message, and pushes the storage address of the result file to the client in a notification form; and the client downloads the result file according to the storage address of the result file. According to the method, the user experience is remarkably improved, and the security of file storage is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a method and system for asynchronous conversion and synchronous notification of documents. Background Art

[0002] In current Web applications, users often need to convert PDF files into Office documents (such as Word, Excel, etc.) or perform optical character recognition (OCR) operations on documents. These operations are usually completed through the backend server. Specifically, after the user uploads the file to the server, the server performs the corresponding conversion processing and finally returns the result file to the user. This traditional document conversion solution usually includes the following steps: the first step is that the user uploads the file to the server through the front-end interface; the second step is that after the file is uploaded, the server-side application starts to process the file and performs document format conversion or OCR processing according to the user's needs; the third step is that after the conversion is completed, the server stores the generated result file locally or in a temporary directory, and returns the result file to the user through an HTTP response, or provides a download link.

[0003] This solution is currently the mainstream document conversion implementation method, which has certain feasibility and ease of use, but it also has some obvious limitations: first, after the user initiates a file conversion request, he needs to maintain a network connection until the conversion is completed. The conversion process may take several seconds or even minutes. The user can only wait passively and cannot interrupt the operation. If the user closes the browser or disconnects from the network during this period, the conversion task will be forced to terminate and the result file cannot be generated, resulting in a poor user experience.

[0004] Secondly, document conversion, especially the conversion of complex documents or OCR processing, often requires a large amount of computing resources (CPU, memory, etc.). When multiple users initiate conversion requests at the same time, the server load will increase significantly, which may affect the normal operation of other business functions and even cause the server to respond slowly, seriously affecting the stability of the system; thirdly, the conversion service is tightly coupled with the business service and cannot be expanded independently. If the number of conversion tasks in the system increases, users cannot only expand the conversion service, but must expand the server resources as a whole, which not only increases costs, but also makes it difficult to cope with sudden peak loads.

[0005] Finally, in traditional solutions, files are usually temporarily stored in the local file system of the server. This storage method has certain security risks, such as file loss, server failure, etc. In addition, as the number of users uploading files increases, the local storage space may be insufficient, further exacerbating the instability of the system. Summary of the invention

[0006] The purpose of the present invention is to provide a method and system for asynchronous document conversion and synchronous notification, aiming to solve the problem that the document conversion solution in the prior art requires maintaining a network connection to complete the conversion task, resulting in a poor user experience.

[0007] In a first aspect, an embodiment of the present invention provides a method for asynchronous conversion and synchronous notification of a document, comprising:

[0008] The client uploads the file to be converted to the object storage service through the web interface;

[0009] The client submits a conversion request to the business service through a Web interface, wherein the file parameters of the conversion request include the storage address and conversion type of the file to be converted;

[0010] The business service receives the conversion request and generates request information, and sends the request information to the conversion service through the RabbitMQ message queue;

[0011] The conversion service downloads the file to be converted from the object storage service according to the request information and performs format conversion to obtain a result file, uploads the result file to the object storage service, generates a conversion completion message and sends it to the business service through the RabbitMQ message queue;

[0012] The business service obtains the storage address of the result file according to the conversion completion message, and pushes the storage address of the result file to the client in the form of a notification;

[0013] The client downloads the result file according to the storage address of the result file.

[0014] In a second aspect, an embodiment of the present invention further provides a system for asynchronous conversion and synchronous notification of documents, which includes: a business service, a conversion service, and a client;

[0015] The client is used to upload the file to be converted to the object storage service through the Web interface;

[0016] The client is also used to submit a conversion request to the business service through a Web interface, wherein the file parameters of the conversion request include the storage address and conversion type of the file to be converted;

[0017] The business service is used to receive the conversion request and generate request information, and send the request information to the conversion service through the RabbitMQ message queue;

[0018] The conversion service is used to download the file to be converted from the object storage service according to the request information and perform format conversion to obtain a result file, upload the result file to the object storage service, and generate a conversion completion message and send it to the business service through the RabbitMQ message queue;

[0019] The business service is further used to obtain the storage address of the result file according to the conversion completion message, and push the storage address of the result file to the client in the form of a notification;

[0020] The client is also used to download the result file according to the storage address of the result file.

[0021] The embodiment of the present invention provides a method and system for asynchronous document conversion and synchronous notification. The method realizes asynchronous decoupling of business services and conversion services by using RabbitMQ message queues. The business service is responsible for processing the conversion request of the client and generating request messages, while the conversion service is responsible for consuming the request messages and performing conversion tasks, thereby improving the scalability and fault tolerance of the system. At the same time, the method also allows the business service to quickly return to the client without waiting for the response of the conversion service, thereby improving the user experience and ensuring the flexibility and scalability of the system. Furthermore, when the amount of document conversion tasks increases, the system can cope with the load by increasing the number of conversion service instances, ensuring that the conversion tasks can be processed in time without affecting the normal operation of the business system. Secondly, by storing files in OSS, the high availability and persistence of files are ensured, avoiding the file loss and insufficient storage space problems caused by local storage in traditional document conversion solutions, and improving the stability and security of the system. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0023] Figure 1 A flowchart of a method for asynchronous document conversion and synchronous notification provided by an embodiment of the present invention;

[0024] Figure 2 A schematic diagram of a sub-flow diagram of a method for asynchronous document conversion and synchronous notification provided by an embodiment of the present invention;

[0025] Figure 3 A schematic diagram of another sub-flow of the method for asynchronous document conversion and synchronous notification provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0028] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0029] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0030] See also Figure 1 , Figure 1 A flowchart of a method for asynchronous document conversion and synchronous notification provided by an embodiment of the present invention, the method comprises steps S101 to S106:

[0031] S101, the client uploads the file to be converted to the object storage service through the web interface;

[0032] In this embodiment, after the client connects to the server through the Web interface, it uploads the file to be converted (file to be converted) to the object storage service (OSS). OSS is a high-availability, durable and secure storage solution that can effectively store client files and support large-scale concurrent access.

[0033] Specifically, on the web interface, there is usually a file upload form element that allows the client (user) to browse and select files on the local computer. The form can be configured to support single or multiple file uploads as needed. In client-side JavaScript, implementing the file upload function usually involves listening to the selection event of the file input and building an HTTP request (such as POST) to send the file to be converted to the server. Then, the server (which may be a web server or API gateway) receives the file upload request and uploads the file to be converted to the specified bucket and path of the OSS.

[0034] It should be noted that before uploading the file to be converted, the server may need to perform user verification and permission checks to ensure that the user has the right to upload the file. Usually, AccessKey ID and AccessKey Secret (or similar mechanisms) are used to verify the identity of the requester (client). Once the user verification and permission check are passed, the client can start uploading the file to be converted. During the upload process, the client needs to send its client ID along with the file to be converted to the server. After receiving the file, the server binds the file to be converted with the client ID, so that this association is recorded in the metadata of the object storage service so that the file to be converted can be referenced in subsequent processing.

[0035] S102, the client submits a conversion request to the business service through a Web interface, wherein the file parameters of the conversion request include the storage address and conversion type of the file to be converted;

[0036] In this embodiment, the user first selects the type of file conversion that he or she wishes to perform (e.g., from PDF to Word, or from JPEG to PNG, etc.) through an option or a drop-down menu on the Web interface.

[0037] As described in the above step S101, the user has uploaded the file to be converted to the object storage service (OSS) and obtained the storage address of the file to be converted. The client will collect the conversion type selected by the user and the storage address of the file to be converted. The information collected by the client is encapsulated into a conversion request of an HTTP request, which is ready to be sent to the business service. Specifically, AJAX, FetchAPI or other HTTP client libraries can be used. The client sends the constructed conversion request to the specified endpoint of the business service, and then the business service listens to the conversion request from the client and parses the file parameters in the conversion request.

[0038] It should be noted that the storage address is the storage location of the file to be converted in OSS, usually a URL, which the business service will use to access and download the file. The conversion type is a parameter that identifies the required conversion type, which tells the business service which format the file will be converted to.

[0039] In one embodiment, the file parameters further include a client ID.

[0040] In this embodiment, the client ID is used to uniquely identify the client or user who initiated the conversion request. This can be a temporary ID based on the user session or a long-term unique identifier of the user (such as a user ID). Before the business service processes the conversion request, the client ID can be used to verify whether the user or device that initiated the request has the authority to perform the operation, which helps to enhance the security of the system. The client ID enables the business service to track and record the initiator of each conversion request, which plays an important role in the subsequent user behavior analysis.

[0041] S103, the business service receives the conversion request and generates request information, and sends the request information to the conversion service through the RabbitMQ message queue;

[0042] In this embodiment, after receiving the user's conversion request, the business service generates a request message, which contains the storage address of the file to be converted, the conversion type, and other necessary metadata attributes, and is serialized. The request message is asynchronously sent to the conversion service through the RabbitMQ message queue. Through the RabbitMQ message queue, the communication between the business service and the conversion service is asynchronously decoupled, which improves the scalability and fault tolerance of the system. At the same time, it also allows the business service to quickly return to the client without waiting for the response of the conversion service, thereby improving the user experience and ensuring the flexibility and scalability of the system.

[0043] Specifically, Figure 2 As shown, the step S103 includes steps S201 to S202:

[0044] S201, the business service verifies the file parameters in the conversion request, and after the verification passes, encapsulates the file parameters into a serialized data format to obtain request information;

[0045] In this embodiment, after the business service receives the user's conversion request, it encapsulates the request information into a message to generate the request information. Specifically, the client carries the user ID, the storage address of the file to be converted, the conversion type (such as from PDF to Word) and the password of the file to be converted to log in and access the business service. After the business service receives the user's conversion request, it performs parameter verification on the file parameters in the conversion request. The verification process includes checking whether the user ID is valid, whether the storage address of the file to be converted exists, whether the conversion type is supported, and whether the password of the file to be converted is correct. The purpose of the verification is to ensure that all necessary information is complete and correct so that subsequent processing can proceed smoothly. After the verification is passed, the file parameters are serialized to obtain the request information.

[0046] It should be noted that once the file parameters pass the verification, the business service will encapsulate (or serialize) these parameters into a specific data format. The serialization process is the process of converting data structures or object states into a format that can be stored or transmitted. In this scenario, the serialized data format may be JSON, XML, or other formats suitable for network transmission. The serialized data (i.e., request information) contains all the necessary conversion request information, but it is no longer the original file to be converted itself, but a reference to the file (such as the storage address) and the instructions required for the conversion.

[0047] S202: The business service sends the request information to the RabbitMQ message queue.

[0048] In this embodiment, the RabbitMQ message queue provides a variety of message confirmation mechanisms to ensure that the message is correctly received and processed. The business service first needs to establish a connection with the RabbitMQ message queue. The business service can configure these mechanisms to obtain feedback after the message is successfully sent to RabbitMQ. Once the connection is established, the business service can send the request information to the RabbitMQ message queue.

[0049] It should be noted that even if the RabbitMQ message queue confirms receipt of the message, it does not mean that the conversion service has processed the request message. The subsequent processing of the request message (such as file conversion) will be the responsibility of the conversion service listening to the queue.

[0050] S104: the conversion service downloads the file to be converted from the object storage service according to the request information and performs format conversion to obtain a result file, uploads the result file to the object storage service, generates a conversion completion message and sends it to the business service through the RabbitMQ message queue;

[0051] In this embodiment, the conversion service implements asynchronous processing and conversion of the converted files, and communicates efficiently with the business service through the RabbitMQ message queue, which improves the scalability and fault tolerance of the system, allowing the business service and the conversion service to be independently expanded and maintained. At the same time, it also allows the business service to continue processing other requests without waiting for the conversion service to complete the conversion, meeting the high-load conditions of multiple users initiating conversion requests at the same time or the same user issuing different task requests, and the system can still run efficiently, further enhancing the reliability of the system and improving the user experience.

[0052] Specifically, Figure 3 As shown, in the step S104, the conversion service downloads the file to be converted from the object storage service according to the request information and performs format conversion to obtain a result file, including steps S301 to S304:

[0053] S301, the conversion service obtains the request information from the RabbitMQ message queue;

[0054] In this embodiment, the conversion service continuously monitors the message queue specified in RabbitMQ, and when new information arrives, it takes the message from the RabbitMQ message queue. This message contains the request information sent by the business service, which has been serialized for transmission in the network.

[0055] S302: The conversion service deserializes the request message to obtain the storage address and conversion type of the file to be converted;

[0056] In this embodiment, after the conversion service obtains the message through the RabbitMQ message queue, it deserializes it to obtain the storage address and conversion type of the file to be converted, as well as attributes such as the user ID and the password of the file to be converted.

[0057] It should be noted that deserialization is the process of converting serialized data formats (such as JSON, XML, etc.) back to the original data structure or object. Through deserialization, the conversion service can extract the storage address and conversion type of the file to be converted.

[0058] S303: The conversion service downloads the file to be converted from the object storage service according to the storage address of the file to be converted;

[0059] In this embodiment, after obtaining the storage address of the file to be converted, the conversion service will initiate a request to the object storage service (OSS) to download the file to be converted. This request contains the storage address of the file to be converted and the conversion type, so that the object storage service can verify the validity of the request and return the file data.

[0060] S304: The conversion service performs format conversion on the file to be converted according to the conversion tool and the conversion type to obtain a result file.

[0061] In this embodiment, after the file to be converted is downloaded, the conversion service will convert the format of the file to be converted according to the conversion type specified in the request information and the available conversion tools. This conversion process includes complex processing logic, such as text parsing, image rendering, audio encoding, etc. After the conversion is completed, a new file (i.e., the result file) will be generated, indicating that the file to be converted has been converted according to the specified format.

[0062] Specifically, in step S104, uploading the result file to the object storage service includes step S401:

[0063] S401, binding the result file with the client ID;

[0064] In this embodiment, the result file is bound to the client ID, which ensures that only legitimate clients can access the corresponding result file, ensuring the security of the file data; at the same time, the result file is bound to the client ID, which also enables the business service to track and manage each client's file conversion request and its results. When the client needs to query the conversion status or download the result file, the business service can quickly find the corresponding file according to the client ID.

[0065] Specifically, before the business service uploads the result file to the object storage service, the business service needs to ensure that there is a clear association between the result file and the client that requested the conversion, that is, bind the result file to the client ID. After the binding is completed, the business service uploads the result file to the object storage service.

[0066] The following is a description of the principle of converting PDF documents to other formats, which is mainly divided into the following steps:

[0067] First, parse the PDF file. No matter what format you convert the document to, you first need to parse the PDF file to extract the text, images, charts, vector graphics and other contents in the file. Usually, a dedicated PDF parsing library (such as PDF.js, Poppler, Adobe PDF Library, etc.) is used to extract the content.

[0068] Second, process the content according to the target format. For example, different target formats require different content processing methods. For example, when extracting plain text from PDF in text format (such as TXT), the layout and style are usually ignored, and only the text content is retained. This is the simplest conversion method; for image formats (such as PNG, JPEG), each page of PDF is rendered as an image, and resolution, color, transparency and other issues usually need to be processed; for office formats (such as Word, Excel, PowerPoint), the layout and format need to be retained, and the content of PDF needs to be remapped into structured documents in these formats, and elements such as paragraphs, tables, images, headers and footers need to be reconstructed.

[0069] Third, keep the layout and format. During the conversion process, the complex layout of PDF must be processed, including: processing paragraphs and line breaks, specifically, determining the logical structure of paragraphs, titles, tables and other contents, and correctly reconstructing them in the target format; processing images and charts, specifically, extracting and maintaining the position and size of images or charts; processing fonts and styles, specifically, trying to match the fonts and styles in the target format to ensure similar appearance; processing the output target format, specifically, after the content is extracted and processed, it is output in the specified target format.

[0070] It should be noted that different formats of documents use different output methods. For example, text format is output by directly outputting to a plain text file; picture format is output by rendering each page to an image file; office format is output by using a document processing library (such as OpenXML, Apache POI, etc.) to generate the corresponding document format.

[0071] S105, the business service obtains the storage address of the result file according to the conversion completion message, and pushes the storage address of the result file to the client in the form of a notification;

[0072] In this embodiment, first, the business service needs to receive a conversion completion message from the conversion service. This message contains the result information of the conversion operation. The business service parses this message and extracts the storage address of the result file from it. Next, the business service uses the storage address of the result file as the main content of the notification. According to business needs, the notification may also contain other information, such as the success status of the conversion operation, the conversion time, the client ID, etc. Finally, the business service pushes the prepared notification to the client in an appropriate manner. The push method can be real-time push via WebSocket, sending a link via email, sending a notification code via SMS, and displaying a message in the client application, etc., depending on the client's business needs.

[0073] In one embodiment, in step S105, the business service obtains the storage address of the result file according to the conversion completion message, including step S601:

[0074] S601: Bind the storage address of the result file to the client ID.

[0075] In this embodiment, first, the business service needs to receive a conversion completion notification from the conversion service, and the business service parses the notification to extract the storage address of the result file; next, the business service binds the storage address to a specific client ID; finally, the business service stores the binding information of the storage address and the client ID in an appropriate storage medium, such as a database, cache system, etc., for subsequent use.

[0076] It should be noted that the client ID (user ID) under the logged-in client is regarded as a specific ID, or a specific ID is generated by the client under the unlogged-in client and stored locally to maintain the uniqueness of the current client. The file conversion task will be performed asynchronously in the background. After the conversion is completed, the business service is accessed through the specific ID to obtain the converted file. Because the connection is established with the business service through the specific ID, after the conversion service completes the asynchronous conversion, the business service binds the converted storage address with the specific ID. After the client connects to the network through the specific ID, it can find specific information and obtain the converted file, that is, the result file.

[0077] In one embodiment, in step S105, the storage address of the result file is pushed to the client in the form of a notification, including step S501:

[0078] S501. The business service pushes the storage address of the result file to the client in the form of a notification via SSE.

[0079] In this embodiment, SSE is a technology that allows business services to actively send updates to clients. It is based on the HTTP protocol, but unlike the traditional request-response model, SSE allows business services to keep the connection open and send business requests to clients when there are updates.

[0080] Specifically, first, the business service needs to configure and start an SSE service, which is used to maintain a persistent connection with the client. The client usually establishes an SSE connection by sending a request with a specific HTTP header to the server. When the conversion service completes the conversion task and sends a conversion completion message to the business service, the business service parses the message to obtain the storage address of the result file. Finally, the business service pushes the constructed SSE message to the client through the previously established SSE connection. After receiving the SSE message, the client can parse the storage address and access the result file accordingly.

[0081] In summary, this embodiment implements a long connection between the client and the business service through SSE technology, so that the user can still receive a notification of the completion of the conversion after the connection is disconnected, which solves the problem that the user must wait for the conversion to be completed in the traditional document conversion solution, and greatly improves the user experience.

[0082] S106: The client downloads the result file according to the storage address of the result file.

[0083] In this embodiment, as described in step S105, the client has received the storage address of the result file. First, the client can use an appropriate protocol (such as HTTP, FTP, etc.) to initiate a download request to the business service according to the storage address of the result file; then the business service responds to the download request and sends the result file to the client; finally, the client receives the result file and saves it to the local file system or the specified location of the application.

[0084] Specifically, the step S106 includes step S701:

[0085] S701: The client queries the conversion status of the corresponding file to be converted by logging in to the client ID, and downloads the result file after the conversion is completed.

[0086] In this embodiment, the client queries the conversion status of the corresponding file to be converted by logging in to the client ID, and downloads the result file after the conversion is completed. The purpose is to allow the user to understand the conversion progress of the file in real time, improve the user experience, and automatically or manually trigger the download of the result file after the conversion is completed to ensure that the user can obtain the converted file in time.

[0087] Specifically, first, the client needs to perform user login verification to ensure that only legitimate users can query the conversion status of the file. The login process includes entering a username and password, or through other authentication mechanisms (such as entering a token for verification, etc.). After successful login, the client uses the client ID to send a request to the business service to query the current status of all files to be converted associated with the ID. The business service checks the conversion progress of these files and returns the conversion status of each file (such as "Converting", "Conversion Successful", "Conversion Failed", etc.). The client parses the returned status information to check whether any files have been converted. If completed files are found, the client will obtain the storage address of these files. The client will use the storage address or download link to initiate a download request, obtain the result file from the object storage service, and save it locally or to a specified location.

[0088] In one embodiment, the method for asynchronous document conversion and synchronous notification further includes step S801:

[0089] S801. When the amount of document conversion tasks increases or decreases, the load is dealt with by increasing or decreasing conversion service instances.

[0090] In this embodiment, first, the system needs to monitor the load of the document conversion task in real time, including key indicators such as the current task volume, processing speed and response time. Set reasonable thresholds (such as the concurrent task volume exceeding the task volume threshold or the response time exceeding the time threshold, etc.), and when these thresholds are reached or exceeded, the system automatically triggers an early warning.

[0091] In this embodiment, the number of conversion service instances can be automatically adjusted when any condition is met. For example, if the current task volume exceeds the task volume threshold, the response time exceeds the time threshold, and the processing speed is lower than the speed threshold, the number of conversion service instances is increased. Alternatively, if the current task volume is lower than the task volume threshold, the response time is lower than the time threshold, and the processing speed exceeds the speed threshold, the number of conversion service instances is reduced.

[0092] At the same time, you can also set indicator weights for each key indicator, such as setting task volume weights, time weights, and speed weights, and normalize the current task volume, response time, and processing speed, and find the inverse of the processing speed, and then multiply them by the corresponding weights to get the comprehensive indicator score, and then compare the comprehensive indicator score with the score threshold. If it exceeds the score threshold, the number of conversion service instances is increased, and if it is lower than the score threshold, the number of conversion service instances is reduced.

[0093] For the key indicator of task volume, weights can also be set according to the resource usage of different types of document conversion tasks, and the usage of system resources (such as CPU or memory) of different types of document conversion tasks can be evaluated. Higher weights can be set for tasks with large resource consumption, and smaller weights can be set for tasks with small resource consumption. In other words, the weight of tasks with large system resource usage is higher than the weight of tasks with small system resource usage. In this way, when calculating the comprehensive score of the above indicators, the scores of different types of tasks can be calculated comprehensively according to the task type. For example, the task volume weight A1 of task A is higher than the task volume weight B1 of task B. In specific implementation, the number of tasks A a and the number of tasks B b can be calculated as A1*a+B1*b, and then the scores of key indicators such as response time and processing speed can be added to obtain the comprehensive score of the indicators.

[0094] Through the above settings, when the load is large, the current conversion service instance cannot process tasks in time, and the system can be expanded in time. After the expansion, the system adopts a load balancing strategy to distribute the newly added tasks to each conversion service instance. When the load is small, the current conversion service instance is surplus, and the system can be reduced to save resources. In other words, the system can automatically reduce the number of conversion service instances to save resources.

[0095] It should be noted that a load balancing algorithm (such as polling, least number of connections, source address hashing, etc.) is used to intelligently allocate conversion tasks to each conversion service instance to achieve balanced utilization of resources.

[0096] The embodiment of the present invention also provides a system for asynchronous conversion and synchronous notification of documents, including: a business service, a conversion service and a client;

[0097] The client is used to upload the file to be converted to the object storage service through the Web interface;

[0098] The client is also used to submit a conversion request to the business service through a Web interface, wherein the file parameters of the conversion request include the storage address and conversion type of the file to be converted;

[0099] The business service is used to receive the conversion request and generate request information, and send the request information to the conversion service through the RabbitMQ message queue;

[0100] The conversion service is used to download the file to be converted from the object storage service according to the request information and perform format conversion to obtain a result file, upload the result file to the object storage service, and generate a conversion completion message and send it to the business service through the RabbitMQ message queue;

[0101] The business service is further used to obtain the storage address of the result file according to the conversion completion message, and push the storage address of the result file to the client in the form of a notification;

[0102] The client is also used to download the result file according to the storage address of the result file.

[0103] In one embodiment, the business service includes:

[0104] A verification unit, used to verify the file parameters in the conversion request, and after the verification passes, encapsulate the file parameters into a serialized data format to obtain request information;

[0105] A sending unit is used to send the request information to the RabbitMQ message queue.

[0106] In one embodiment, the conversion service includes:

[0107] An acquiring unit, configured to acquire the request information from the RabbitMQ message queue;

[0108] A deserialization unit, used for deserializing the request message to obtain the storage address and conversion type of the file to be converted;

[0109] A downloading unit, configured to download the file to be converted from the object storage service according to the storage address of the file to be converted;

[0110] The conversion unit is used to perform format conversion on the file to be converted according to the conversion tool and the conversion type to obtain a result file.

[0111] The system achieves asynchronous decoupling of business services and conversion services by using RabbitMQ message queues. The business service is responsible for processing the client's conversion requests and generating request messages, while the conversion service is responsible for consuming request messages and performing conversion tasks, thereby improving the scalability and fault tolerance of the system. At the same time, the method also allows the business service to quickly return to the client without waiting for the response of the conversion service, thereby improving the user experience and ensuring the flexibility and scalability of the system. Furthermore, when the amount of document conversion tasks increases, the system can cope with the load by adding conversion service instances to ensure that the conversion tasks can be processed in a timely manner without affecting the normal operation of the business system. Secondly, by storing files in OSS, the high availability and persistence of files are ensured, avoiding the file loss and insufficient storage space problems caused by local storage in traditional document conversion solutions, and improving the stability and security of the system.

[0112] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the above-described equipment, devices and units can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0113] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses 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, and there may be other division methods in actual implementation, and units with the same function may be combined into one unit, for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0114] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0115] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0116] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), disk or optical disk and other media that can store program codes.

[0117] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for asynchronous document conversion and synchronous notification, characterized in that: include: The client uploads the file to be converted to the object storage service through the web interface; The client submits a conversion request to the business service through a Web interface, wherein the file parameters of the conversion request include the storage address and conversion type of the file to be converted; The business service receives the conversion request and generates request information, and sends the request information to the conversion service through the RabbitMQ message queue; The conversion service downloads the file to be converted from the object storage service according to the request information and performs format conversion to obtain a result file, uploads the result file to the object storage service, generates a conversion completion message and sends it to the business service through the RabbitMQ message queue; The business service obtains the storage address of the result file according to the conversion completion message, and pushes the storage address of the result file to the client in the form of a notification; The client downloads the result file according to the storage address of the result file.

2. The method for asynchronous document conversion and synchronous notification according to claim 1, characterized in that: The business service receives the conversion request and generates request information, and sends the request information to the conversion service through the RabbitMQ message queue, including: The business service verifies the file parameters in the conversion request, and after passing the verification, encapsulates the file parameters into a serialized data format to obtain request information; The business service sends the request information to the RabbitMQ message queue.

3. The method for asynchronous document conversion and synchronous notification according to claim 1, characterized in that: The file parameters also include a client ID.

4. The method for asynchronous document conversion and synchronous notification according to claim 3, characterized in that: The uploading the result file to the object storage service includes: binding the result file to the client ID; The business service obtains the storage address of the result file according to the conversion completion message, including: binding the storage address of the result file with the client ID.

5. The method for asynchronous document conversion and synchronous notification according to claim 4, characterized in that: The client downloads the result file according to the storage address of the result file, including: The client queries the conversion status of the corresponding file to be converted by logging in to the client ID, and downloads the result file after the conversion is completed.

6. The method for asynchronous document conversion and synchronous notification according to claim 1, characterized in that: The conversion service downloads the file to be converted from the object storage service according to the request information and performs format conversion to obtain a result file, including: The conversion service obtains the request information from the RabbitMQ message queue; The conversion service deserializes the request message to obtain the storage address and conversion type of the file to be converted; The conversion service downloads the file to be converted from the object storage service according to the storage address of the file to be converted; The conversion service performs format conversion on the file to be converted according to the conversion tool and the conversion type to obtain a result file.

7. The method for asynchronous document conversion and synchronous notification according to claim 1, characterized in that: The pushing the storage address of the result file to the client in the form of a notification includes: the business service pushing the storage address of the result file to the client in the form of a notification through SSE.

8. A system for asynchronous document conversion and synchronous notification, characterized in that: include: Business services, transformation services, and clients; The client is used to upload the file to be converted to the object storage service through the Web interface; The client is also used to submit a conversion request to the business service through a Web interface, wherein the file parameters of the conversion request include the storage address and conversion type of the file to be converted; The business service is used to receive the conversion request and generate request information, and send the request information to the conversion service through the RabbitMQ message queue; The conversion service is used to download the file to be converted from the object storage service according to the request information and perform format conversion to obtain a result file, upload the result file to the object storage service, and generate a conversion completion message and send it to the business service through the RabbitMQ message queue; The business service is further used to obtain the storage address of the result file according to the conversion completion message, and push the storage address of the result file to the client in the form of a notification; The client is also used to download the result file according to the storage address of the result file.

9. The system for asynchronous document conversion and synchronous notification according to claim 8, characterized in that: The business services include: A verification unit, used to verify the file parameters in the conversion request, and after the verification passes, encapsulate the file parameters into a serialized data format to obtain request information; A sending unit is used to send the request information to the RabbitMQ message queue.

10. The system for asynchronous document conversion and synchronous notification according to claim 8, characterized in that: The conversion services include: An acquiring unit, configured to acquire the request information from the RabbitMQ message queue; A deserialization unit, used for deserializing the request message to obtain the storage address and conversion type of the file to be converted; A downloading unit, configured to download the file to be converted from the object storage service according to the storage address of the file to be converted; The conversion unit is used to perform format conversion on the file to be converted according to the conversion tool and the conversion type to obtain a result file.

Citation Information

Cited By

  • Cross-application Excel data import processing method and system based on cloud storage

    CN121012829A