Message sending method, device, equipment, system and storage medium

文档序号:1965904 发布日期:2021-12-14 浏览:18次 中文

阅读说明:本技术 消息发送方法、装置、设备、系统与存储介质 (Message sending method, device, equipment, system and storage medium ) 是由 袁桂敏 于 2021-07-27 设计创作,主要内容包括:本发明提供一种消息发送方法、装置、设备、系统与存储介质,所述方法用于消息服务系统,所述方法包括:从业务系统获取待发送的目标消息,所述目标消息是所述业务系统按照设定消息体结构组装成的消息;对所述目标消息进行消息校验,得到校验结果;若所述校验结果为通过校验,则根据所述目标消息的消息类型确定所述目标消息对应的发送方式,按照所述发送方式将所述目标消息发送至所述目标消息对应的目标地址。本发明提供的消息发送方法、装置、设备、系统与存储介质,实现了对消息发送的统一化管理,提高了消息发送的可靠性和可扩展性。(The invention provides a message sending method, a device, equipment, a system and a storage medium, wherein the method is used for a message service system and comprises the following steps: acquiring a target message to be sent from a service system, wherein the target message is a message assembled by the service system according to a set message body structure; carrying out message verification on the target message to obtain a verification result; and if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode. The message sending method, the device, the equipment, the system and the storage medium realize the unified management of message sending and improve the reliability and the expandability of message sending.)

1. A message sending method, wherein the method is used in a message service system, and wherein the method comprises:

acquiring a target message to be sent from a service system, wherein the target message is a message assembled by the service system according to a set message body structure;

carrying out message verification on the target message to obtain a verification result;

and if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode.

2. The messaging method of claim 1, wherein the messaging service system comprises a distributed message queue, Nats-MQ;

the obtaining of the target message to be sent from the service system includes:

and monitoring the target message from the service system in the distributed message queue Nats-MQ.

3. The method of claim 1, wherein the messaging service system comprises a distributed message queue, Nats-MQ, and a first application program interface, API;

the obtaining of the target message to be sent from the service system includes:

and monitoring the target message from the first application program interface API in the distributed message queue Nats-MQ, wherein the first application program interface API is used for receiving the target message from the business system and synchronizing the target message into the distributed message queue Nats-MQ.

4. The message sending method according to any one of claims 1 to 3, wherein the performing message verification on the target message to obtain a verification result includes:

according to each set parameter included in the set message body structure, carrying out first verification on the target message;

if the first verification is verification passing, determining the message type of the target message, and performing second verification on a set field of the target message according to the message type, wherein the set field corresponds to the message type;

and if the second verification is verification passing, determining that the verification result is verification passing.

5. The method according to claim 4, wherein the performing the first verification on the target message according to each setting parameter included in the setting message body structure includes:

and carrying out first verification on the target message in a Data Transmission Object (DTO) mode.

6. The method according to claim 1, further comprising:

storing the target message to a set area of the message service system;

or the like, or, alternatively,

and sending the target message to a target address corresponding to the target message, and simultaneously storing the target message to a set area of the message service system by adopting a multithreading synchronization mechanism.

7. The message transmission method according to claim 1 or 6, characterized by further comprising:

detecting whether the target message is successfully sent;

if the target message is determined to be successfully sent, storing a first sending result used for indicating the successful sending to a set area of the message service system or storing the first sending result to the set area by adopting a multithread asynchronous callback;

if the target message is determined to be failed to be sent, the target message is sent to a target address corresponding to the target message again according to the sending mode; if the target message is successfully sent when the number of times of resending is detected to be less than or equal to the set number of times of failed retries, the first sending result is stored in the set area or the first sending result is stored in the set area by adopting a multi-thread asynchronous callback, if the number of times of resending is detected to be equal to the set number of times of failed retries, the target message is failed to be sent, the resending of the target message is stopped, and a second sending result used for indicating the failure of the sending is stored in the set area or the second sending result is stored in the set area by adopting the multi-thread asynchronous callback.

