Message sending method and related device

文档序号:1300176 发布日期:2020-08-07 浏览:22次 中文

阅读说明:本技术 一种消息发送方法和相关装置 (Message sending method and related device ) 是由 泮诚 于 2020-06-30 设计创作,主要内容包括:本申请实施例公开了一种消息发送方法和相关装置,该方法包括:根据待发送消息的产生时间和有效时长剩余时间,确定快消息队列中待发送消息的位置排序;从快消息队列中向发送队列提取待发送消息;所述快消息队列中待发送消息对应的有效时长小于慢消息队列中待发送消息的有效时长;若所述快消息队列为空,从所述慢消息队列中向所述发送队列提取待发送消息;向接收设备发送所述发送队列中的待发送消息。处理设备可以根据消息的有效时长、产生时间和有效时长剩余时间进行分类和排序,优先将快消息队列中产生时间较早、有效时长剩余时间较小的消息进行发送,一定程度上避免了因网络波动时优先发送有效时长较大的消息导致有效时长较小的消息失效的问题。(The embodiment of the application discloses a message sending method and a related device, wherein the method comprises the following steps: determining the position sequence of the messages to be sent in the fast message queue according to the generation time and the effective duration residual time of the messages to be sent; extracting a message to be sent from the fast message queue to a sending queue; the effective duration corresponding to the message to be sent in the fast message queue is less than the effective duration of the message to be sent in the slow message queue; if the fast message queue is empty, extracting a message to be sent from the slow message queue to the sending queue; and sending the message to be sent in the sending queue to receiving equipment. The processing equipment can classify and sort according to the effective duration, the generation time and the remaining time of the effective duration of the message, and preferentially sends the message with earlier generation time and shorter remaining time of the effective duration in the fast message queue, thereby avoiding the problem of message failure with shorter effective duration caused by preferentially sending the message with longer effective duration when the network fluctuates to a certain extent.)

1. A method for sending a message, the method comprising:

determining the position sequence of the messages to be sent in the fast message queue according to the generation time and the effective duration residual time of the messages to be sent;

extracting a message to be sent from the fast message queue to a sending queue; the effective duration corresponding to the message to be sent in the fast message queue is less than the effective duration of the message to be sent in the slow message queue;

if the fast message queue is empty, extracting a message to be sent from the slow message queue to the sending queue;

and sending the message to be sent in the sending queue to receiving equipment.

2. The method of claim 1, further comprising:

if the target message is failed to be sent to the receiving equipment through the sending queue, adding the target message into a failure queue; the target message is a message to be sent in the sending queue;

and when the message to be sent is extracted from the slow message queue to the sending queue, if the slow message queue is empty, extracting the message to be sent from the failure queue to the sending queue.

3. The method of claim 2, wherein the failure queues include a first failure queue and a second failure queue, the position ordering of the messages to be sent in the first failure queue is determined according to the time for joining the first failure queue, and the position ordering of the messages to be sent in the second failure queue is determined according to the number of times of failure to send the messages to be sent;

if the target message is extracted from the first failure queue to the sending queue, adding the target message to the failure queue includes:

and adding the target message into the second failure queue.

4. The method of claim 2, further comprising:

if the queue capacity of the fast message queue reaches a first threshold value, extracting a first number of messages to be sent from the tail of the fast message queue and storing the messages into a storage space;

if the queue capacity of the slow message queue reaches a second threshold value, extracting a second number of messages to be sent from the tail of the slow message queue and storing the messages into the storage space;

and if the transmission failure times of the messages to be transmitted in the failure queue reach a third threshold value, the messages to be transmitted, the transmission failure times of which reach the third threshold value, are extracted from the failure queue and stored in the storage space.

5. The method of claim 4, wherein when the message to be sent is extracted from the failure queue to the send queue, if the failure queue is empty, the method further comprises:

extracting a message to be sent from the persistent queue to the sending queue; the messages to be sent in the persistent queue are obtained from the storage space, and the position ordering of the messages to be sent in the persistent queue is determined according to any one or combination of more than one of the following items:

the generation time of the message to be sent;

