Mail sending method and device, storage medium and program product

By introducing message queues and multithreading mechanisms into financial business scenarios, the business worker threads and email sending process are decoupled, solving the problem of poor email notification performance and achieving real-time, reliable email sending and improved system performance.

CN121814727APending Publication Date: 2026-04-07INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Email notifications in financial business scenarios suffer from poor delivery performance. Synchronous methods cause business threads to be blocked, while asynchronous methods increase database pressure and waste resources.

Method used

The system employs a message queue and multithreading mechanism. The first thread generates email messages and adds them to the message queue, while the second thread handles email sending asynchronously. This decouples the business worker thread from the email sending process and utilizes topic partitioning and sub-threads to process email messages in parallel.

Benefits of technology

It achieves real-time and reliable email sending, reduces the pressure on the database and business worker threads, reduces the load on the mail server, and improves system scalability and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121814727A_ABST
    Figure CN121814727A_ABST
Patent Text Reader

Abstract

The invention discloses a mail sending method and device, a storage medium and a program product. Relates to the field of financial science and technology, and the method comprises the steps that under the condition that a first thread detects that target business data is updated to a database, a mail message is generated, the first thread comprises a thread for processing the target business data, and the target business data comprises data generated in the financial business handling process; adding the mail message to a message queue; and extracting the mail message in the message queue by using a second thread, and sending a mail to the target object based on the mail message, the second thread comprising a thread for processing mail sending. Through the method and the device, the problem of poor sending effect of notification mails of financial service scenes in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of financial technology, and more specifically, to an email sending method, apparatus, storage medium, and program product. Background Technology

[0002] Email notification services are crucial in financial institutions' business applications. In practice, for indicators that system users need to closely monitor, such as large account balance changes, timely email alerts should be sent to users when changes occur, enabling them to be aware of changes immediately and meeting security requirements.

[0003] Email notifications in financial business applications differ significantly from those in general scenarios because a substantial amount of account information calculation or storage occurs before the worker thread actually sends the email request. Therefore, financial business applications place higher demands on email notifications.

[0004] Among related technologies, email notification technology can be mainly divided into two categories: synchronous and asynchronous methods. However, both have drawbacks, as follows:

[0005] Figure 1 It is a flowchart of synchronized email notifications provided by relevant technologies, such as Figure 1 As shown, synchronous methods are often integrated into worker threads. Once critical business data changes and is stored in the database, the business worker thread begins the email sending logic. During this process, the business thread sends an email request to the mail server and becomes blocked until the email is successfully sent. However, this method tightly couples the business thread with the email sending process, blocking the current worker thread, slowing down response time, and impacting critical business processes if email sending fails. Furthermore, synchronous email notifications are embedded in the critical data processing flow; therefore, an email needs to be sent every time critical data changes, which not only degrades the user experience but also increases the load on the mail server.

[0006] Figure 2 This is a flowchart based on timer-based asynchronous email notifications provided by relevant technologies, such as... Figure 2As shown, after the business worker thread completes the key data changes and calculates and stores them in the database, it directly returns the operation results to the user without needing to pay attention to the email sending business. The system's preset timer periodically (the period is set according to the specific business) queries the database for changes in key data and wakes up the timer worker thread to handle email notification business. However, the introduction of the timer tool will periodically poll the business database table, which not only fails to achieve real-time email notifications but also increases the pressure on the database; moreover, if the data does not meet the notification conditions, it will produce invalid operations that waste resources. If there are many email notification requests generated within a timer cycle, it will cause a surge in email request traffic, thereby increasing the pressure on the mail server. Furthermore, this method of email sending is coupled with the database; once the database table structure changes due to business needs, the scheduled task logic must also change accordingly.

[0007] There is currently no effective solution to the problem of poor delivery performance of notification emails in financial business scenarios related to this technology. Summary of the Invention

[0008] The main purpose of this application is to provide an email sending method, device, storage medium, and program product to solve the problem of poor sending effect of notification emails in financial business scenarios in related technologies.

[0009] To achieve the above objectives, according to one aspect of this application, an email sending method is provided. The method includes: generating an email message upon a first thread detecting that target business data has been updated to a database, wherein the first thread includes a thread for processing the target business data, the target business data including data generated during the processing of financial transactions; adding the email message to a message queue; retrieving the email message from the message queue using a second thread, and sending an email to a target object based on the email message, the second thread including a thread for processing email sending.

[0010] Furthermore, the message queue includes: N topics, each topic being associated with a different business type. Adding the email message to the message queue includes: determining the business type of the target business data to obtain the target business type; and adding the email message to the target topic of the message queue based on the target business type. The target topic includes: among the N topics, the target business type is associated with a topic, where N is a positive integer.