8. The method according to claim 7, wherein the message service system comprises a second Application Program Interface (API);

the method further comprises the following steps:

receiving a query request message from the service system through the second application program interface API, wherein the query request message is used for querying a sending result of the target message;

acquiring a sending result of the target message from the set area according to the inquired request message, wherein the sending result of the target message is the first sending result or the second sending result;

and sending the first sending result or the second sending result to the service system through the second application program interface API.

9. A message transmission apparatus, for use in a message service system, the apparatus comprising:

the system comprises an acquisition module, a sending module and a sending module, wherein the acquisition module is used for acquiring a target message to be sent from a service system, and the target message is a message assembled by the service system according to a set message body structure;

the checking module is used for carrying out message checking on the target message to obtain a checking result;

and the sending module is used for determining a sending mode corresponding to the target message according to the message type of the target message and sending the target message to a target address corresponding to the target message according to the sending mode if the verification result is that the verification is passed.

10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the message sending method according to any of claims 1 to 8 are implemented when the processor executes the program.

11. A message management system is characterized by comprising a service system and a message sending system;

the service system is used for assembling a target message to be sent according to a set message body structure and sending the target message to the message sending system;

the messaging system is arranged to perform the steps of the messaging method of any of claims 1 to 8.

12. A non-transitory computer readable storage medium, having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the steps of the message sending method according to any one of claims 1 to 8.

13. A computer program product having executable instructions stored thereon, which instructions, when executed by a processor, cause the processor to carry out the steps of the method of transmitting a message according to any one of claims 1 to 8.

Technical Field

The present invention relates to the field of network security technologies, and in particular, to a message sending method, device, apparatus, system, and storage medium.

Background

The message sending method includes many ways, such as sending the message by mail, short message, blue message, etc.

However, the message transmission implemented in the prior art has the following problems because different service modules respectively implement a set of programs: the method comprises the following steps that (1) due to the fact that message sending programs of all service modules are not uniform, resolving logics are not consistent, readability is poor, maintenance cost is high, and mistakes are easy to make; secondly, each service module needs to be changed once when configuration change occurs due to the fact that each service module maintains a set of configuration information, maintenance cost is high, and mistakes are easy to occur; and (III) the same message sending mode can be realized once in different service modules, and the expandability is poor.

Disclosure of Invention

Aiming at the problems in the prior art, the invention provides a message sending method, a message sending device, message sending equipment, message sending system and a storage medium.

The invention provides a message sending method, which is used for a message service system and comprises the following steps:

acquiring a target message to be sent from a service system, wherein the target message is a message assembled by the service system according to a set message body structure;

carrying out message verification on the target message to obtain a verification result;

and if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode.

According to the message sending method provided by the invention, the message service system comprises a distributed message queue Nats-MQ;

the obtaining of the target message to be sent from the service system includes:

and monitoring the target message from the service system in the distributed message queue Nats-MQ.

According to the message sending method provided by the invention, the message service system comprises a distributed message queue Nats-MQ and a first application program interface API;

the obtaining of the target message to be sent from the service system includes:

and monitoring the target message from the first application program interface API in the distributed message queue Nats-MQ, wherein the first application program interface API is used for receiving the target message from the business system and synchronizing the target message into the distributed message queue Nats-MQ.

According to the message sending method provided by the invention, the message verification is performed on the target message to obtain the verification result, and the method comprises the following steps:

according to each set parameter included in the set message body structure, carrying out first verification on the target message;

if the first verification is verification passing, determining the message type of the target message, and performing second verification on a set field of the target message according to the message type, wherein the set field corresponds to the message type;

and if the second verification is verification passing, determining that the verification result is verification passing.

According to a message sending method provided by the present invention, the first verification of the target message according to each setting parameter included in the setting message body structure includes:

and carrying out first verification on the target message in a Data Transmission Object (DTO) mode.

The message sending method provided by the invention further comprises the following steps:

storing the target message to a set area of the message service system;

or the like, or, alternatively,

and sending the target message to a target address corresponding to the target message, and simultaneously storing the target message to a set area of the message service system by adopting a multithreading synchronization mechanism.