whether from a fast message queue or a slow message queue;

the number of transmission failures.

6. The method of claim 1, further comprising:

and if the message to be sent extracted from the slow message queue is successfully sent to the receiving equipment through the sending queue, extracting the message to be sent from the fast message queue to the sending queue.

7. The method according to any one of claims 1-6, further comprising:

counting a first sending failure rate of the messages to be sent from the fast message queue and a second sending failure rate of the messages to be sent from the slow message queue;

determining an overall failure rate according to the first sending failure rate and the second sending failure rate;

and adjusting the process quantity of the messages to be sent from the sending queue according to the overall failure rate.

8. The method according to any one of claims 1 to 6, wherein the message to be sent has a message header, and the message header is used to record the generation time, the aging type and the number of failed sending times of the message to be sent, the aging type includes a fast message or a slow message, the effective duration of the fast message corresponds to the effective duration corresponding to the message to be sent in the fast message queue, and the effective duration of the slow message corresponds to the effective duration corresponding to the message to be sent in the slow message queue.

9. The method according to any one of claims 1-6, further comprising:

acquiring messages to be classified to be sent;

according to the effective duration corresponding to the message type of the message to be sent, carrying out aging type classification on the message to be sent;

adding the message to be sent of which the aging type belongs to the fast message into the fast message queue, and adding the message to be sent of which the aging type belongs to the slow message into the slow message queue.

10. A message transmission apparatus, characterized in that the apparatus comprises a first determination unit, a first extraction unit, a second extraction unit, and a transmission unit:

the first determining unit is used for determining the position sequence of the messages to be sent in the fast message queue according to the generation time of the messages to be sent and the remaining time of the effective duration;

the first extraction unit is used for extracting the message to be sent from the fast message queue to the sending queue; the effective duration corresponding to the message to be sent in the fast message queue is less than the effective duration of the message to be sent in the slow message queue;

the second extracting unit is configured to extract a message to be sent from the slow message queue to the sending queue if the fast message queue is empty;

and the sending unit is used for sending the message to be sent in the sending queue to the receiving equipment.

11. The apparatus of claim 10, further comprising a first adding unit and a third extracting unit:

the first joining unit is used for joining the target message into a failure queue if the target message is failed to be sent to the receiving equipment through the sending queue; the target message is a message to be sent in the sending queue;

the third extracting unit is configured to, when the message to be sent is extracted from the slow message queue to the sending queue, extract the message to be sent from the failure queue to the sending queue if the slow message queue is empty.

12. The apparatus according to claim 11, wherein the failure queues include a first failure queue and a second failure queue, the position ordering of the messages to be sent in the first failure queue is determined according to the time for joining the first failure queue, and the position ordering of the messages to be sent in the second failure queue is determined according to the number of times of failure to send the messages to be sent;

if the target message is extracted from the first failure queue to the sending queue, the first joining unit is specifically configured to:

and adding the target message into the second failure queue.

13. The apparatus of claim 11, further comprising a fourth extraction unit, a fifth extraction unit, and a sixth extraction unit:

the fourth extraction unit is configured to, if the queue capacity of the fast message queue reaches a first threshold, extract a first number of messages to be sent from the tail of the fast message queue and store the messages in a storage space;

the fifth extracting unit is configured to extract a second number of messages to be sent from the tail of the slow message queue and store the second number of messages in the storage space if the queue capacity of the slow message queue reaches a second threshold;

and the sixth extraction unit is configured to, if the transmission failure times of the messages to be sent in the failure queue reach a third threshold, extract the messages to be sent whose transmission failure times reach the third threshold from the failure queue, and store the extracted messages in the storage space.

14. An apparatus for messaging, the apparatus comprising a processor and a memory:

the memory is used for storing program codes and transmitting the program codes to the processor;

the processor is configured to execute the message sending method according to any one of claims 1 to 9 according to instructions in the program code.

15. A computer-readable storage medium for storing a computer program for executing the message sending method according to any one of claims 1 to 9.

25页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:网络交换设备、操作网络交换机的方法和计算机可读介质

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!