[0011] Furthermore, the second thread includes: N sub-threads, each of which sub-threads subscribes to one of the topics. Extracting email messages from the message queue using the second thread includes: using a target sub-thread to detect whether the email message exists in the target topic, obtaining a first detection result, wherein the target sub-thread includes: a sub-thread that subscribes to the target topic; and, if the first detection result indicates that the email message exists in the target topic, using the target sub-thread to extract the email message from the target topic.

[0012] Further, sending an email to a target object based on the email message includes: generating an email sending request using the second thread based on the email message, wherein the email sending request is used to request sending an email to the target object; sending the email sending request to a mail server, and sending the email to the target object through the mail server.

[0013] Furthermore, before generating an email message when the first thread detects that the target business data has been updated to the database, the method further includes: when the target object conducts the financial business, adjusting the first thread to a running state; using the first thread to collect the target business data and updating the business data to the database.

[0014] Furthermore, before generating the email message, the method further includes: obtaining preset email notification conditions, detecting whether the target business data meets the preset email notification conditions, and obtaining a second detection result; if the second detection result indicates that the target business data meets the email notification conditions, then performing the step of generating an email message.

[0015] Furthermore, when the first thread detects that the target business data has been updated to the database, an email message is generated, including: obtaining the identification information and email address of the target object; and generating the email message based on the identification information, the email address, and the target business data.

[0016] To achieve the above objectives, according to another aspect of this application, an email sending apparatus is provided. The apparatus includes: a generation unit, configured to generate an email message when a first thread detects that target business data has been updated to a database, wherein the first thread includes a thread for processing the target business data, the target business data including data generated during the processing of financial transactions; an adding unit, configured to add the email message to a message queue; and a first processing unit, configured to use a second thread to extract the email message from the message queue and send an email to a target object based on the email message, wherein the second thread includes a thread for processing email sending.

[0017] Furthermore, the message queue includes: N topics, each topic being associated with a different business type; the adding unit includes: a determining subunit, used to determine the business type of the target business data to obtain the target business type; and an adding subunit, used to add the email message to the target topic of the message queue based on the target business type, wherein the target topic includes: among the N topics, the topic associated with the target business type, where N is a positive integer.

[0018] Further, the second thread includes: N sub-threads, each of which sub-threads subscribes to one of the topics; the first processing unit includes: a detection sub-unit, used to detect whether the email message exists in the target topic using the target sub-thread, and obtain a first detection result, wherein the target sub-thread includes: a sub-thread that subscribes to the target topic; and an extraction sub-unit, used to extract the email message in the target topic using the target sub-thread when the first detection result indicates that the email message exists in the target topic.

[0019] Furthermore, the first processing unit further includes: a first generation subunit, configured to generate an email sending request based on the email message using the second thread, wherein the email sending request is used to request sending an email to the target object; and a processing subunit, configured to send the email sending request to the mail server and send the email to the target object through the mail server.

[0020] Furthermore, the email sending device also includes: an adjustment unit, configured to adjust the first thread to a running state before generating an email message when the target object conducts the financial business, provided that the first thread detects that the target business data has been updated to the database; and a second processing unit, configured to collect the target business data using the first thread and update the business data to the database.

[0021] Furthermore, the email sending device includes: a third processing unit, configured to obtain preset email notification conditions before generating an email message, detect whether the target business data meets the preset email notification conditions, and obtain a second detection result; and an execution unit, configured to execute the step of generating an email message when the second detection result indicates that the target business data meets the email notification conditions.

[0022] Furthermore, the generation unit includes: an acquisition subunit, used to acquire the identification information and email address of the target object; and a second generation subunit, used to generate the email message based on the identification information, the email address, and the target business data.

[0023] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is executed, it controls the device where the computer-readable storage medium is located to perform the email sending method.

[0024] According to another aspect of this application, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein the program executes the email sending method when it runs.

[0025] According to another aspect of this application, a computer program product is provided, including computer instructions that, when executed by a processor, implement the steps of the email sending method.

[0026] In this application, the following approach is adopted: Upon detecting that target business data has been updated in the database, a first thread generates an email message. This first thread includes a thread that processes the target business data, which includes data generated during the financial transaction process. The email message is then added to a message queue. A second thread retrieves the email message from the message queue and sends it to the target object. This second thread includes a thread for handling email sending. This solves the technical problem of poor email delivery performance in financial business scenarios in related technologies. In this application, by using a message queue and multiple threads to send notification emails, the business workflow threads and email sending are decoupled, as are email sending and the business database. This avoids the problems of timer-based periodic polling of the business database for email notifications in related technologies, which leads to high database pressure and the potential blocking of business workflow threads by synchronous email notification methods. This achieves the technical effect of reducing the pressure on the database and business workflow threads. Attached Figure Description