The message sending method provided by the invention further comprises the following steps:

detecting whether the target message is successfully sent;

if the target message is determined to be successfully sent, storing a first sending result for indicating the successful sending to a set area of the message service system;

if the target message is determined to be failed to be sent, the target message is sent to a target address corresponding to the target message again according to the sending mode; if the target message is successfully sent when the number of times of resending is detected to be less than or equal to the set number of times of failed retries, the first sending result is stored in the set area or the first sending result is stored in the set area by adopting a multi-thread asynchronous callback, if the number of times of resending is detected to be equal to the set number of times of failed retries, the target message is failed to be sent, the resending of the target message is stopped, and a second sending result used for indicating the failure of the sending is stored in the set area or the second sending result is stored in the set area by adopting the multi-thread asynchronous callback.

According to the message sending method provided by the invention, the message service system comprises a second Application Program Interface (API);

receiving a query request message from the service system through the second application program interface API, wherein the query request message is used for querying a sending result of the target message;

acquiring a sending result of the target message from the set area according to the inquired request message, wherein the sending result of the target message is the first sending result or the second sending result;

and sending the first sending result or the second sending result to the service system through the second application program interface API.

The present invention also provides a message transmitting apparatus, which is used in a message service system, and the apparatus includes:

the system comprises an acquisition module, a sending module and a sending module, wherein the acquisition module is used for acquiring a target message to be sent from a service system, and the target message is a message assembled by the service system according to a set message body structure;

the checking module is used for carrying out message checking on the target message to obtain a checking result;

and the sending module is used for determining a sending mode corresponding to the target message according to the message type of the target message and sending the target message to a target address corresponding to the target message according to the sending mode if the verification result is that the verification is passed.

The present invention also provides an electronic device, comprising a memory, a processor and a computer program stored on the memory and operable on the processor, wherein the processor implements the steps of any of the above-mentioned message sending methods when executing the program.

The invention also provides a message management system, which comprises a service system and a message sending system; the service system is used for assembling a target message to be sent according to a set message body structure and sending the target message to the message sending system; the message service system is configured to perform any of the steps of the message sending method.

The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the message sending method as any one of the above.

The invention also provides a computer program product having stored thereon a computer program which, when executed by a processor, carries out the steps of the message sending method as claimed in any one of the above.

The message sending method, the device, the equipment, the system and the storage medium provided by the invention carry out message verification on the target message assembled by the service system according to the set message body structure, if the verification result is that the verification is passed, the sending mode corresponding to the target message is determined according to the message type of the target message, and the target message is sent to the target address corresponding to the target message according to the sending mode, so that the unified management on message sending is realized, and the reliability and the expandability of message sending are improved; in addition, by providing a uniform set message body structure for each service system, the target messages sent by each service system are favorably unified, so that all the messages are analyzed and normalized, and the problems of disordered codes, poor readability and the like are avoided; and the service program and the message sending program are decoupled, so that the reusability of the message sending service is enhanced, and the platform portability is strong because the independent message sending service is a micro-service architecture.

Drawings

In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.

Fig. 1 is a schematic flow chart of a message sending method provided by the present invention;

fig. 2 is one of the scene diagrams of the message sending method provided by the present invention;

fig. 3 is a second scenario diagram of the message sending method provided by the present invention;

fig. 4 is a third schematic view of a scenario of a message sending method provided by the present invention;

fig. 5 is another schematic flow chart of a message sending method provided by the present invention;

fig. 6 is a schematic diagram of another process of the message sending method provided by the present invention;

FIG. 7 is a schematic structural diagram of a message sending apparatus provided in the present invention;

fig. 8 is a schematic structural diagram of an electronic device provided in the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The message sending method, apparatus, device, system and storage medium of the present invention are described below with reference to fig. 1-8.

Fig. 1 is a schematic flow chart of a message sending method provided by the present invention, and as shown in fig. 1, the message sending method of the present invention may be applied to a message service system, and the message sending method may include the following steps:

step 101, obtaining a target message to be sent from a service system, where the target message is a message assembled by the service system according to a set message body structure.

Specifically, the message service system of the present invention can provide a unified set message body structure, which can be used by different service systems. And the service system can also be assembled into the target message according to the set message body structure according to the respective service requirements.

Such as: the configuration message body structure may include, but is not limited to, the following structural forms:

and 102, carrying out message verification on the target message to obtain a verification result.

Specifically, after the message service system of the present invention obtains the target message, the message service system may perform message verification on the target message according to the set message body structure to obtain a verification result, and if the verification is passed, it is determined that the message service system can perform message transmission on the target message; if the verification is not passed, returning an abnormal message for indicating that the verification is not passed to the service system.

And 103, if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode.

Specifically, the message type of the target message may include various types, such as: in-station letters, mails, short messages, blue letters, micro letters, nails, and the like.

The transmission mode corresponding to the target message is corresponding to the message type.

Such as: the message type is station information, and the message service system can push the monitored target message to the web front end in real time in a WebSocket mode. The WebSocket is a full duplex communication Protocol based on a Transmission Control Protocol (TCP).

For another example: the message type is mail, short message, blue letter, WeChat, nail, etc., and the message service system may perform secondary assembly on the target message through the configuration message (e.g., gateway, user name, password, token, etc.) of the message type, and then send the target message after the secondary assembly to the target address corresponding to the target message.

The destination address corresponding to the destination message may refer to the recipient of the destination message. Such as: mail receiver, short message receiver, blue message receiver.

The message sending method provided by the invention carries out message verification on the target message assembled by the service system according to the set message body structure, if the verification result is that the verification is passed, the sending mode corresponding to the target message is determined according to the message type of the target message, and the target message is sent to the target address corresponding to the target message according to the sending mode, so that the unified management of message sending is realized, and the reliability and the expandability of message sending are improved; in addition, by providing a uniform set message body structure for each service system, the target messages sent by each service system are favorably unified, so that all the messages are analyzed and normalized, and the problems of disordered codes, poor readability and the like are avoided; and the service program and the message sending program are decoupled, so that the reusability of the message sending service is enhanced, and the platform portability is strong because the independent message sending service is a micro-service architecture.

Based on any one of the above embodiments, in this embodiment, the Message service system includes a distributed Message Queue (Nats-Message Queue, Nats-MQ); in performing step 101, may include:

listening for the target message from the business system in the distributed message queue (Nats-MQ).

Specifically, as shown in FIG. 2, a distributed message queue (Nats-MQ) is an important component in a message service system for receiving targeted messages from a business system. The message service system (e.g., the listening module (i.e., NatListeners) in fig. 2) may listen in real-time to the targeted messages received by the distributed message queue (Nats-MQ).

The message sending method provided by the invention can acquire the target message of the service system through the distributed message queue (Nats-MQ), thereby improving the efficiency of acquiring the target message.

Based on any of the above embodiments, in this embodiment, the message service system includes a distributed message queue (nat-MQ) and a first Application Programming Interface (API); in performing step 101, may include:

listening for the target message from the first API in the distributed message queue (Nats-MQ), the first API for receiving the target message from the business system and synchronizing to the distributed message queue (Nats-MQ).

Specifically, as shown in fig. 3, the message service system may include the following two ways to receive the target message:

mode one, distributed message queue (Nats-MQ)

In particular, distributed message queues (Nats-MQ) are important components of a messaging service system that can be used to directly receive targeted messages from a business system.

Mode two, API (i.e. API1 in FIG. 3)

In particular, the API1 provides a unified API service interface for the message service system to the business system (i.e., platform, system module, terminal, etc. in fig. 3), which can be used to directly receive a target message from the business system and synchronize the target message to a distributed message queue (Nats-MQ).

In both of the above manners, if the message size is large, since the performance of receiving messages by the API1 is not as high as that of receiving messages by a distributed message queue (Nats-MQ), the distributed message queue (Nats-MQ) may be preferably used.

