Message sending method, storage medium and electronic equipment
By a method of obtaining business events and generating messages to be sent, the problem of high coupling between the message sending platform and the service party is solved, the decoupling between message sending and the service system is realized, efficiency and standardization are improved, and the message sending process is simplified.
Patent Information
- Application Number
- CN202410937278.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-29
AI Technical Summary
The existing message sending platform has a high degree of coupling with the business party, which leads to an increase in maintenance and expansion costs, making it difficult to send messages to users quickly and effectively.
By obtaining business events in the target message queue, obtaining message configuration information based on the event type, calling the abstract message factory to generate messages to be sent, and inserting the message into the corresponding queue according to the specified sending method, realizing the solution between message sending and service system Coupling.
It realizes the decoupling of message transmission and service system, improves message generation efficiency and standardization, simplifies the message transmission process, and reduces maintenance and expansion costs.
Smart Images

Figure CN119052046A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a message sending method, a storage medium and an electronic device. Background Art
[0002] With the development of Internet technology, the types of Internet services and notification messages are increasing. How to send messages to users quickly and effectively is an important factor in enhancing the interactive experience between business parties and users.
[0003] In the related art, when a business party generates a business event that requires sending a message to a user, the message sending platform can be instructed to send the message through a notification message. The message sending platform is highly coupled to the business party, which increases the maintenance and expansion costs of the message sending platform. Summary of the invention
[0004] In order to solve the above technical problems, embodiments of the present disclosure provide a message sending method, a storage medium and an electronic device.
[0005] According to one aspect of an embodiment of the present disclosure, a message sending method is provided, which is applied to a message sending platform, including:
[0006] Obtaining an event message of a business event in a target message queue, wherein the event message includes event parameters and an event type;
[0007] Based on the event type, acquiring message configuration information of the business event, the message configuration information including at least one message type and message sending mode;
[0008] Generate a to-be-sent message of each message type based on a message content template of each message type and the event parameter by calling an abstract message factory corresponding to each message type in the at least one message type;
[0009] According to the message sending method, the generated messages to be sent of each message type are respectively inserted into the corresponding sending queue for sending.
[0010] In some optional implementations of the present disclosure, the generating of the to-be-sent messages of each message type based on the message content template of each message type and the event parameter by calling the abstract message factory corresponding to each message type in the at least one message type includes:
[0011] By calling the abstract message factory corresponding to each message type, the abstract message factory constructs the event parameter into a data object as a message carrier of the message to be sent of each message type;
[0012] Generate messages of each message type to be sent based on the message content template and message carrier of each message type.
[0013] In some optional implementations of the present disclosure, the message sending mode is used to indicate the sending time and sending rules of the to-be-sent messages of each message type;
[0014] The sending time includes: real-time sending and delayed sending;
[0015] The sending rules include: sending all and sending only one.
[0016] In some optional implementations of the present disclosure, inserting the generated messages of each message type to be sent into the corresponding sending queue for sending according to the message sending mode includes:
[0017] In response to the message sending mode indicating that the sending time is real-time sending, the generated to-be-sent messages of each message type are respectively inserted into the corresponding responsibility chain queue for sending according to the sending rule;
[0018] In response to the message sending method indicating that the sending time is delayed sending, the generated messages of each message type to be sent are inserted into the delayed message queue, and it is periodically determined whether the messages in the delayed message queue arrive at the set sending time point. In response to a message arriving at the set sending time point, a sending operation is performed.
[0019] In some optional implementations of the present disclosure, inserting the generated messages of each message type to be sent into the corresponding responsibility chain queue for sending according to the sending rule includes:
[0020] In response to the message sending mode indicating that the sending rule is to send all, the generated to-be-sent messages of each message type are inserted into the queue corresponding to the first responsibility chain, and each processor in the first responsibility chain sends the to-be-sent messages of each message type by calling the corresponding interface;
[0021] In response to the message sending method indicating that the sending rule is to send only one type, the generated messages to be sent of each message type are inserted into the queue corresponding to the second responsibility chain, and each processor in the second responsibility chain calls the corresponding interface to send the messages to be sent of each message type according to the set priority until one message to be sent is successfully sent.
[0022] In some optional implementations of the present disclosure, the message type includes at least one of the following: a service number message, a mini-program message, an in-site message, a push message, and an SMS message.
[0023] In some optional implementations of the present disclosure, before obtaining the event message of the business event in the target message queue, the method further includes:
[0024] In response to monitoring a business event, executing a business operation corresponding to the business event;
[0025] In response to the completion of the business operation, an event message corresponding to the business event is inserted into the target message queue.
[0026] According to another aspect of an embodiment of the present disclosure, a message sending device is provided, which is applied to a message sending platform, including:
[0027] A message acquisition module, used to acquire an event message of a business event in a target message queue, wherein the event message includes event parameters and event type;
[0028] A configuration information acquisition module, used to acquire message configuration information of the business event based on the event type, wherein the message configuration information includes at least one message type and message sending mode;
[0029] A message generation module, configured to generate a to-be-sent message of each message type based on a message content template of each message type and the event parameter by calling an abstract message factory corresponding to each message type in the at least one message type;
[0030] The message sending module is used to insert the to-be-sent messages of each message type generated into the corresponding sending queue for sending according to the message sending mode.
[0031] In some optional implementations of the present disclosure, the message generation module includes:
[0032] A construction submodule is used to call an abstract message factory corresponding to each message type, so that the abstract message factory constructs the event parameter into a data object as a message carrier of a message to be sent of each message type;
[0033] The generation submodule is used to generate to-be-sent messages of each message type based on the message content template and message carrier of each message type.
[0034] In some optional implementations of the present disclosure, the message sending mode is used to indicate the sending time and sending rules of the to-be-sent messages of each message type;
[0035] The sending time includes: real-time sending and delayed sending;
[0036] The sending rules include: sending all and sending only one.
[0037] In some optional implementations of the present disclosure, the message sending module includes:
[0038] A first sending submodule is used for, in response to the message sending mode indicating that the sending time is real-time sending, inserting the to-be-sent messages of each message type generated into the corresponding responsibility chain queue for sending according to the sending rule;
[0039] The second sending sub-module is used to insert the generated messages of each message type to be sent into a delayed message queue in response to the message sending mode indicating that the sending time is delayed sending, and periodically determine whether the messages in the delayed message queue arrive at the set sending time point, and execute the sending operation in response to a message arriving at the set sending time point.
[0040] In some optional implementations of the present disclosure, the first sending submodule includes:
[0041] A first sending unit, configured to, in response to the message sending mode indicating that the sending rule is to send all, insert the generated to-be-sent messages of each message type into a queue corresponding to the first responsibility chain, and each processor in the first responsibility chain sends the to-be-sent messages of each message type by calling a corresponding interface;
[0042] The second sending unit is used to, in response to the message sending method indicating that the sending rule is to send only one message, insert the generated messages of each message type to be sent into the queue corresponding to the second responsibility chain, and each processor in the second responsibility chain calls the corresponding interface to send the messages of each message type to be sent according to the set priority until one message to be sent is successfully sent.
[0043] In some optional implementations of the present disclosure, the message type includes at least one of the following: a service number message, a mini-program message, an in-site message, a push message, and an SMS message.
[0044] In some optional embodiments of the present disclosure, the device further comprises:
[0045] An operation execution module, configured to execute a business operation corresponding to a business event in response to monitoring the business event;
[0046] The message publishing module is used to insert the event message corresponding to the business event into the target message queue in response to the completion of the business operation.
[0047] According to another aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program instructions are executed, the above-mentioned message sending method is implemented.
[0048] According to another aspect of the embodiments of the present disclosure, an electronic device is provided, the electronic device comprising:
[0049] a memory for storing a computer program product;
[0050] The processor is used to execute the computer program product stored in the memory, and when the computer program product is executed, the above-mentioned message sending method is implemented.
[0051] According to another aspect of the embodiments of the present disclosure, a computer program instruction is provided, and when the computer program instruction is executed by a processor, the above-mentioned message sending method is implemented.
[0052] Based on the message sending method, storage medium and electronic device provided by the above-mentioned embodiments of the present disclosure, after the message sending platform obtains the event message of the business event in the target message queue, it can determine whether the business event needs to send a message according to the event type and obtain the message configuration information of the business event, and generate the to-be-sent messages of each message type based on the message content template and event parameters of each message type by calling the abstract message factory corresponding to each message type in the at least one message type; and according to the message sending method, the generated to-be-sent messages of each message type are respectively inserted into the corresponding sending queue for sending. Therefore, the technical solution of the present disclosure can realize message sending by publishing and subscribing (target message queue), realizes the decoupling of message sending and business system, and can automatically construct the to-be-sent messages of each message type by means of abstract message factory and message template, improves the efficiency and standardization of message generation; and after the message is generated, the message is automatically sent according to the set message sending method, which simplifies the message sending process.
[0053] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The above and other purposes, features and advantages of the present disclosure will become more apparent by describing the embodiments of the present disclosure in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. In the drawings, the same reference numerals generally represent the same components or steps.
[0055] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0056] Figure 1 A schematic diagram of a message sending architecture in the message sending method disclosed herein;
[0057] Figure 2 A flowchart of an embodiment of the message sending method disclosed in the present invention;
[0058] Figure 3 A flowchart for generating a message to be sent in the message sending method disclosed in the present invention;
[0059] Figure 4 A schematic diagram of the structure of an embodiment of a message sending device disclosed in the present invention;
[0060] Figure 5 This is a structural diagram of another embodiment of the message sending device disclosed in the present invention;
[0061] Figure 6 A structural diagram of an electronic device provided for an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0062] Below, the exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described here.
[0063] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless specifically stated otherwise.
[0064] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0065] It should also be understood that in the embodiments of the present disclosure, “plurality” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.
[0066] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0067] In addition, the term "and / or" in the present disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present disclosure generally indicates that the associated objects before and after are in an "or" relationship.
[0068] It should also be understood that the description of the various embodiments in the present disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0069] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0070] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0071] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0072] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0073] The disclosed embodiments can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0074] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0075] SUMMARY OF THE DISCLOSURE
[0076] The technical solution provided by the embodiments of the present disclosure is used in scenarios where business events occur in a business system and messages need to be sent to users. For example, when a new order is generated in an order system, an event message can be inserted into a target message queue, such as a Kafka message queue. When a message sending platform consumes messages in the target message queue, it can obtain corresponding message configuration information based on the event message, thereby realizing automatic generation and sending of messages.
[0077] The disclosed embodiments can be applied to the message sending platform to generate and send various types of messages, such as mini program messages, in-site notification messages, instant messaging (IM), push messages, short messages, enterprise WeChat messages, etc.
[0078] Figure 1 FIG. 1 is a schematic diagram of a message sending architecture in the message sending method disclosed in the present invention. Figure 1 As shown in the figure, when a business party generates a business event, it can send an event message corresponding to the business event to the target message queue, for example, a domain message generated when the business party generates transaction events such as order, shipment, successful delivery, and initiation of collection, or a service number message, mini program message, station letter, etc. forwarded by an instant messaging tool; when the message sending platform obtains and consumes these event messages from the target message queue, it can obtain from the configuration file whether the business event corresponding to the event message needs to send a message, and obtain the message configuration information of the business event when it needs to send a message, and build a message according to the message template by calling the abstract message factory. Different message types correspond to different abstract message factories and message templates. For example, the SMS abstract message factory is responsible for building payment reminder SMS messages, contract signing SMS messages, etc., and the mini program abstract message factory is responsible for building payment reminder mini program messages, contract signing mini program messages, etc. After building the good news, the message can be pushed to the user through the set message sending method, such as responsibility chain, delay queue, etc.
[0079] Among them, when using the responsibility chain mode to send messages in real time, the message sending logic can be divided into two responsibility chains. Each processor in one responsibility chain stops sending after successfully sending a message (such as only sending one of the service number message and the mini program message, which have priority and mutual exclusion), while the other responsibility chain sends all forms of messages (such as SMS messages and push messages can be sent at the same time). For messages that need to be sent with a delay, for example, the notification message of "10 minutes left for order closing", a delay queue can be used to periodically (every 10 minutes) determine whether it has arrived 10 minutes before the time point, and perform the sending operation when it arrives.
[0080] Among them, the responsibility chain pattern is a software design pattern in object-oriented programming, which includes some command objects and a series of processing objects. Each processing object determines the command objects that it can process, and can pass the command objects that cannot be processed to the next processing object in the responsibility chain. In the embodiment of the present disclosure, the responsibility chain can include the general sending logic of messages such as SMS, in-station messages, and mini-programs, such as a processor for sending SMS and a processor for sending in-station messages. Each type of processor is only responsible for sending messages of the corresponding type.
[0081] Exemplary Methods
[0082] Figure 2 Flow chart of an embodiment of the message sending method disclosed in the present invention; the message sending method can be applied to electronic devices (such as computer systems, servers), such as Figure 2 As shown, the message sending method includes the following steps 201 to 204. Each step is described below.
[0083] In step 201, an event message of a business event in a target message queue is obtained, where the event message includes event parameters and event type.
[0084] In some optional implementations, the target message queue may be a Kafka message queue, RocketMQ, etc. When business events are generated in various business systems, such as generating an order, shipping, successful delivery, initiating collection, signing a contract, etc., an event message indicating the occurrence / completion of a certain business event may be pushed to the target message queue.
[0085] Among them, business events can be various events generated by the business system that may require pushing notification messages to users. They can be transaction events, news events, customer service feedback events, etc.
[0086] In some optional implementations, event parameters may indicate relevant information of the event, for example, event parameters of a contract signing event may include information such as signing time, signatory, contract amount, etc. Event type may indicate the type of business event, for example, the business event is a contract signing event, a shipping event, a logistics change event, etc.
[0087] In specific implementation, after any business event occurs in the business system, the business operation corresponding to the business event can be executed first, such as executing a transaction operation, executing an order generation operation, etc., and after the business operation is completed, the event message corresponding to the business event is inserted into the target message queue to realize message publishing. After the business system pushes the event message of the business event to the preset target message queue, the message sending platform can consume the event message in the target message queue in real time, and execute the message sending operation when the business event indicated by the consumed event message needs to send a message to the user. The decoupling of the business system and the message sending platform is realized through this publish-subscribe method.
[0088] In step 202, based on the event type, message configuration information of the business event is obtained, where the message configuration information includes at least one message type and a message sending mode.
[0089] In some optional implementations, corresponding message configuration information can be pre-set in a configuration file for business events that require sending messages to users. The configuration file can store the event type, message type, and message sending method for the event that requires sending notification messages to users. For example, for events of logistics change type, the message configuration information can be configured to "send notification messages of the in-site message type and service number message type to users, and the message sending method is to send only one of them". Then, when the message sending platform consumes business events of the logistics change type from the target message queue, it can send messages to users according to the message configuration information.
[0090] In some optional implementations, the message type is used to indicate the type of notification message sent to the user, which may include service number message, mini program message, in-station message, PUSH message, SMS message, etc. For different business events, you can choose to send messages of different message types to the user.
[0091] In specific implementation, you can choose to send corresponding types of messages to users according to the importance of the business event and the degree of relevance to the user. For example, through calculation, it can be found that instant chat, text messages and other message types are more relevant to users, and users usually do not resist such messages. Therefore, you can pre-configure the sending of instant chat, text messages and other types of messages for business events of more important event types. For notification messages of less important business events, such as notification messages of logistics change events, you can configure the sending of in-site messages, mini-program messages, etc.
[0092] In some optional implementations, the message sending method may indicate the message sending rule. For example, for business event 1, a service number message, a mini program message, an in-station message, a PUSH message, and an SMS message may be sent to the user. If the message sending method is to send all, then all messages of the service number message, the mini program message, the in-station message, the PUSH message, and the SMS message need to be sent to the user. If the message sending method is to send only one, then only one of the service number message, the mini program message, the in-station message, the PUSH message, and the SMS message needs to be successfully sent to the user. If one message is sent successfully, the sending of other types of messages will be stopped.
[0093] In step 203, by calling the abstract message factory corresponding to each message type in at least one message type, based on the message content template and event parameters of each message type, a message to be sent of each message type is generated.
[0094] In some optional implementations, the abstract message factory is a creational design pattern that provides an interface for creating a series of related or interdependent objects without specifying their specific classes. Different abstract message factories can implement messages of different message types. For example, the SMS message abstract factory is responsible for building payment reminder SMS messages, contract signing SMS messages, etc., and the mini program message abstract factory is responsible for building payment reminder mini program messages, contract signing mini program messages, etc.
[0095] The abstract factory of each message type can be implemented through code. For example, the abstract factory method instance of the in-station message is as follows:
[0096]
[0097]
[0098]
[0099]
[0100] The above code illustrates that the in-station message abstract factory implements in-station message of various event types. Abstract factories of other message types can define different instances according to the format requirements of mini-program messages, short messages, etc. or the requirements of the Application Programming Interface (API).
[0101] In some optional implementations, message content templates refer to templates of content structures and formats of different types of messages. For example, different types of messages such as mini program messages, in-station messages, and short messages may have different content structures, so corresponding message content templates may be pre-defined according to the structural format requirements or API forms of mini program messages, in-station messages, and short messages.
[0102] In some optional implementations, the specific event parameters of each business event are different, so the abstract message factory can generate the specific event parameters into a data object as a message carrier, and generate the event message of the business event according to the message carrier and the message content template. For example, when generating a notification message of a contract signing business event, the contract signing time, the signatory, etc. can be constructed into a data object as a message carrier, and then the abstract message factory can combine the message carrier and the message content template to generate the corresponding message to be sent.
[0103] In step 204, according to the message sending mode, the generated messages to be sent of each message type are respectively inserted into the corresponding sending queue for sending.
[0104] In some optional implementations, the message sending mode is used to indicate the sending time and sending rules of the to-be-sent messages of each message type. The sending time may include: real-time sending, delayed sending. The sending rules may include: sending all, sending only one.
[0105] In specific implementation, when the message sending mode indicates that the sending time is real-time sending, the generated messages of each message type to be sent will be inserted into the corresponding responsibility chain queue for sending according to the sending rules; when the message sending mode indicates that the sending time is delayed sending, the generated messages of each message type to be sent will be inserted into the delayed message queue, and it is periodically determined whether the messages in the delayed message queue have arrived at the set sending time point. In response to a message arriving at the set sending time point, the sending operation is executed.
[0106] In some optional implementations, when it is necessary to send messages in real time, the messages can be inserted into one of the two responsibility chains according to the sending rules. When the sending rule is to send all, the generated messages to be sent of each message type are inserted into the queue corresponding to the first responsibility chain, and each processor in the first responsibility chain sends the messages to be sent of each message type by calling the corresponding interface. For example, if SMS messages, push messages, and mini-program messages all need to be sent, then the SMS messages, push messages, and mini-program messages can all be sent into the queue corresponding to the first responsibility chain, and the SMS message processor, push message processor, and mini-program message processor in the first responsibility chain send the corresponding messages to be sent by calling the corresponding interface. When the sending rule is to send only one type, the generated messages to be sent of each message type are inserted into the queue corresponding to the second responsibility chain, and each processor in the second responsibility chain calls the corresponding interface to send the messages to be sent of each message type according to the set priority. Each processor stops sending after successfully sending one message (such as sending only one of the service number message and the mini-program message, which have priority and mutual exclusivity).
[0107] As an example, notification messages for most business events can be sent in real time, such as contract reminders, shipping notifications, etc. When the message sending platform consumes event messages of such business events in the target message queue, it can generate corresponding notification messages (messages to be sent) and send such messages in real time. However, some reminder order events may require delayed sending of notification messages, such as reminder notification messages such as order closing in 10 minutes. When the message sending platform consumes event messages of order placement events in the target message queue, it can generate reminder notification messages and use a delay queue to periodically (such as every 5 minutes) determine whether it has reached 10 minutes before the order closing time point. If it has, the reminder notification message will be sent.
[0108] In some optional implementations, the rules for sending messages to users may be configured in the current configuration file based on the importance of the business event and the degree of relevance to the user. For example, for unimportant messages, only one type of notification message may be sent to the user, while for very important messages, all types of notification messages may be sent to the user.
[0109] In some optional implementations, a corresponding message sending method can be set for each message type. For example, the message sending platform determines that mini program messages, in-site messages, text messages, and PUSH messages can be sent to users based on the message configuration information of business event 1. The message sending method for mini program and in-site message messages is to send only one message, which means that only one of the mini program and in-site message messages needs to be sent, and the message sending method for text messages and PUSH messages is "all", which means that both text messages and PUSH messages need to be sent.
[0110] In the above steps 201 to 204, after the message sending platform obtains the event message of the business event in the target message queue, it can determine whether the business event needs to send a message according to the event type and obtain the message configuration information of the business event, and generate the to-be-sent messages of each message type based on the message content template and event parameters of each message type by calling the abstract message factory corresponding to each message type in at least one message type; and according to the message sending method, the generated to-be-sent messages of each message type are respectively inserted into the corresponding sending queue for sending. Therefore, the technical solution disclosed in the present invention can implement message sending by means of publish-subscribe (target message queue), realizes the decoupling of message sending and business system, and can automatically construct the to-be-sent messages of each message type by means of abstract message factory and message template, thereby improving the efficiency and standardization of message generation; and after the message is generated, the message is automatically sent according to the set message sending method, thereby simplifying the message sending process.
[0111] Figure 3 A flowchart of generating a message to be sent in the message sending method disclosed in the present invention; Figure 3 As shown, in this embodiment, step 203 may include steps 231 to 232. Each step is described below.
[0112] In step 231, by calling the abstract message factory corresponding to each message type, the abstract message factory constructs the event parameter into a data object as a message carrier of the message to be sent of each message type.
[0113] In some optional implementations, the abstract message factory is used to provide an interface for creating a series of related or interdependent objects. Different abstract message factories can implement messages of different message types. For example, the SMS message abstract factory is responsible for building payment reminder SMS messages, contract signing SMS messages, etc., and the mini program message abstract factory is responsible for building payment reminder mini program messages, contract signing mini program messages, etc.
[0114] In some optional implementations, the specific event parameters of each business event are different, so the specific event parameters can be generated into a data object by calling the abstract message factory as the message carrier of the message to be sent. The data object, as the message carrier, records the data information of the message.
[0115] In step 232, based on the message content template and message carrier of each message type, a to-be-sent message of each message type is generated.
[0116] In some optional implementations, since messages of different message types have different content structures, and messages of the same type have similar content structures or API format requirements, corresponding message content templates can be abstracted according to the content structures of messages of different message types.
[0117] The abstract message factory can combine the message carrier and the message content template to generate the corresponding message to be sent. For example, when generating a notification message of a contract signing event, the contract signing time, the signatory, etc. can be constructed into a data object as a message carrier, and then the abstract message factory can combine the message carrier and the message content template to generate the corresponding message to be sent.
[0118] Through the above steps 231 to 232, the corresponding type of to-be-sent message is automatically generated through the abstract message factory according to the message content template, which realizes the intelligent and automated message generation and improves the message generation efficiency and message templating.
[0119] Corresponding to the embodiments of the aforementioned message sending method, the present disclosure also provides corresponding embodiments of a message sending device.
[0120] Exemplary Devices
[0121] Figure 4 FIG. 1 is a schematic diagram of a structure of an embodiment of a message sending device disclosed in the present invention. The device is applied to a message sending platform (such as a computer system or a server). Figure 4 As shown, the device comprises:
[0122] The message acquisition module 41 is used to acquire the event message of the business event in the target message queue, and the event message includes event parameters and event type;
[0123] A configuration information acquisition module 42, used to acquire message configuration information of a business event based on the event type, where the message configuration information includes at least one message type and a message sending mode;
[0124] A message generation module 43, configured to generate a to-be-sent message of each message type based on a message content template and event parameters of each message type by calling an abstract message factory corresponding to each message type in at least one message type;
[0125] The message sending module 44 is used to insert the to-be-sent messages of each message type generated into the corresponding sending queue for sending according to the message sending mode.
[0126] Figure 5 FIG. 1 is a structural diagram of another embodiment of the message sending device disclosed in the present invention. Figure 5 As shown, in Figure 4 Based on the illustrated embodiment, in some optional implementations of the present disclosure, the message generating module 43 includes:
[0127] The construction submodule 431 is used to call the abstract message factory corresponding to each message type to realize that the abstract message factory constructs the event parameter into a data object as a message carrier of the message to be sent of each message type;
[0128] The generating submodule 432 is used to generate a to-be-sent message of each message type based on a message content template and a message carrier of each message type.
[0129] In some optional implementations of the present disclosure, the message sending mode is used to indicate the sending time and sending rules of the to-be-sent messages of each message type;
[0130] Sending time includes: real-time sending and delayed sending;
[0131] The sending rules include: send all, send only one.
[0132] In some optional implementations of the present disclosure, the message sending module 44 includes:
[0133] The first sending submodule 441 is used for, in response to the message sending mode indicating that the sending time is real-time sending, inserting the to-be-sent messages of each message type generated into the corresponding responsibility chain queue for sending according to the sending rule;
[0134] The second sending submodule 442 is used to insert the generated messages of each message type to be sent into the delayed message queue in response to the message sending mode indicating that the sending time is delayed sending, and periodically determine whether the messages in the delayed message queue arrive at the set sending time point, and execute the sending operation in response to a message arriving at the set sending time point.
[0135] In some optional implementations of the present disclosure, the first sending submodule 441 includes:
[0136] The first sending unit 4411 is used for inserting the to-be-sent messages of each message type generated into the queue corresponding to the first responsibility chain in response to the message sending mode indicating that the sending rule is to send all, and each processor in the first responsibility chain sends the to-be-sent messages of each message type by calling the corresponding interface;
[0137] The second sending unit 4412 is used to insert the generated messages of each message type to be sent into the queue corresponding to the second responsibility chain in response to the message sending method indicating that the sending rule is to send only one message. Each processor in the second responsibility chain calls the corresponding interface to send the messages of each message type to be sent according to the set priority until one message to be sent is successfully sent.
[0138] In some optional implementations of the present disclosure, the message type includes at least one of the following: a service account message, a mini-program message, an in-site message, a push message, and an SMS message.
[0139] In some optional embodiments of the present disclosure, the device further comprises:
[0140] An operation execution module 45, configured to execute a business operation corresponding to a business event in response to monitoring the business event;
[0141] The message publishing module 46 is used to insert an event message corresponding to the business event into a target message queue in response to the completion of the business operation execution.
[0142] The modules and units in the device disclosed in the present invention can also be divided into finer granularity according to actual needs, and can be specifically set according to actual needs.
[0143] The device of the embodiment of the present disclosure can be used to implement the methods of the above-mentioned embodiments of the present disclosure. The two correspond to each other in specific implementation, and the specific implementations of related parts are referenced to each other, which will not be repeated here.
[0144] Exemplary electronic devices, computer program products, and computer-readable storage media
[0145] An embodiment of the present disclosure further provides an electronic device, comprising: a memory for storing a computer program; a processor for executing the computer program stored in the memory, and when the computer program is executed, the message sending method of any of the above embodiments of the present disclosure is implemented.
[0146] Below, reference Figure 6 An electronic device according to an embodiment of the present disclosure is described, in which a device for implementing the method according to an embodiment of the present disclosure may be integrated. Figure 6 A structural diagram of an electronic device provided in an exemplary embodiment of the present disclosure, such as Figure 6 As shown, the electronic device includes one or more processors 61, one or more computer-readable storage media memory 62, and a computer program stored in the memory and executable on the processor. When the program in the memory 62 is executed, the above-mentioned message sending method can be implemented.
[0147] Specifically, in practical applications, the electronic device may further include components such as an input device 63 and an output device 64, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown). Those skilled in the art will appreciate that Figure 6 The structure of the electronic device shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or certain components, or different component arrangements.
[0148] in:
[0149] The processor 61 can be a central processing unit (CPU) or other forms of processing units with message sending capabilities and / or instruction execution capabilities. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 62, and calling data stored in the memory 62, thereby monitoring the electronic device as a whole.
[0150] The memory 62 may store one or more computer program products, and the memory may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The above-mentioned volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The above-mentioned non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program products may be stored on the computer-readable storage medium, and the processor 61 may run the computer program products to implement the message sending method of each embodiment of the present disclosure above and / or other desired functions.
[0151] The input device 63 can be used to receive input digital or character information. The input device 63 can include a keyboard, a mouse, a joystick, etc. related to user settings and function control.
[0152] The output device 64 can output various information to the outside, including the determined distance information, direction information, etc. The output device 64 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0153] The electronic device may also include a power supply for supplying power to various components, which may be logically connected to the processor 61 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply may also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0154] Of course, to simplify, Figure 6 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device may further include any other appropriate components.
[0155] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps in the message sending method according to various embodiments of the present disclosure described in the above-mentioned "Exemplary Method" section of this specification.
[0156] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0157] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the message sending method according to various embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
[0158] Computer readable storage media can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0159] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0160] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0161] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.
[0162] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0163] The description of the present disclosure is given for the purpose of illustration and description, and is not intended to be exhaustive or to limit the present disclosure to the disclosed form. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present disclosure, and to enable those of ordinary skill in the art to understand the present disclosure and thereby design various embodiments with various modifications suitable for specific uses.
Claims
1. A message sending method, characterized in that: Applied to the messaging platform, including: Obtaining an event message of a business event in a target message queue, wherein the event message includes event parameters and an event type; Based on the event type, acquiring message configuration information of the business event, the message configuration information including at least one message type and message sending mode; Generate a to-be-sent message of each message type based on a message content template of each message type and the event parameter by calling an abstract message factory corresponding to each message type in the at least one message type; According to the message sending method, the generated messages to be sent of each message type are respectively inserted into the corresponding sending queue for sending.
2. The method according to claim 1, characterized in that: The generating of the to-be-sent messages of each message type based on the message content template of each message type and the event parameter by calling the abstract message factory corresponding to each message type of the at least one message type includes: By calling the abstract message factory corresponding to each message type, the abstract message factory constructs the event parameter into a data object as a message carrier of the message to be sent of each message type; Generate messages of each message type to be sent based on the message content template and message carrier of each message type.
3. The method according to any one of claims 1-2, characterized in that: The message sending mode is used to indicate the sending time and sending rules of the messages to be sent of each message type; The sending time includes: real-time sending and delayed sending; The sending rules include: sending all and sending only one.
4. The method according to claim 3, characterized in that According to the message sending mode, the generated messages of each message type to be sent are respectively inserted into the corresponding sending queue for sending, including: In response to the message sending mode indicating that the sending time is real-time sending, the generated to-be-sent messages of each message type are respectively inserted into the corresponding responsibility chain queue for sending according to the sending rule; In response to the message sending method indicating that the sending time is delayed sending, the generated messages of each message type to be sent are inserted into the delayed message queue, and it is periodically determined whether the messages in the delayed message queue arrive at the set sending time point. In response to a message arriving at the set sending time point, a sending operation is performed.
5. The method according to claim 4, characterized in that According to the sending rule, the generated messages of each message type to be sent are respectively inserted into the corresponding responsibility chain queue for sending, including: In response to the message sending mode indicating that the sending rule is to send all, the generated to-be-sent messages of each message type are inserted into the queue corresponding to the first responsibility chain, and each processor in the first responsibility chain sends the to-be-sent messages of each message type by calling the corresponding interface; In response to the message sending method indicating that the sending rule is to send only one type, the generated messages to be sent of each message type are inserted into the queue corresponding to the second responsibility chain, and each processor in the second responsibility chain calls the corresponding interface to send the messages to be sent of each message type according to the set priority until one message to be sent is successfully sent.
6. The method according to claim 1, characterized in that The message type includes at least one of the following: service account message, mini program message, in-site message, push message, and SMS message.
7. The method according to any one of claims 1 to 6, characterized in that: Before obtaining the event message of the business event in the target message queue, the method further includes: In response to monitoring a business event, executing a business operation corresponding to the business event; In response to the completion of the business operation, an event message corresponding to the business event is inserted into the target message queue.
8. A computer-readable storage medium, wherein the storage medium stores computer program instructions, and when the computer program instructions are executed, the method according to any one of claims 1 to 7 is implemented.
9. An electronic device, comprising: a memory for storing a computer program product; A processor is used to execute the computer program product stored in the memory, and when the computer program product is executed, it implements the method described in any one of claims 1 to 7.
10. A computer program product comprising computer program instructions, characterized in that When the computer program instructions are executed by a processor, the method described in any one of claims 1 to 7 is implemented.