[0027] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:

[0028] Figure 1 This is a flowchart of synchronized email notifications provided by relevant technologies;

[0029] Figure 2 This is a flowchart of timer-based asynchronous email notifications provided by relevant technologies;

[0030] Figure 3 A hardware structure block diagram of a computer terminal for implementing an email sending method is shown.

[0031] Figure 4This is a flowchart of an email sending method provided according to an embodiment of this application;

[0032] Figure 5 This is a flowchart of email message generation based on the embodiments of this application;

[0033] Figure 6 This is a flowchart of email sending according to an embodiment of this application;

[0034] Figure 7 This is a schematic diagram of an email sending device provided according to an embodiment of this application;

[0035] Figure 8 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0036] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0037] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0038] It should be noted that the email sending method and apparatus in this application can be used in the field of fintech for sending email notifications during the processing of financial business, and can also be used in any field other than fintech for sending email notifications during the processing of financial business. This application does not limit the application field of the email sending method and apparatus.

[0039] It should be noted that the information collected in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding access points are provided for users to choose to authorize or refuse. For example, interfaces are set up between this system and relevant users or organizations, providing users with corresponding access points to choose to agree to or refuse automated decision-making results; if the user chooses to refuse, the process proceeds to the expert decision-making stage.

[0040] This invention can be applied to various software products, control systems, and client applications (including but not limited to mobile clients, PCs, etc.) of financial institutions to send email notifications to users, thereby enabling financial institutions to perform business functions (including but not limited to: transfers, wealth management, funds, bill payments, account inquiries, advertising, recommendations, etc.).

[0041] Example 1

[0042] According to an embodiment of this application, a method embodiment for sending emails is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0043] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 3 A hardware block diagram of a computer terminal (or mobile device) for implementing an email sending method is shown. Figure 3 As shown, the computer terminal 30 (or mobile device) may include one or more processors 302 (shown as 302a, 302b, ..., 302n in the figure) (processor 302 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 304 for storing data, and a transmission device 306 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 3 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 30 may also include... Figure 3 The more or fewer components shown, or having the same Figure 3 The different configurations shown.

[0044] It should be noted that the aforementioned one or more processors 302 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 30 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0045] The memory 304 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the email sending method in this embodiment. The processor 302 executes various functional applications and data processing by running the software programs and modules stored in the memory 304, thereby realizing the above-mentioned email sending method. The memory 304 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 304 may further include memory remotely located relative to the processor 302, and these remote memories can be connected to the computer terminal 30 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0046] The transmission device 306 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 30. In one example, the transmission device 306 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 306 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0047] The display can be, for example, a touchscreen liquid crystal display (LCD), which allows the user to interact with the user interface of the computer terminal 30 (or mobile device).

[0048] Under the aforementioned operating environment, this application provides the following: Figure 4 The email sending method shown. Figure 4 This is a flowchart of an email sending method according to Embodiment 1 of this application.

[0049] Step S401: When the first thread detects that the target business data has been updated to the database, an email message is generated. The first thread includes a thread that processes the target business data, which includes data generated during the financial business process.

[0050] The first thread mentioned above can be a business worker thread, used to execute specific business data, generate email messages, and push them into the specified topic of the message queue.

[0051] In this embodiment, after the key data (corresponding to the target business data) is stored in the database, the email message generation stage begins. The business worker thread acts as the producer, using the changed user key data to perform calculations, while simultaneously verifying whether this data meets the conditions for email notification, and outputting the data results that meet the conditions. For these data results that urgently need to be notified, email messages can be generated according to the identity of the target object (e.g., user identifier) ​​and email address information.

[0052] Step S402: Add the email message to the message queue.

[0053] To avoid blocking the current worker thread when using synchronous email notifications, which would not only slow down the response time but also affect critical business processes if email delivery fails, this embodiment can push email messages into a specified topic in the message queue based on the business type (e.g., large transfer, withdrawal, etc.) of the target object's business data. The message queue can include multiple topics, and different topics can correspond to different business types. At the same time, a response message can be returned to the target object to indicate that the operation was successful.

[0054] Figure 5 This is a flowchart of email message generation based on the embodiments of this application, such as... Figure 5 As shown, the business worker thread (corresponding to the first thread) can perform calculations on key business data (corresponding to target business data) to obtain data result 1 and data result 2. Furthermore, it can generate email messages based on the data results and add them to the corresponding subject (e.g., ...). Figure 5 In the Topic1, Topic2, and Topic3, the email can then be processed through the email worker thread (corresponding to the second thread).