In addition, if some service systems (such as the platform, the system module, the terminal, etc. in fig. 4) do not refer to the client code of the distributed message queue (Nats-MQ), the target message can be directly sent to the API1, and then the API1 synchronizes the target message to the distributed message queue (Nats-MQ).

The message service system (e.g., the listening module (i.e., NatListeners) in fig. 3 or fig. 4) may listen in real-time for the target message received by the distributed message queue (Nats-MQ), where the target message may include a message sent directly by the business system to the distributed message queue (Nats-MQ), and also include a message sent directly by the business system to the API1 and synchronized by the API1 to the distributed message queue (Nats-MQ).

The message sending method provided by the invention can acquire the target message of the service system through the distributed message queue (Nats-MQ) or the API, thereby improving the flexibility of acquiring the target message. In addition, by providing a uniform API service interface for the service system, repeated development of the same operation interface can be avoided, and resource consumption is reduced.

Based on any one of the above embodiments, in this embodiment, in executing step 102, the method may include:

according to each set parameter included in the set message body structure, carrying out first verification on the target message;

if the first verification is verification passing, determining the message type of the target message, and performing second verification on a set field of the target message according to the message type, wherein the set field corresponds to the message type;

and if the second verification is verification passing, determining that the verification result is verification passing.

Specifically, the setting parameters included in the setting message body structure may include a message title, a message ID, a message content, a message level, a message source, a sender, a receiver, and the like. The message body structures of the target messages of different message types may be the same.

When the message check is performed on the target message, the check of the basic message format (i.e. the first check) may be performed first, for example: checking whether the basic check is null or not, checking the message type and the like; if the basic message passes the verification, then a deep verification (i.e. a second verification) is performed, such as: and (3) checking individual fields (namely one or more set fields) of the mailbox, the short message and the in-station message, and if the individual fields pass deep checking, determining that the checking is successful and executing subsequent message sending.

The setting fields corresponding to different message types may be the same or different.

Such as: and if the message type is a short message, setting fields as the mobile phone numbers of the sender and the receiver, and carrying out deep verification that the mobile phone numbers of the sender and the receiver cannot be empty.

For another example: if the message type is mail, setting fields as sender and receiver mailboxes, and checking deeply whether the sender and receiver mailboxes cannot be empty and are correct or not.

For another example: and if the message type is the station-to-station message, setting a field as a receiver ID, and deeply verifying whether the receiver ID belongs to a system user, wherein if the receiver ID belongs to the system user, the target message can be received in a WebSocket mode, and otherwise, the target message cannot be received.

For another example: if the message type is blue letter, the field is set as the mobile phone number of the receiver, and the deep check indicates that the mobile phone number of the receiver cannot be empty and correct.

The message sending method provided by the invention can carry out two times of verification on the target message, and can carry out message sending only if the target message passes the verification, thereby improving the accuracy and the safety of message sending.

Based on any of the above embodiments, in this embodiment, when performing the first verification on the target message according to each setting parameter included in the setting message body structure, the following verification methods are adopted, but not limited to:

and carrying out first verification on the target message in a Data Transfer Object (DTO) mode.

Specifically, the DTO is a data transmission object, and there are many attributes in the object, and non-null, data type, and default value checks can be performed on the attributes in the DTO in a functional manner.

In addition to the DTO scheme described above, logic verification may also be performed in the program logic. Compared with the DTO mode, the DTO mode is verified in an object-oriented mode, the code integrity is better, and the code is simpler.

In this embodiment, as shown in fig. 5, the process of implementing message transmission between the message service system and the service system may include:

(1) the message service system monitors the target message in real time, and decodes the target message if the target message is monitored; if the target message is not monitored, monitoring is continued.

(2) Carrying out basic message format verification (namely, first verification) and message integrity verification (namely, second verification) on the target message, and if the target message passes the verification, carrying out message storage and message sending processes; if the verification is passed, only the storage is carried out, and the verification failure is marked.

The message sending method provided by the invention can carry out the first verification on the target message in a DTO mode, thereby improving the message verification efficiency.

