CN111585808A - A message processing method, apparatus, device, and computer-readable storage medium - Google Patents
A message processing method, apparatus, device, and computer-readable storage medium Download PDFInfo
- Publication number
- CN111585808A CN111585808A CN202010363080.2A CN202010363080A CN111585808A CN 111585808 A CN111585808 A CN 111585808A CN 202010363080 A CN202010363080 A CN 202010363080A CN 111585808 A CN111585808 A CN 111585808A
- Authority
- CN
- China
- Prior art keywords
- message
- sending
- receiving end
- receiving
- sent
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 19
- 238000012545 processing Methods 0.000 claims abstract description 18
- 238000000034 method Methods 0.000 claims description 35
- 238000004590 computer program Methods 0.000 claims description 6
- 230000005540 biological transmission Effects 0.000 abstract description 7
- 230000006854 communication Effects 0.000 description 14
- 238000004891 communication Methods 0.000 description 13
- 238000010586 diagram Methods 0.000 description 4
- 230000007958 sleep Effects 0.000 description 4
- 230000000903 blocking effect Effects 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 208000013407 communication difficulty Diseases 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
- H04L41/0803—Configuration setting
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/2866—Architectures; Arrangements
- H04L67/30—Profiles
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/568—Storing data temporarily at an intermediate stage, e.g. caching
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
Description
技术领域technical field
本申请涉及计算机网络通信领域,尤其涉及一种消息处理方法、装置、设备及计算机可读存储介质。The present application relates to the field of computer network communications, and in particular, to a message processing method, apparatus, device, and computer-readable storage medium.
背景技术Background technique
随着计算机行业的不断发展,各式各样的设备提供了花样繁多的功能。众多设备之间交互通信,使得众多设备构成通信系统。但因为设备所处的网络有可能不同,使用的通信协议也可能不同,所以,多种设备构成的通信系统的通信的难度和复杂度较高。因此,如果目标设备分布于多地处于多个网络下,只针对一个网络环境设计的技术可能导致寻址效率降低和网络传输速度降低。With the continuous development of the computer industry, a wide variety of devices provide a wide variety of functions. The interactive communication between many devices makes many devices form a communication system. However, because the networks where the devices are located may be different, and the communication protocols used may also be different, the communication difficulty and complexity of the communication system composed of multiple devices are relatively high. Therefore, if the target devices are distributed in many places and under multiple networks, a technology designed for only one network environment may lead to lower addressing efficiency and lower network transmission speed.
因此,在多个网络内均可访问,不需要多重的链路传递即可与各个设备互通消息的技术,例如基于B/S架构的消息传输技术,能够保证寻址效率和网络传输数据速度。Therefore, it is accessible in multiple networks and can communicate messages with various devices without multiple link transmissions, such as message transmission technology based on B/S architecture, which can ensure addressing efficiency and network transmission data speed.
而目前的这类技术,各设备和程序需要不断向服务器发送同步请求以保证消息的时效性,频繁的请求导致使用时设备和服务器的资源占用均变高。However, in the current technology, each device and program needs to continuously send synchronization requests to the server to ensure the timeliness of the message, and the frequent requests lead to high resource occupancy of the device and the server during use.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本申请提供了一种消息处理方法、装置、设备及计算机可读存储介质,如下:In view of this, the present application provides a message processing method, apparatus, device, and computer-readable storage medium, as follows:
一种消息处理方法,应用于消息服务器,所述消息服务器连接多个发送端和多个接收端,所述方法包括:A message processing method, applied to a message server, wherein the message server is connected to multiple senders and multiple receivers, the method comprising:
所述消息服务器接收并存储所述发送端发送的消息,其中所述发送端和多个接收端的网络协议被预先配置在所述消息服务器中;The message server receives and stores the message sent by the sender, wherein the network protocols of the sender and a plurality of receivers are pre-configured in the message server;
所述消息服务器在获取所述接收端发送的消息请求后,如果不存在所述接收端的待接收消息,则阻塞所述消息请求,并在接收到所述接收端的待接收消息后,将所述待接收消息发送至所述接收端。After the message server obtains the message request sent by the receiving end, if there is no message to be received by the receiving end, the message server blocks the message request, and after receiving the message to be received from the receiving end, sends the message to the receiving end. The message to be received is sent to the receiving end.
可选地,本方法还包括:Optionally, the method further includes:
所述消息服务器获取配置文件,所述配置文件中包括所述接收端和所述发送端的标识和所述消息的解析方式;The message server obtains a configuration file, and the configuration file includes the identifiers of the receiving end and the sending end and a parsing method of the message;
所述消息服务器依据所述配置文件注册所述接收端和所述发送端,并为注册的所述接收端和所述发送端创建存储空间;The message server registers the receiving end and the sending end according to the configuration file, and creates a storage space for the registered receiving end and the sending end;
所述消息服务器在新增终端的情况下,注册新增的终端并为所述新增的终端创建存储空间,在删减终端的情况下,注销删减的终端并释放所述删减的终端的存储空间,所述终端包括所述接收端和/或所述发送端。In the case of adding a terminal, the message server registers the newly added terminal and creates a storage space for the newly added terminal, and in the case of deleting a terminal, cancels the deleted terminal and releases the deleted terminal storage space, the terminal includes the receiving end and/or the sending end.
可选地,接收端和所述发送端存在于多种类型的网络环境,和/或,所述接收端和所述发送端使用不同类型的多种网络协议。Optionally, the receiving end and the sending end exist in multiple types of network environments, and/or the receiving end and the sending end use multiple network protocols of different types.
可选地,接收并存储所述发送端发送的消息,包括:Optionally, receiving and storing a message sent by the sender, including:
接收所述发送端发送的消息,并如果所述发送端已注册,则将所述消息按照发送时间的先后顺序,存储至所述消息的发送端在所述存储空间中的链表内;Receive the message sent by the sending end, and if the sending end is registered, store the message in the linked list of the sending end of the message in the storage space according to the order of sending time;
如果所述发送端未注册,则注册所述发送端,并将所述消息按照发送时间的先后顺序,存储至所述消息的发送端在所述存储空间中的链表内。If the sender is not registered, the sender is registered, and the message is stored in the linked list of the sender of the message in the storage space according to the order of sending time.
可选地,在所述将所述消息按照发送时间的先后顺序,存储至所述消息的发送端在所述存储空间中的链表内之后,还包括:Optionally, after the message is stored in the linked list of the sender of the message in the storage space in the order of sending time, the method further includes:
将所述链表内的消息按照接收端分组;grouping the messages in the linked list according to the receiving end;
如果所述链表内的消息的存在目标接收端,则向所述目标接收端发送所述目标接收端的分组内的消息,所述目标接收端为存在被阻塞的所述消息请求的所述接收端。If there is a target receiver of the message in the linked list, send the message in the packet of the target receiver to the target receiver, and the target receiver is the receiver with the blocked message request .
可选地,在接收到所述接收端的待接收消息后,将所述待接收消息发送至所述接收端,包括:Optionally, after receiving the to-be-received message of the receiving end, sending the to-be-received message to the receiving end, including:
将所述链表内的消息按照接收端分组;grouping the messages in the linked list according to the receiving end;
如果所述链表内的消息的接收端为被阻塞的接收端,则向所述被阻塞的接收端发送所述的消息。If the receiver of the message in the linked list is a blocked receiver, the message is sent to the blocked receiver.
可选地,本方法还包括:Optionally, the method further includes:
如果在预设时间周期内均不存在所述被阻塞的接收端的待接收消息,则向所述被阻塞的接收端发送无消息反馈。If there is no message to be received by the blocked receiver within a preset time period, no message feedback is sent to the blocked receiver.
一种消息处理服务器,所述消息服务器连接多个发送端和多个接收端,所述发送端和多个接收端的网络协议被预先配置在所述消息服务器中;A message processing server, the message server is connected to a plurality of sending ends and a plurality of receiving ends, and the network protocols of the sending ends and the plurality of receiving ends are pre-configured in the message server;
所述装置包括:消息模块和缓存模块;The device includes: a message module and a cache module;
所述消息模块用于接收所述发送端发送的消息;The message module is configured to receive a message sent by the sender;
所述缓存模块用于存储所述发送端发送的消息;The cache module is used to store the message sent by the sending end;
所述消息模块还用于,在获取所述接收端发送的消息请求后,如果不存在所述接收端的待接收消息,则阻塞所述消息请求,并在接收到所述接收端的待接收消息后,将所述待接收消息发送至所述接收端。The message module is further configured to, after acquiring the message request sent by the receiving end, if there is no message to be received by the receiving end, block the message request, and after receiving the message to be received from the receiving end , and send the to-be-received message to the receiving end.
一种消息处理设备,连接多个发送端和多个接收端,所述发送端和多个接收端的网络协议被预先配置在所述消息处理设备中;A message processing device, connecting a plurality of sending ends and a plurality of receiving ends, and the network protocols of the sending ends and the plurality of receiving ends are pre-configured in the message processing device;
所述消息处理设备包括存储器和处理器,所述存储器用于存储程序,所述处理器用于运行所述程序,以实现如上所述的消息处理方法的各个步骤。The message processing device includes a memory and a processor, where the memory is used for storing a program, and the processor is used for running the program, so as to implement each step of the message processing method as described above.
一种计算机可读存储介质,其上存储有计算机程序,其特征在于,在所述计算机程序在计算机设备上运行时,实现如上所述的消息处理方法的各个步骤。A computer-readable storage medium on which a computer program is stored, characterized in that, when the computer program runs on a computer device, each step of the above-mentioned message processing method is implemented.
本申请所述的技术方案,连接多个发送端和多个接收端的消息服务器,接收并存储发送端发送的消息,在获取接收端发送的消息请求后,如果不存在接收端的待接收消息,则阻塞消息请求,并在接收到接收端的待接收消息后,将待接收消息发送至接收端,因为消息阻塞消息请求后,接收端会等待消息请求的反馈,因此,极大降低了请求频率,能够减少消息同步对于资源的占用。又因为发送端和多个接收端的网络协议被预先配置在消息服务器中,所以可以通过配置项支持多网络环境下的设备,可以保证低寻址成本和最高的传输速度。The technical solution described in this application is to connect a message server with multiple senders and multiple receivers, receive and store messages sent by the sender, and after obtaining the message request sent by the receiver, if there is no message to be received by the receiver, then Block the message request, and after receiving the to-be-received message from the receiver, send the to-be-received message to the receiver, because after the message blocks the message request, the receiver will wait for the feedback of the message request. Reduce the resource consumption of message synchronization. And because the network protocols of the sender and multiple receivers are pre-configured in the message server, devices in multiple network environments can be supported through configuration items, which can ensure low addressing costs and the highest transmission speed.
附图说明Description of drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that are used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1a为本申请实施例公开的一种消息服务器的结构示意图;FIG. 1a is a schematic structural diagram of a message server disclosed in an embodiment of the application;
图1b示例了一种基于B/S架构的阻塞型消息处理方法实例示意图;Figure 1b illustrates a schematic diagram of an example of a blocking message processing method based on B/S architecture;
图2为本申请实施例公开的一种消息处理方法的流程示意图;2 is a schematic flowchart of a message processing method disclosed in an embodiment of the present application;
图3为本申请实施例公开的创建存储空间的流程示意图;3 is a schematic flowchart of creating a storage space disclosed in an embodiment of the present application;
图4为本申请实施例公开的存储发送端发送的消息的流程示意图;4 is a schematic flowchart of storing a message sent by a sending end disclosed in an embodiment of the present application;
图5为本申请实施例公开的查询待发送的消息的流程示意图;FIG. 5 is a schematic flowchart of querying a message to be sent disclosed by an embodiment of the present application;
图6为本申请实施例公开的发送查询到待发送的消息的流程示意图;FIG. 6 is a schematic flowchart of sending a query to a message to be sent disclosed by an embodiment of the present application;
图7为本申请实施例公开的一种消息处理设备的结构示意图。FIG. 7 is a schematic structural diagram of a message processing device disclosed in an embodiment of the present application.
具体实施方式Detailed ways
图1a~图1b为本申请实施例公开的消息处理方法的应用场景示例,该场景中包括多个接收端和多个发送端。所有终端(包括接收端和发送端)可能处于不同类型的网络,也可能使用不同类型的协议进行通信。1a to 1b are examples of application scenarios of the message processing method disclosed in the embodiments of the present application, and the scenario includes multiple receiving ends and multiple sending ends. All terminals (including the receiving end and the sending end) may be in different types of networks, and may also use different types of protocols to communicate.
本申请公开的消息处理方法,由图1a中所示的消息服务器执行。其中,消息服务器分别与发送端以及接收端相连,进一步的,可以通过网络层分别与发送端以及接收端相连,网络层可以包括HTTP层、HTTPS层、TCP层和UDP层。具体的,如图1a所示,消息服务器可以包括缓存模块、消息模块和注册管理模块。The message processing method disclosed in this application is executed by the message server shown in FIG. 1a. Wherein, the message server is respectively connected with the sender and the receiver, and further, it can be connected with the sender and the receiver respectively through the network layer, and the network layer can include HTTP layer, HTTPS layer, TCP layer and UDP layer. Specifically, as shown in FIG. 1a, the message server may include a cache module, a message module and a registration management module.
本申请的实施例中,从硬件角度,以终端为平板、服务器和电脑为例进行说明,但并不限定于上述举例。In the embodiments of the present application, from the perspective of hardware, the terminal is a tablet, a server, and a computer as examples for description, but it is not limited to the above examples.
从软件角度,如图1b所示,发送端可以包括浏览器A、UDP控制器和TCP控制器,接收端可以包括浏览器B、UDP控制器和TCP控制器。从图1b可以看出,发送端和接收端均在消息服务器注册,并由消息服务器实现消息通信。具体的,浏览器A,B为HTTP/HTTPS接收端和发送端,并且是在消息服务器启动后动态注册入消息服务器。UDP控制器可以运行在平板电脑上,使用UDP/IP协议。TCP控制器可以运行在服务器上,使用TCP/IP协议。From a software perspective, as shown in Figure 1b, the sender may include browser A, a UDP controller, and a TCP controller, and the receiver may include browser B, a UDP controller, and a TCP controller. As can be seen from Figure 1b, both the sender and the receiver are registered with the message server, and the message server implements message communication. Specifically, browsers A and B are HTTP/HTTPS receivers and senders, and are dynamically registered with the message server after the message server is started. The UDP controller can run on the tablet and use the UDP/IP protocol. The TCP controller can run on the server, using the TCP/IP protocol.
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行进一步地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be further described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
图2为本申请实施例公开的一种消息处理方法,包括以下步骤:FIG. 2 is a message processing method disclosed by an embodiment of the present application, comprising the following steps:
S201:消息服务器获取配置文件。S201: The message server obtains a configuration file.
具体的,配置文件可以由技术人员,预先按照终端使用的协议和所处的网络进行设置,并发送至消息服务器。也可以预先将配置文件保存在消息服务器内。消息服务运行时将配置文件解析后存储至内存中。Specifically, the configuration file may be set by a technician in advance according to the protocol used by the terminal and the network where the terminal is located, and sent to the message server. The configuration file can also be saved in the message server in advance. When the message service runs, the configuration file is parsed and stored in memory.
表1示例了配置文件中可以包括的配置项(其中后缀*为动态注册和消息收发所需项,^为本次实例特定项,其余则是预配置项,无法动态修改):Table 1 illustrates the configuration items that can be included in the configuration file (where the suffix * is the items required for dynamic registration and messaging, ^ is the specific item for this instance, and the rest are pre-configured items that cannot be dynamically modified):
表1Table 1
可以理解的是,配置项的各个配置值,可由技术人员依据接收端和发送端、以及网络协议进行配置,并且,在接收端和发送端、以及网络协议更改的情况下,技术人员可以多配置项的配置值进行修改。具体配置方式可以参见现有技术,这里不再赘述。It can be understood that each configuration value of the configuration item can be configured by the technician according to the receiving end, the sending end, and the network protocol, and in the case of changing the receiving end, the sending end, and the network protocol, the technician can configure more The configuration value of the item is modified. For a specific configuration manner, reference may be made to the prior art, which will not be repeated here.
因为配置项中包括接收端和发送端的标识,所以,通过配置信息可以实现发送端和/或接收端的删减或新增。Because the configuration item includes the identifiers of the receiving end and the transmitting end, the deletion or addition of the transmitting end and/or the receiving end can be realized through the configuration information.
S202:消息服务器依据配置文件,进行初始化配置。S202: The message server performs initial configuration according to the configuration file.
具体的,初始化配置的步骤包括以下:Specifically, the steps of initializing the configuration include the following:
1、按照配置项中的CONFIGJSON的位置将消息配置文件放入。消息配置文件的具体内容为设置的指令和对应的设备命令,例如表2:1. Put the message configuration file according to the location of CONFIGJSON in the configuration item. The specific content of the message configuration file is the set instructions and the corresponding device commands, such as Table 2:
表2Table 2
可以理解的是,消息配置文件也可以由技术人员预先设置。It can be understood that the message configuration file can also be preset by a technician.
2、开启承载消息服务的消息服务器的软硬件,初始化注册信息管理模块。2. Start the software and hardware of the message server that carries the message service, and initialize the registration information management module.
3、注册信息管理模块按照配置项的配置值,注册发送端和接收端,记录全局编码格式和其他配置。3. The registration information management module registers the sender and receiver according to the configuration value of the configuration item, and records the global encoding format and other configurations.
可以理解的是,消息服务器可以依据新增或删减终端后新获取的配置文件,在新增终端的情况下,注册新增的终端并为新增的终端创建存储空间,在删减终端的情况下,注销删减的终端并释放所述删减的终端的存储空间,其中,终端包括接收端和/或发送端。It can be understood that the message server can register the newly added terminal and create a storage space for the newly added terminal according to the newly acquired configuration file after the terminal is added or deleted, and then delete the terminal. In this case, the deleted terminal is deregistered and the storage space of the deleted terminal is released, wherein the terminal includes a receiving end and/or a transmitting end.
4、按照配置项的配置值,消息服务器开始尝试占用UDP监听端口和TCP端口,如果失败则UDP和TCP消息接收和发送功能启动失败。4. According to the configuration value of the configuration item, the message server starts to try to occupy the UDP listening port and the TCP port. If it fails, the UDP and TCP message receiving and sending functions fail to start.
5、注册信息管理模块通知初始化完毕,消息服务器创建缓存模块的进程。5. The registration information management module notifies that the initialization is completed, and the message server creates the process of the cache module.
6、缓存模块创建发送端对应的存储空间。具体流程如图3所示。6. The cache module creates the storage space corresponding to the sender. The specific process is shown in Figure 3.
7、注册信息管理模块接口开放,等待接收动态注册。7. The interface of the registration information management module is open, waiting to receive dynamic registration.
8、缓存模块休眠,消息模块等待请求。8. The cache module sleeps, and the message module waits for a request.
可以理解的是,S201和S202为预先配置的过程,在终端和网络没有更改的情况下,可以仅配置一次,而无需重复执行。并且,S201~S202仅为可选的一种预先配置的具体实现方式,需要说明的是,预先配置的具体实现方式包括多种,本实施例对此不做赘述。It can be understood that S201 and S202 are pre-configured processes, and if the terminal and the network are not changed, they can be configured only once and do not need to be repeatedly performed. In addition, S201 to S202 are only an optional specific implementation manner of pre-configuration, and it should be noted that the specific implementation manner of pre-configuration includes multiple types, which will not be repeated in this embodiment.
基于以上配置,消息服务器实现发送端和接收端中间的消息通信流程,具体的,可以分为发送端发送消息的场景和接收端发送消息请求的场景,详见以下步骤:Based on the above configuration, the message server implements the message communication process between the sender and the receiver. Specifically, it can be divided into a scenario where the sender sends a message and a scenario where the receiver sends a message request. For details, see the following steps:
发送端发送消息的场景:Scenarios where the sender sends a message:
S203:发送端发送消息。S203: The sender sends a message.
S204:消息服务器通过网络层,接收到消息,并按照配置文件配置的全局编码格式,解析消息,得到消息的发送端标识。S204: The message server receives the message through the network layer, parses the message according to the global encoding format configured in the configuration file, and obtains the sender identifier of the message.
S205:注册信息管理模块判断发送端标识是否存在于注册信息中,如果是,执行S206-S208,如果否,执行S209-S210。S205: The registration information management module judges whether the identifier of the sender exists in the registration information, and if so, executes S206-S208, and if not, executes S209-S210.
S206:消息服务器存储发送端发送的消息,具体流程可参见图4所示。S206: The message server stores the message sent by the sending end, and the specific process can be referred to as shown in FIG. 4 .
S207:消息服务器查询待发送的消息,具体流程可参见图5所示。S207: The message server queries the message to be sent, and the specific process can be referred to as shown in FIG. 5 .
S208:消息服务器发送查询到的待发送的消息,具体流程可参见图6所示。S208: The message server sends the queried message to be sent, and the specific process can be referred to as shown in FIG. 6 .
S209:注册信息管理模块注册发送端。S209: The registration information management module registers the sender.
S210:消息服务器为新注册的发送端创建存储空间,具体可以参见图3所示。S210: The message server creates a storage space for the newly registered sender, as shown in FIG. 3 for details.
S210后,执行S206-S208。After S210, execute S206-S208.
上述S202~S210为本申请实施例提供的接收并存储发送端发送的消息的一种可选的实现方式,可以将S202~S210概括为,接收发送端发送的消息,并如果发送端已注册,则存储消息。如果发送端未注册,则注册发送端后存储消息。The foregoing S202 to S210 are an optional implementation manner of receiving and storing a message sent by the sending end provided by the embodiment of the application. S202 to S210 can be summarized as: receiving a message sent by the sending end, and if the sending end is registered, message is stored. If the sender is not registered, the message is stored after the sender is registered.
需要说明的是,本申请实施例中的接收并存储发送端发送的消息还可以包括其他的实现方式,本申请对此不做限定。It should be noted that, receiving and storing the message sent by the sending end in the embodiments of the present application may also include other implementation manners, which are not limited in the present application.
接收端发送消息请求的场景:Scenarios where the receiver sends a message request:
S211:接收端发送消息请求。S211: The receiving end sends a message request.
S212:消息服务器通过网络层,接收到消息请求,并按照配置文件配置的全局编码格式,解析消息请求,得到发送消息请求的接收端的标识(简称接收到标识)。S212: The message server receives the message request through the network layer, parses the message request according to the global encoding format configured in the configuration file, and obtains the identifier of the receiver sending the message request (referred to as the received identifier).
S213:注册信息管理模块判断接收端标识是否存在于注册信息中,如果是,执行S214-S218,如果否,执行S219-S220。S213: The registration information management module judges whether the receiver identifier exists in the registration information, and if so, executes S214-S218, and if not, executes S219-S220.
S214:消息服务器查询待发送的消息,具体流程可参见图5所示。S214: The message server queries the message to be sent, and the specific process can be referred to as shown in FIG. 5 .
S215:消息服务器发送查询到待发送的消息,具体流程可参见图6所示。S215: The message server sends the query to the message to be sent, and the specific process can be referred to as shown in FIG. 6 .
S216:消息服务器如果没有查询到消息,则阻塞消息请求。S216: If the message server does not find a message, it blocks the message request.
阻塞是软件工程领域的一种常用技术手段,这里是指把消息请求挂起,不让其完成。Blocking is a common technical method in the field of software engineering. Here, it refers to suspending a message request and not allowing it to complete.
在消息请求被阻塞的情况下,接收端不会收到消息请求的反馈,因此,不会再次发送消息请求,而是等到反馈。In the case that the message request is blocked, the receiving end will not receive the feedback of the message request, therefore, the message request will not be sent again, but will wait for the feedback.
S217:消息服务器判断阻塞时长是否大于预设的时长阈值,如果是,执行S218,如果否,执行S217。S217: The message server determines whether the blocking duration is greater than the preset duration threshold, and if so, executes S218, and if not, executes S217.
S218:取消阻塞,并向发送端回复无消息。S218: Unblock and reply no message to the sender.
S219:注册信息管理模块注册接收端。S219: The registration information management module registers the receiver.
S220:消息服务器为新注册的接收端创建存储空间,具体可以参见图3所示。S220: The message server creates a storage space for the newly registered receiver, as shown in FIG. 3 for details.
S220后,执行S214-S218。After S220, execute S214-S218.
需要说明的是,接收端在接收到消息后,可以解析消息并根据消息来源和内容执行相应处理。It should be noted that after receiving the message, the receiving end can parse the message and perform corresponding processing according to the source and content of the message.
可以将上述S212~S216概括为:The above S212 to S216 can be summarized as:
消息服务器在获取接收端发送的消息请求后,如果不存在接收端的待接收消息,则阻塞消息请求,并在接收到接收端的待接收消息后,将待接收消息发送至接收端。After obtaining the message request sent by the receiver, the message server blocks the message request if there is no message to be received by the receiver, and sends the message to be received to the receiver after receiving the message to be received from the receiver.
需要说明的是,S212~S216仅为可选的一种实施方式,本实施例还可以包括其他的具体实现方式,对此本实施例不做赘述。It should be noted that S212 to S216 are only an optional implementation manner, and this embodiment may further include other specific implementation manners, which are not described repeatedly in this embodiment.
可以将上述S217~S220概括为:The above S217-S220 can be summarized as:
如果在预设时间周期内均不存在被阻塞的接收端的待接收消息,则向被阻塞的接收端发送无消息反馈。需要说明的是,本实施例中的S217~S220仅为可选步骤,用于及时向接收端反馈无消息。If there is no message to be received by the blocked receiver within the preset time period, no message feedback is sent to the blocked receiver. It should be noted that, S217 to S220 in this embodiment are only optional steps, and are used to feed back no message to the receiving end in time.
图2所示的流程具有以下有益效果:The flow shown in Figure 2 has the following beneficial effects:
1、消息服务器接收并存储发送端发送的消息,并在接收端请求消息时,如果没有接收端的消息,则阻塞消息请求,因为阻塞消息请求后,接收端会等待消息请求的反馈,所以,不会再次发送消息请求,因此,极大降低了请求频率,能够减少消息同步对于资源的占用。1. The message server receives and stores the message sent by the sender, and when the receiver requests a message, if there is no message from the receiver, the message request is blocked, because after the message request is blocked, the receiver will wait for the feedback of the message request, so no The message request will be sent again. Therefore, the request frequency is greatly reduced, and the resource occupation of message synchronization can be reduced.
2、发送端和多个接收端的网络协议被预先配置在消息服务器中,所以可以通过配置项支持多网络环境下的设备,所以可以保证低寻址成本和最高的传输速度。2. The network protocols of the sender and multiple receivers are pre-configured in the message server, so devices in multiple network environments can be supported through configuration items, so low addressing costs and the highest transmission speed can be guaranteed.
3、由于可以动态注册发送端和接收端、定制消息的解析行为,提高了服务的灵活性。3. Since the sender and receiver can be dynamically registered, and the parsing behavior of the customized message can be customized, the flexibility of the service is improved.
下面将从消息服务器中各个模块的角度,对存储空间分配流程、消息存储流程、待发送消息查询流程、以及待发送消息发送流程进行进一步说明。The following will further describe the storage space allocation process, the message storage process, the query process for messages to be sent, and the process for sending messages to be sent from the perspective of each module in the message server.
图3为创建存储空间的流程,包括以下步骤:Figure 3 shows the process of creating a storage space, including the following steps:
S301:缓存模块被唤醒。S301: The cache module is woken up.
S302:缓存模块接到创建空间指令。S302: The cache module receives an instruction to create a space.
可以理解的是,消息模块按需向缓存模块发送创建空间指令,即在需要为发送端创建存储空间的情况下,例如S210,发送包括发送端标识的创建空间指令,而在需要为接收端创建存储空间的情况下,例如S219,发送包括接收端标识的创建空间指令。It can be understood that the message module sends a space creation instruction to the cache module as needed, that is, in the case where a storage space needs to be created for the sender, for example, S210, a space creation instruction including the sender identifier is sent, and a space creation instruction needs to be created for the receiver. In the case of storage space, for example, S219, send a space creation instruction including the identifier of the receiver.
S303:缓存模块依据创建空间指令创建终端的存储空间。S303: The cache module creates the storage space of the terminal according to the space creation instruction.
具体的,将创建空间指令中的发送端标识或接收到标识放入映射,并创建映射与链表之间的对应关系。Specifically, the sender identifier or the received identifier in the space creation instruction is put into the map, and the corresponding relationship between the map and the linked list is created.
可选的,为了节省资源,缓存模块在完成存储空间的创建后,可以进入休眠状态。Optionally, in order to save resources, the cache module may enter a sleep state after completing the creation of the storage space.
图4为存储发送端发送的消息的流程,包括以下步骤:Fig. 4 is the process flow of storing the message that the sending end sends, including the following steps:
S401:缓存模块被唤醒。S401: The cache module is woken up.
S402:缓存模块接收到消息存储指令。S402: The cache module receives a message storage instruction.
具体的,消息存储指令可由消息模块在接收到发送端发送的消息后发出。Specifically, the message storage instruction may be issued by the message module after receiving the message sent by the sender.
S403:缓存模块将消息按照发送时间排序存储至发送端对应的链表内。S403: The cache module stores the messages in a linked list corresponding to the sender according to the sending time sequence.
可选的,为了节省资源,缓存模块在完成消息存储后,可以进入休眠状态。Optionally, in order to save resources, the cache module may enter a sleep state after storing the message.
图5为查询待发送的消息的流程,包括以下步骤:Figure 5 is a process of querying messages to be sent, including the following steps:
S501:缓存模块被唤醒。S501: The cache module is woken up.
S502:缓存模块接到消息查询指令。S502: The cache module receives a message query instruction.
具体的,消息查询指令可以由消息模块在S207或者S214发送。Specifically, the message query instruction may be sent by the message module at S207 or S214.
S503:缓存模块遍历现有发送端的存储空间,找出待发送消息。S503: The cache module traverses the storage space of the existing sender to find the message to be sent.
S504:将待发送消息发送至消息模块。S504: Send the message to be sent to the message module.
可选的,为了节省资源,缓存模块在完成消息查询后,可以进入休眠状态。Optionally, in order to save resources, the cache module may enter a sleep state after completing the message query.
图6为发送查询到待发送的消息的流程,包括以下步骤:Fig. 6 is the process flow of sending the query to the message to be sent, including the following steps:
S601:消息模块收到待发送的消息。S601: The message module receives the message to be sent.
S602:消息模块解析待发送的消息,并将待发送的消息按照接收端分组。S602: The message module parses the to-be-sent messages, and groups the to-be-sent messages according to the receiving end.
S603:消息模块从注册信息管理模块尝试查找被阻塞的接收端,如果找到,执行S604,如果没有找到,执行S605。S603: The message module tries to find the blocked receiving end from the registration information management module, and if found, executes S604, and if not found, executes S605.
S604:唤醒接收端,并将接收方为被阻塞的接收端的待发送的消息,按照时间顺序,发送至对应的接收端。S604: Wake up the receiver, and send the messages to be sent whose receivers are blocked receivers to the corresponding receivers in chronological order.
S605:将待发送的消息存储至缓存模块。具体的存储流程如前所述。S605: Store the message to be sent in the cache module. The specific storage process is as described above.
本身器实施例公开了一种消息处理设备,消息处理设备连接多个发送端和多个接收端,其中,多个发送端和多个接收端的网络协议被预先配置在消息处理设备中;消息处理设备包括存储器和处理器。其中,存储器用于存储程序,处理器用于运行程序,以实现消息处理方法的各个步骤。The embodiment of the native device discloses a message processing device, the message processing device is connected to a plurality of sending ends and a plurality of receiving ends, wherein the network protocols of the plurality of sending ends and the plurality of receiving ends are pre-configured in the message processing device; The device includes a memory and a processor. Wherein, the memory is used for storing the program, and the processor is used for running the program, so as to realize each step of the message processing method.
图7为本申请实施例公开的一种消息处理设备的结构示意图,该设备可以包括:至少一个处理器701,至少一个通信接口702,至少一个存储器703和至少一个通信总线704;7 is a schematic structural diagram of a message processing device disclosed in an embodiment of the present application, the device may include: at least one
在本申请实施例中,处理器701、通信接口702、存储器703、通信总线704的数量为至少一个,且处理器701、通信接口702、存储器703通过通信总线704完成相互间的通信;In this embodiment of the present application, the number of the
处理器701可能是一个中央处理器CPU,或者是特定集成电路ASIC(ApplicationSpecific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路等;The
存储器703可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory)等,例如至少一个磁盘存储器;The
其中,存储器存储有程序,处理器可执行存储器存储的程序,实现如上项所述的消息处理方法。The memory stores a program, and the processor can execute the program stored in the memory to implement the message processing method described in the above item.
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质可存储有适于处理器执行的计算机程序,计算机程序被处理器执行时,实现如上所述的消息处理方法。Embodiments of the present application further provide a computer-readable storage medium, where a computer program suitable for execution by a processor can be stored in the computer-readable storage medium. When the computer program is executed by the processor, the above message processing method is implemented.
本申请实施例方法所述的功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算设备可读取存储介质中。基于这样的理解,本申请实施例对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一台计算设备(可以是个人计算机,服务器,移动计算设备或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,RandomAccess Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions described in the methods of the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they may be stored in a readable storage medium of a computing device. Based on this understanding, the part of the embodiments of the present application that contribute to the prior art or the part of the technical solution may be embodied in the form of a software product, and the software product is stored in a storage medium and includes several instructions to make a A computing device (which may be a personal computer, a server, a mobile computing device or a network device, etc.) executes all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, removable hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其它实施例的不同之处,各个实施例之间相同或相似部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments may be referred to each other.
对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments enables any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, this application is not intended to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010363080.2A CN111585808A (en) | 2020-04-30 | 2020-04-30 | A message processing method, apparatus, device, and computer-readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010363080.2A CN111585808A (en) | 2020-04-30 | 2020-04-30 | A message processing method, apparatus, device, and computer-readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111585808A true CN111585808A (en) | 2020-08-25 |
Family
ID=72126374
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010363080.2A Pending CN111585808A (en) | 2020-04-30 | 2020-04-30 | A message processing method, apparatus, device, and computer-readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111585808A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1937811A (en) * | 2006-08-28 | 2007-03-28 | 华为技术有限公司 | Terminal and server communication method, system and device |
US20130010333A1 (en) * | 2010-04-07 | 2013-01-10 | Pankaj Anand | Device messaging |
CN105515936A (en) * | 2014-09-23 | 2016-04-20 | 中国电信股份有限公司 | Method, server and system for message communication |
CN107770034A (en) * | 2016-08-16 | 2018-03-06 | 中国移动通信有限公司研究院 | A kind of message treatment method and device |
CN109067669A (en) * | 2018-09-06 | 2018-12-21 | 华泰证券股份有限公司 | Synchronization call method and application based on asynchronous interface |
CN110933171A (en) * | 2019-11-29 | 2020-03-27 | 北京浪潮数据技术有限公司 | Server asynchronous communication method, device, equipment and computer storage medium |
-
2020
- 2020-04-30 CN CN202010363080.2A patent/CN111585808A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1937811A (en) * | 2006-08-28 | 2007-03-28 | 华为技术有限公司 | Terminal and server communication method, system and device |
US20130010333A1 (en) * | 2010-04-07 | 2013-01-10 | Pankaj Anand | Device messaging |
CN105515936A (en) * | 2014-09-23 | 2016-04-20 | 中国电信股份有限公司 | Method, server and system for message communication |
CN107770034A (en) * | 2016-08-16 | 2018-03-06 | 中国移动通信有限公司研究院 | A kind of message treatment method and device |
CN109067669A (en) * | 2018-09-06 | 2018-12-21 | 华泰证券股份有限公司 | Synchronization call method and application based on asynchronous interface |
CN110933171A (en) * | 2019-11-29 | 2020-03-27 | 北京浪潮数据技术有限公司 | Server asynchronous communication method, device, equipment and computer storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111918273B (en) | Network slice selection method and device | |
CN111770172A (en) | Messaging middleware consumption proxy method, device, proxy server and storage medium | |
CN103795689A (en) | Resource subscription method and device | |
CN107635022A (en) | Method and device for accessing services across internal and external networks | |
CN105656653A (en) | Network access method of newly added node in distributed coordination system, device and system | |
CN111083180B (en) | Internet of things system, Internet of things equipment linkage method and device | |
CN112751847A (en) | Interface call request processing method and device, electronic equipment and storage medium | |
CN110753129A (en) | Message transmission method, system, apparatus, device, and computer-readable storage medium | |
CN111818187B (en) | Intranet and extranet communication method and system | |
CN113835825B (en) | Dynamic adjustment method and device of virtual service host, server and storage medium | |
CN111741512B (en) | A kind of private network access method and device | |
CN115023919B (en) | Firewall rule updating method and device, server and storage medium | |
CN111901132A (en) | Group management method, device and system | |
WO2023103419A1 (en) | Message queue-based method and apparatus for sending 5g messages in batches, and electronic device | |
CN105722040B (en) | Method, device and system for transmitting business messages | |
WO2021087892A1 (en) | Resource subscription method and device, and storage medium | |
CN110290009A (en) | A data scheduling method, device and computer-readable storage medium | |
CN113612825A (en) | Internet of things message middleware server cluster expansion method and system | |
CN108804711A (en) | A kind of method, apparatus and computer readable storage medium of data processing | |
CN111585808A (en) | A message processing method, apparatus, device, and computer-readable storage medium | |
CN116325895A (en) | Data transmission method and related equipment | |
CN117615469A (en) | A communication method and related device | |
CN114138895B (en) | Data synchronization method and device for multiple data sources, computer equipment and storage medium | |
CN114025016B (en) | Data forwarding method, device and storage medium | |
CN115426393A (en) | A method and device for realizing wireless control information interaction |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200825 |
|
RJ01 | Rejection of invention patent application after publication |