[0055] Step S403: Use the second thread to extract email messages from the message queue and send emails to the target object based on the email messages. The second thread includes a thread for processing email sending.

[0056] To avoid coupling the email sending process with the business thread in synchronous email notification methods, which could affect critical business processes if email sending fails, and to prevent asynchronous email notification methods from periodically polling the business database table, which not only fails to achieve real-time email notifications but also increases the pressure on the database, this embodiment utilizes a second thread to poll the topics in the message queue to extract email messages from the topics in the message queue. Then, based on the email messages, the email can be sent to the target object using the mail server. The target object can be a user or a device owned by the user.

[0057] In this embodiment, a message queue and a second thread (i.e., an email worker thread) are introduced to decouple the email sending process from the business worker thread. The business worker thread generates email messages only for data that meets certain conditions, avoiding redundant calculations and invalid operations on business data. Using the "publish-subscribe" pattern of the message queue enables real-time email notifications, reducing traffic spikes caused by periodic email requests and lowering the pressure on the mail server. Decoupling the email sending process from the database reduces database pressure while providing good scalability.

[0058] Through the above steps, this embodiment achieves the decoupling of business worker threads and email sending, as well as the decoupling of email sending from the business database, by using message queues and multiple threads to send notification emails. This avoids the problems of related technologies where periodic polling of the business database based on timers for email notifications leads to high database pressure, and synchronous email notification methods easily block business worker threads. Therefore, it reduces the pressure on the database and business worker threads, thus solving the technical problem of poor notification email sending performance in financial business scenarios in related technologies.

[0059] Optionally, in the email sending method provided in this application embodiment, the message queue includes: N topics, each topic is associated with a different business type, and adding email messages to the message queue includes: determining the business type of the target business data to obtain the target business type; and adding email messages to the target topic of the message queue based on the target business type, wherein the target topic includes: among the N topics, the target business type is associated with a topic, and N is a positive integer.

[0060] The message queue described above may include N topics. In this embodiment, N topics can be deployed in the message queue according to the business scenario or business type (e.g., deposit, withdrawal, transfer, etc.).

[0061] For example, when a business worker thread detects a data change and decides to send an email notification, it can identify which "business type" this change belongs to, i.e., the nature of the target business data. For instance, if it's a large account change, then it belongs to the corresponding business type. Then, this email message of the "target business type" is added to the "target subject" associated with that business type.

[0062] Load balancing: By distributing different types of messages across different topics, it is easy to balance the load on email worker threads and prevent a single thread from becoming overloaded due to processing a large number of messages of the same type. When a new business type emerges, a corresponding topic can be added to the message queue without changing the existing email notification system architecture, which facilitates system expansion and maintenance.

[0063] In this embodiment, the method based on message queues and topic partitioning can effectively improve the real-time performance, reliability, and processing efficiency of email notification services, while also reducing the pressure on the database and mail server.

[0064] Optionally, in the email sending method provided in this application embodiment, the second thread includes: N sub-threads, each sub-thread subscribing to a topic, and using the second thread to extract email messages from the message queue, including: using a target sub-thread to detect whether there are email messages in the target topic and obtaining a first detection result, wherein the target sub-thread includes: a sub-thread subscribing to the target topic; and when the first detection result indicates that there are email messages in the target topic, using the target sub-thread to extract email messages in the target topic.

[0065] To improve the speed and efficiency of email notifications, an email worker thread can contain N sub-threads. Each sub-thread subscribes to a specific topic in the message queue. That is, if the message queue has multiple topics, such as large transaction notifications and account login anomaly alerts, then each sub-thread will consume email messages from one of the topics.

[0066] At startup, each child thread can subscribe to the topic it is responsible for. The child thread that subscribes to the target topic can be called the target child thread. The target child thread can periodically check whether there are new email messages in the target topic it subscribes to. If an email message is detected, the target child thread will record this result, namely the "first detection result". If the first detection result shows that there are indeed email messages in the target topic, then the target child thread can retrieve the email messages from the message queue and start processing them to send the emails.

[0067] Because each sub-thread independently processes email messages for a single topic, the parallel processing of N sub-threads improves email message handling capacity and reduces the waiting time and bottleneck caused by a single thread processing all topic messages. This ensures the timeliness and accuracy of email delivery, improves the efficiency of email notifications, and allows for easy addition of new email notification types without requiring major changes to the existing architecture; only the corresponding topics and sub-threads need to be added.