Based on any of the foregoing embodiments, in this embodiment, the message sending method may further include:

storing the target message to a set area of the message service system;

or the like, or, alternatively,

and sending the target message to a target address corresponding to the target message, and simultaneously storing the target message to a set area of the message service system by adopting a multithreading synchronization mechanism.

Specifically, as shown in fig. 2, 3 or 4, the message service system may start a multi-thread synchronization mechanism, and when sending the target message to the corresponding target address, store the target message in a set area of the message service system, that is, the message drop library shown in fig. 2, 3 or 4. If the target message fails to be verified, the target message may be stored in a set area of the message service system and marked as failed in verification, but the target message is not transmitted.

When the message sending method provided by the invention sends the target message to the corresponding target address, the target message is stored in the set area of the message service system, so that the subsequent service system can conveniently inquire the message sending progress condition, and the message sending practicability is improved.

Based on any of the foregoing embodiments, in this embodiment, the message sending method may further include:

detecting whether the target message is successfully sent;

if the target message is determined to be successfully sent, storing a first sending result for indicating the successful sending to a set area of the message service system;

if the target message is determined to be failed to be sent, the target message is sent to a target address corresponding to the target message again according to the sending mode; if the target message is successfully sent when the number of times of resending is detected to be less than or equal to the set number of times of failed retries, the first sending result is stored in the set area or the first sending result is stored in the set area by adopting a multi-thread asynchronous callback, if the number of times of resending is detected to be equal to the set number of times of failed retries, the target message is not sent again, and the second sending result used for indicating the sending failure is stored in the set area or the first sending result is stored in the set area by adopting the multi-thread asynchronous callback.

Specifically, as shown in fig. 2, fig. 3, or fig. 4, the message service system may start the multi-threaded asynchronous callback, obtain a sending result (i.e., a first sending result or a second sending result) for the target message, and store the sending result in a set area of the message service system, i.e., a message sending result in the update library shown in fig. 2, fig. 3, or fig. 4.

The retransmission may be performed based on the set number of failed retries for the transmission abnormality. The setting of the number of failed retries may be a threshold set in advance, for example: and 3 times, and if the threshold value is exceeded, the transmission is not repeated. The number of setting-failure retries may be adjusted according to actual conditions.

The interval time of each retransmission can be configured according to a specific message type.

In this embodiment, as shown in fig. 6, the process of implementing message transmission by the message service system may include:

(1) and performing message warehouse storage on the verified messages (namely the target messages), and sending the target messages at set time intervals.

(2) When sending a target message, a corresponding sending submodule may be selected according to a message type of the target message to send, for example: the station mail corresponds to a station mail sending submodule, the mail corresponds to a mail sending submodule, the short message corresponds to a short message sending submodule, and the blue message corresponds to a blue message sending submodule, and the like. And each message sending sub-module analyzes configuration information (such as a gateway, a user name, a password, a token (token) and the like) corresponding to the message type, secondarily assembles the target message, and sends the secondarily assembled target message to a target address corresponding to the target message.

(3) After the target message is sent, judging whether the sending is successful, and asynchronously updating a sending result to a library; if not, judging whether the set failure retry times are reached, if so, asynchronously updating the sending result to the library, and if not, resending the target message.

The message sending method provided by the invention can store the sending result of the target message, such as: the transmission is successful or failed, and particularly when the transmission is failed, the retransmission opportunity can be set for times, so that the reliability of message transmission is improved.

Based on any one of the above embodiments, in this embodiment, the message service system includes a second API; the message sending method may further include:

receiving a query request message from the service system through the second application program interface API, wherein the query request message is used for querying a sending result of the target message;

acquiring a sending result of the target message from the set area according to the inquired request message, wherein the sending result of the target message is the first sending result or the second sending result;

and sending the first sending result or the second sending result to the service system through the second application program interface API.