[0068] Optionally, in the email sending method provided in this application embodiment, sending an email to a target object based on an email message includes: generating an email sending request using a second thread based on the email message, wherein the email sending request is used to request sending an email to the target object; sending the email sending request to an email server, and sending the email to the target object through the email server.

[0069] When a sub-thread (e.g., the target sub-thread) in the mail worker thread (corresponding to the second thread) detects and extracts email messages from its subscribed topic (e.g., the target topic), it may need to convert these email messages into email sending requests that the mail server can understand. For example, (1) parsing email messages: the target sub-thread can first parse the content of the email message, including the information of the target object (i.e., the email recipient), such as email address, name, etc., as well as the specific content of the email, such as transaction details, account changes, etc.; (2) formatting emails: according to the requirements of the mail server, the sub-thread can format the content of the email into a specific format, such as email subject, body, sender information, recipient information, etc., to ensure that the mail server can correctly identify and process it.

[0070] Based on the parsed and formatted email message, the child thread can create an email send request. This request contains all the necessary information to request the mail server to send the email to the target object. After generating the email send request, the child thread can send the email send request to the mail server, for example, by passing the email send request to the mail server through a specified network protocol.

[0071] After receiving an email send request, the mail server checks the sender and recipient information in the request to ensure they are correct and that the sender has the necessary permissions. If the request passes verification, the mail server generates the email based on the information in the request and sends it to the target recipient's email address. The email sending process may also include steps such as encrypting the email content and routing to ensure secure and efficient delivery.

[0072] Email worker threads can efficiently and accurately convert email messages extracted from the message queue into requests that the mail server can handle, thereby enabling automated email sending. This not only improves the real-time performance and accuracy of email notifications, but also prevents the mail server from being overloaded by processing a large number of email requests in a short period of time through the "buffering" effect of the message queue.

[0073] Optionally, in the email sending method provided in this application embodiment, before generating an email message when the first thread detects that the target business data has been updated to the database, the method further includes: adjusting the first thread to a running state when the target object is conducting financial business; using the first thread to collect the target business data and updating the business data to the database.

[0074] In the business systems of financial institutions, when a target object begins to perform a financial business operation, such as a transfer, deposit, or loan application, this operation can be immediately identified. The business worker thread (first thread) can be awakened from the waiting or dormant state and switched to the running state to respond to the user operation, ensuring that the business logic can be executed quickly.

[0075] Once the business worker thread enters the running state, it can collect relevant business data. This includes, but is not limited to, key information such as the target object's account information, transaction amount, transaction time, and transaction type. The collection process can be completed through interaction between the business worker thread and various internal system components or external services, ensuring that all relevant data can be obtained comprehensively and accurately.

[0076] The collected business data can be updated in the database to reflect the user's latest business status. Ensuring the timeliness and accuracy of user data is essential for subsequent business processing and email notifications. Updating business data can include database write operations, which may include adding records, modifying existing records, or deleting records that are no longer needed.

[0077] Optionally, in the email sending method provided in this application embodiment, before generating an email message, the method further includes: obtaining preset email notification conditions, detecting whether the target business data meets the preset email notification conditions, and obtaining a second detection result; and if the second detection result indicates that the target business data meets the email notification conditions, performing the step of generating an email message.

[0078] Retrieving preset email notification conditions can be used to determine when to send email notifications to users. These preset conditions may include, but are not limited to, large financial transactions, abnormal account logins, password changes, and updates to important documents. Preset email notification conditions can be obtained by reading system configurations, database rules, or by calling specific service modules.

[0079] To avoid the synchronous email notification method used in related technologies, which requires sending an email for every critical data change, degrading user experience and increasing pressure on the email server, this embodiment allows the business worker thread (first thread) to analyze and judge the updated business data (corresponding to the target business data) based on preset email notification conditions. For example, if one of the preset conditions is "a single transaction exceeding 100,000 yuan," then the system can check whether recent transaction records meet this standard to filter out data changes that do not require email notifications.

[0080] If the second detection result indicates whether the business data meets the conditions for sending an email notification, the step of generating an email message can be executed. This enables intelligent identification of which data changes are worth notifying users via email and which can be ignored. This not only improves the system's operating efficiency but also ensures the accuracy and necessity of email notifications, providing users with a better service experience while protecting the system's resources from excessive consumption.

[0081] Optionally, in the email sending method provided in this application embodiment, when the first thread detects that the target business data has been updated to the database, an email message is generated, including: obtaining the identification information and email address of the target object; and generating an email message based on the identification information, email address, and target business data.

[0082] The business worker thread (i.e., the first thread) updates the database after detecting that target business data (such as account balance, transaction records) has been operated on by the target object (e.g., a user). It can obtain user information related to this business operation, including the user's unique identification information (such as user ID, account, etc.) and the user's preset email address for receiving email notifications. This ensures that emails are accurately sent to the correct user.

[0083] After obtaining user identification information and email address, the business worker thread can generate email messages based on updated business data. For example, based on changes in business data, such as large fund transfers or abnormal account logins, email content can be generated to describe the business changes, including the amount, time, and type of the change. Personalized information can also be added, such as the user's personalized information, such as name and account name, to improve the readability and user-friendliness of the email.

[0084] After collecting user identification information and email addresses and generating email content, an email message (including user identification information, email address, and relevant business change details) can be obtained. This achieves the technical effect of accurately generating email messages.

[0085] The email sending method provided in this embodiment involves the collaborative participation of three components: a business worker thread (corresponding to the first thread), a message queue, and an email worker thread (corresponding to the second thread). The business worker thread is responsible for executing specific business data, generating email messages, and pushing them into a specified topic in the message queue. The email worker thread subscribes to various topics in the message queue to complete the email sending process. Figure 6 This is a flowchart of email sending according to an embodiment of this application. The implementation process of email sending is as follows: Figure 6 It can be divided into two parts according to components: the first part is the business worker thread that produces email messages, and the second part is the email worker thread that consumes email messages, as detailed below:

[0086] Part 1: Business worker threads produce email messages.

[0087] Step 1: User operation (corresponding to the target object) wakes up the business worker thread, triggers key data changes, and executes key data entry into the database.

[0088] Step 2: After the key data is stored in the database, the email message generation stage begins. Business worker threads act as producers, using the changed key user data for calculations, simultaneously verifying whether this data meets the conditions for email notification, and outputting the data results that meet the conditions. For these data results that urgently need to be notified, email messages are generated according to the user's identity and email address information.

[0089] Step 3: The business worker thread pushes the generated email message into the corresponding topic in the message queue, using the topic as the handle. At the same time, it returns a response message to the user to indicate that the operation was successful.

[0090] Optionally, steps 2-3 can be made more asynchronous. For example, after the business worker thread stores the key business data in the database, it can be returned to the user, and a sub-thread can be created to complete the production of email messages, thereby speeding up the response.

[0091] The second part involves email worker threads consuming email messages.

[0092] Step 4: Using a publish-subscribe pattern based on a message queue, the email worker thread pre-subscribes to various email topics. When an email message arrives in the message queue, the message queue notifies the email worker thread to consume the message from the queue according to the different topics.

[0093] Step 5: The email worker thread iterates through all topics and their user identities, email addresses, and other information, creates an email sending request, and sends it to the mail server.

[0094] Optionally, steps 4 and 5 can be used to create multiple email worker threads (corresponding to N sub-threads) according to the Topic. Each thread can simultaneously consume all email messages of the Topic to fully leverage the advantages of multi-core processors and thus improve the performance of business concurrency.

[0095] Step 6: After the email is successfully sent, the email worker thread is complete and can continue to enter standby mode, waiting for email messages to arrive in the message queue.

[0096] This embodiment introduces a message queue and an email worker thread to decouple the email sending process from the business worker thread, ensuring that the business worker thread remains unaffected. This allows the business worker thread to focus on processing business logic, avoiding redundant calculations and invalid operations on business data, thus improving reliability and scalability. Furthermore, the introduction of the message queue enables real-time email notifications, decoupling from existing business processes while reducing traffic spikes from periodic email requests, ultimately lowering the pressure on the mail server. Generating email messages when critical data changes reduces database access frequency and avoids invalid validation operations during email sending.

[0097] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0098] Example 2

[0099] This application also provides an email sending device. It should be noted that the email sending device of this application can be used to execute the email sending method provided in Embodiment 1 of this application. The email sending device provided in this application will be described below.

[0100] According to embodiments of this application, an apparatus for implementing the above-described email sending method is also provided, such as... Figure 7 As shown, the device includes: a generation unit 71, an addition unit 72, and a first processing unit 73.

[0101] The generation unit 71 is used to generate an email message when the first thread detects that the target business data has been updated to the database. The first thread includes a thread that processes the target business data, which includes data generated during the financial business process.

[0102] Add unit 72, used to add email messages to the message queue;

[0103] The first processing unit 73 is used to extract email messages from the message queue using a second thread and send emails to the target object based on the email messages. The second thread includes a thread for processing email sending.