Specifically, the second API may be the API2 shown in fig. 2 or fig. 3 or fig. 4, where the API2 is another API service interface provided by the message service system for a service module (the service module shown in fig. 2 or fig. 3 or fig. 4) of the service system, and may be used for the service system to query the sending result of the target message from the message service system, such as: whether the target message was sent successfully.

The service module shown in fig. 2, fig. 3, or fig. 4 mainly implements all message retrieval queries, including WebSocket push, and also pushes the query to the web end of the service module. The API2 shown in fig. 2 or fig. 3 or fig. 4 serves mainly the service module shown in fig. 2 or fig. 3 or fig. 4, and the platform, system module, terminal, etc. shown in fig. 2 or fig. 3 or fig. 4.

The message sending method provided by the invention can provide a uniform API service interface for the service system, and is used for providing query service for the service system, so that repeated development of the same operation interface can be avoided, and resource consumption is reduced. And, by decoupling the business program and the messaging program, the message transmission reusability is enhanced.

The following describes a message sending device provided by the present invention, and the message sending device described below and the message sending method described above may be referred to correspondingly.

Fig. 7 is a schematic structural diagram of a message sending apparatus provided in the present invention, where the message sending apparatus may be used in a message sending system, and the message sending apparatus may include:

an obtaining module 71, configured to obtain a target message to be sent from a service system, where the target message is a message assembled by the service system according to a set message body structure;

the checking module 72 is configured to perform message checking on the target message to obtain a checking result;

and the sending module 73 is configured to determine a sending method corresponding to the target message according to the message type of the target message if the verification result is that the verification is passed, and send the target message to a target address corresponding to the target message according to the sending method.

The message sending device provided by the invention carries out message verification on the target message assembled by the service system according to the set message body structure, if the verification result is that the verification is passed, the sending mode corresponding to the target message is determined according to the message type of the target message, and the target message is sent to the target address corresponding to the target message according to the sending mode, so that the unified management of message sending is realized, and the reliability and the expandability of message sending are improved; in addition, by providing a uniform set message body structure for each service system, the target messages sent by each service system are favorably unified, so that all the messages are analyzed and normalized, and the problems of disordered codes, poor readability and the like are avoided; and the service program and the message sending program are decoupled, so that the reusability of the message sending service is enhanced, and the platform portability is strong because the independent message sending service is a micro-service architecture.

Based on any one of the above embodiments, in this embodiment, the message service system includes a distributed message queue nat-MQ; the obtaining module 71 is specifically configured to:

and monitoring the target message from the service system in the distributed message queue Nats-MQ.

The message sending device provided by the invention can acquire the target message of the service system through the distributed message queue Nats-MQ, thereby improving the efficiency of acquiring the target message.

Based on any one of the above embodiments, in this embodiment, the message service system includes a distributed message queue nat-MQ and a first application program interface API; the obtaining module 71 is specifically configured to:

and monitoring the target message from the first application program interface API in the distributed message queue Nats-MQ, wherein the first application program interface API is used for receiving the target message from the business system and synchronizing the target message into the distributed message queue Nats-MQ.

The message sending device provided by the invention can acquire the target message of the service system through the distributed message queue Nats-MQ or API, thereby improving the flexibility of acquiring the target message. In addition, by providing a uniform API service interface for the service system, repeated development of the same operation interface can be avoided, and resource consumption is reduced.

Based on any one of the above embodiments, in this embodiment, the verification module 72 includes:

the first checking submodule is used for carrying out first checking on the target message according to each set parameter included in the set message body structure;

the second checking submodule is used for determining the message type of the target message if the first checking is that the checking is passed, and carrying out second checking on the set field of the target message according to the message type, wherein the set field corresponds to the message type;

and the verification determining submodule is used for determining that the verification result is passed verification if the second verification is passed verification.

The message sending device provided by the invention can carry out two times of verification on the target message, and can send the message only if the target message passes the verification, thereby improving the accuracy and the safety of message sending.

Based on any one of the above embodiments, in this embodiment, the first check submodule is specifically configured to:

and carrying out first verification on the target message in a Data Transmission Object (DTO) mode.