[0104] In the email sending device provided in this embodiment, an email message can be generated by the generation unit 71 when the first thread detects that the target business data has been updated to the database. The first thread includes a thread for processing the target business data, which includes data generated during the financial business process. The email message is added to a message queue by the adding unit 72. The first processing unit 73 uses a second thread to extract the email message from the message queue and sends the email to the target object based on the email message. The second thread includes a thread for processing email sending. This solves the technical problem of poor sending effect of notification emails in financial business scenarios in related technologies. In this embodiment, by sending notification emails through a message queue and multiple threads, the business work thread and email sending are decoupled, and email sending is decoupled from the business database. This avoids the situation in related technologies where the business database is periodically polled based on a timer for email notification, resulting in high database pressure and the synchronous email notification method easily blocking the business work thread. This achieves the technical effect of reducing the pressure on the database and business work threads.

[0105] Optionally, in the email sending apparatus provided in this application embodiment, the message queue includes: N topics, each topic being associated with a different business type, and the adding unit includes: a determining subunit, used to determine the business type of the target business data to obtain the target business type; and an adding subunit, used to add the email message to the target topic of the message queue based on the target business type, wherein the target topic includes: among the N topics, the target business type is associated with a topic, and N is a positive integer.

[0106] Optionally, in the email sending apparatus provided in this application embodiment, the second thread includes: N sub-threads, each sub-thread subscribing to a topic; the first processing unit includes: a detection sub-unit, used to detect whether there are email messages in the target topic using the target sub-thread, and obtain a first detection result, wherein the target sub-thread includes: a sub-thread subscribing to the target topic; and an extraction sub-unit, used to extract email messages in the target topic using the target sub-thread when the first detection result indicates that there are email messages in the target topic.

[0107] Optionally, in the email sending apparatus provided in this application embodiment, the first processing unit further includes: a first generation subunit, used to generate an email sending request based on the email message and using a second thread, wherein the email sending request is used to request to send an email to a target object; and a processing subunit, used to send the email sending request to the email server and send the email to the target object through the email server.

[0108] Optionally, in the email sending device provided in the embodiments of this application, the email sending device further includes: an adjustment unit, used to adjust the first thread to a running state before generating an email message when the first thread detects that the target business data has been updated to the database; and a second processing unit, used to collect the target business data using the first thread and update the business data to the database.

[0109] Optionally, in the email sending apparatus provided in this application embodiment, the email sending apparatus includes: a third processing unit, configured to obtain preset email notification conditions before generating an email message, detect whether the target business data meets the preset email notification conditions, and obtain a second detection result; and an execution unit, configured to execute the step of generating an email message when the second detection result indicates that the target business data meets the email notification conditions.

[0110] Optionally, in the email sending apparatus provided in this application embodiment, the generation unit includes: an acquisition subunit, used to acquire the identification information and email address of the target object; and a second generation subunit, used to generate an email message based on the identification information, email address, and target business data.

[0111] It should be noted that the generation unit 71, the addition unit 72, and the first processing unit 73 mentioned above correspond to steps S401 to S403 in Embodiment 1. Each unit and its corresponding step implement the same instance and application scenario, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 304) and processed by one or more processors (e.g., processors 302a, 302b, ..., 302n). The above modules can also be part of a device and run in the computer terminal 30 provided in Embodiment 1.

[0112] Example 3

[0113] Embodiments of this application may provide an electronic device. Figure 8 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 8 As shown, the electronic device may include: one or more ( Figure 8(Only one is shown) processor 802, memory 804, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0114] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the above-described methods. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0115] The processor can invoke information and applications stored in memory via a transmission device to perform the following steps: Upon detecting that target business data has been updated in the database by a first thread, an email message is generated. The first thread includes a thread that processes the target business data, which includes data generated during the financial transaction process. The email message is added to a message queue. A second thread retrieves the email message from the message queue and sends an email to the target object based on the message message. The second thread includes a thread for handling email sending.

[0116] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: The message queue includes: N topics, each topic is associated with a different business type, and adding email messages to the message queue includes: determining the business type of the target business data to obtain the target business type; based on the target business type, adding email messages to the target topic of the message queue, wherein the target topic includes: among the N topics, the target business type is associated with the topic, where N is a positive integer.

[0117] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: The second thread includes: N sub-threads, each sub-thread subscribing to a topic, and using the second thread to extract email messages from the message queue, including: using the target sub-thread to detect whether there are email messages in the target topic and obtaining a first detection result, wherein the target sub-thread includes: a sub-thread that subscribes to the target topic; if the first detection result indicates that there are email messages in the target topic, using the target sub-thread to extract email messages in the target topic.