The message sending device provided by the invention can carry out the first verification on the target message in a DTO mode, thereby improving the message verification efficiency.

Based on any one of the foregoing embodiments, in this embodiment, the message sending apparatus may further include:

the first storage module is used for storing the target message to a set area of the message service system;

or the like, or, alternatively,

and sending the target message to a target address corresponding to the target message, and simultaneously storing the target message to a set area of the message service system by adopting a multithreading synchronization mechanism.

When the message sending device sends the target message to the corresponding target address, the target message is stored in the set area of the message service system, so that the subsequent service system can conveniently inquire the message sending progress condition, and the message sending practicability is improved.

Based on any one of the foregoing embodiments, in this embodiment, the message sending apparatus may further include:

the detection module is used for detecting whether the target message is successfully sent;

the second storage module is used for storing a first sending result for indicating the successful sending to a set area of the message service system or storing the first sending result to the set area by adopting a multithread asynchronous callback if the target message is determined to be successfully sent;

the third storage module is used for resending the target message to a target address corresponding to the target message according to the sending mode if the target message is determined to be failed to be sent; if the target message is successfully sent when the number of times of resending is detected to be less than or equal to the set number of times of failed retries, the first sending result is stored in the set area or the first sending result is stored in the set area by adopting a multi-thread asynchronous callback, if the number of times of resending is detected to be equal to the set number of times of failed retries, the target message is failed to be sent, the resending of the target message is stopped, and a second sending result used for indicating the failure of the sending is stored in the set area or the second sending result is stored in the set area by adopting the multi-thread asynchronous callback.

The message sending device provided by the invention can store the sending result of the target message, such as: the transmission is successful or failed, and particularly when the transmission is failed, the retransmission opportunity can be set for times, so that the reliability of message transmission is improved.

Based on any one of the above embodiments, in this embodiment, the message service system includes a second application program interface API; the message transmitting apparatus may further include:

a receiving module, configured to receive, through the second application program interface API, a query request message from the service system, where the query request message is used to query a sending result of the target message;

the query module is used for acquiring a sending result of the target message from the set area according to the query request message, wherein the sending result of the target message is the first sending result or the second sending result;

and the response module is used for sending the first sending result or the second sending result to the service system through the second application program interface API.

The message sending device provided by the invention can provide a uniform API service interface for the service system, and is used for providing query service for the service system, so that repeated development of the same operation interface can be avoided, and resource consumption is reduced. And, by decoupling the business program and the messaging program, the message transmission reusability is enhanced.

Fig. 8 is a schematic structural diagram of an electronic device provided in the present invention, and as shown in fig. 8, the electronic device may be used in a message sending system, and includes: a processor (processor)810, a communication Interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication Interface 820 and the memory 830 communicate with each other via the communication bus 840. Processor 810 may invoke logic instructions in memory 830 to perform a messaging method comprising:

acquiring a target message to be sent from a service system, wherein the target message is a message assembled by the service system according to a set message body structure;

carrying out message verification on the target message to obtain a verification result;

and if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode.

In addition, the logic instructions in the memory 830 may be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

On the other hand, the invention also provides a message management system, which comprises the message sending system and the service system shown in any of the above embodiments;

the service system is used for assembling a target message to be sent according to a set message body structure and sending the target message to the message sending system.

In another aspect, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, which when executed by a computer, enable the computer to perform the message sending method provided by the above methods, the method comprising:

acquiring a target message to be sent from a service system, wherein the target message is a message assembled by the service system according to a set message body structure;

carrying out message verification on the target message to obtain a verification result;

and if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode.

In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program, which when executed by a processor is implemented to perform the message sending method provided above, the method including:

acquiring a target message to be sent from a service system, wherein the target message is a message assembled by the service system according to a set message body structure;

carrying out message verification on the target message to obtain a verification result;

and if the verification result is that the verification is passed, determining a sending mode corresponding to the target message according to the message type of the target message, and sending the target message to a target address corresponding to the target message according to the sending mode.

The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.

Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.

Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

21页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:信息显示方法、装置及电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!