[0118] The processor can also invoke information and applications stored in memory via a transmission device to perform the following steps: sending an email to a target object based on an email message, including: generating an email sending request using a second thread based on the email message, wherein the email sending request is used to request sending an email to the target object; sending the email sending request to the mail server, and sending the email to the target object through the mail server.

[0119] The processor can also invoke information and applications stored in the memory via the transmission device to perform the following steps: before generating an email message when the first thread detects that the target business data has been updated to the database, the processor also includes: adjusting the first thread to a running state when the target object conducts financial business; using the first thread to collect the target business data and update the business data to the database.

[0120] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: before generating an email message, it further includes: obtaining preset email notification conditions, detecting whether the target business data meets the preset email notification conditions, and obtaining a second detection result; if the second detection result indicates that the target business data meets the email notification conditions, the step of generating an email message is performed.

[0121] The processor can also invoke information and applications stored in the memory via the transmission device to perform the following steps: when the first thread detects that the target business data has been updated to the database, generate an email message, including: obtaining the identification information and email address of the target object; and generating an email message based on the identification information, email address, and target business data.

[0122] By employing the embodiments of this application, notification emails are sent through message queues and multiple threads, thereby decoupling business worker threads from email sending and decoupling email sending from the business database. This avoids the situation in related technologies where periodic polling of the business database based on timers for email notifications results in high database pressure, and synchronous email notification methods are prone to blocking business worker threads. Thus, the technical effect of reducing the pressure on the database and business worker threads is achieved.

[0123] Those skilled in the art will understand that Figure 8 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones, tablets, handheld computers, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 8 This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 8 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 8The different configurations shown.

[0124] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0125] Example 4

[0126] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the email sending method provided in Embodiment 1.

[0127] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.

[0128] This application also provides a computer program product that, when executed on a data processing device, is suitable for performing email sending method steps.

[0129] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0130] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0131] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0132] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0133] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0134] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0135] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for sending emails, characterized in that, include: When the first thread detects that the target business data has been updated to the database, an email message is generated. The first thread includes a thread that processes the target business data, which includes data generated during the financial business process. Add the email message to the message queue; The second thread extracts email messages from the message queue and sends emails to the target object based on the email messages. The second thread includes a thread for handling email sending.

2. The email sending method according to claim 1, characterized in that, The message queue includes N topics, each associated with a different business type. Adding email messages to the message queue includes: Determine the business type of the target business data to obtain the target business type; Based on the target business type, the email message is added to the target topic of the message queue, wherein the target topic includes: among N topics, the topic associated with the target business type, where N is a positive integer.

3. The email sending method according to claim 2, characterized in that, The second thread includes: N sub-threads, each of which sub-threads subscribes to one of the topics. The second thread retrieves email messages from the message queue, including: The first detection result is obtained by using a target sub-thread to detect whether the email message exists in the target topic, wherein the target sub-thread includes a sub-thread that subscribes to the target topic; If the first detection result indicates that the email message exists in the target topic, the email message in the target topic is extracted using the target sub-thread.

4. The email sending method according to claim 1, characterized in that, Sending an email to the target based on the email message includes: Based on the email message, the second thread generates an email sending request, wherein the email sending request is used to request to send an email to the target object; The email sending request is sent to the mail server, and the email is sent to the target object through the mail server.

5. The email sending method according to claim 1, characterized in that, Before generating an email message, if the first thread detects that the target business data has been updated in the database, the following steps are also included: When the target object conducts the financial business, the first thread is put into running state; The first thread is used to collect the target business data and update the business data to the database.

6. The email sending method according to claim 1, characterized in that, Before generating the email message, it also includes: Obtain preset email notification conditions, detect whether the target business data meets the preset email notification conditions, and obtain a second detection result; If the second detection result indicates that the target business data meets the email notification conditions, the step of generating an email message is executed.

7. The email sending method according to claim 1, characterized in that, Upon detecting an update to the database of target business data in the first thread, an email message is generated, including: Obtain the identification information and email address of the target object; The email message is generated based on the identification information, the email address, and the target business data.

8. A mail sending device, characterized in that, include: A generation unit is configured to generate an email message when the first thread detects that the target business data has been updated to the database. The first thread includes a thread that processes the target business data, which includes data generated during the financial transaction process. An adding unit is used to add the email message to the message queue; The first processing unit is used to extract email messages from the message queue using a second thread, and send emails to the target object based on the email messages. The second thread includes a thread for processing email sending.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the email sending method according to any one of claims 1 to 7.

10. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the steps of the email sending method according to any one of claims 1 to 7.