WO2017063506A1 - 消息持久化方法及装置 - Google Patents

消息持久化方法及装置 Download PDF

Info

Publication number
WO2017063506A1
WO2017063506A1 PCT/CN2016/100872 CN2016100872W WO2017063506A1 WO 2017063506 A1 WO2017063506 A1 WO 2017063506A1 CN 2016100872 W CN2016100872 W CN 2016100872W WO 2017063506 A1 WO2017063506 A1 WO 2017063506A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
memory
persistent
host
hard disk
Prior art date
Application number
PCT/CN2016/100872
Other languages
English (en)
French (fr)
Inventor
马立军
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2017063506A1 publication Critical patent/WO2017063506A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers

Definitions

  • the present invention relates to the field of network communication technologies, and in particular, to a message persistence method and apparatus.
  • the message middleware adopts a server/client mode, which includes a producer and a consumer of a message, and the message middleware completes the connection between the producer and the consumer, and the entity that completes this part of the function is generally called a message server, wherein
  • the message server mainly includes a switch and a message queue.
  • the message may be lost between the producer and the consumer due to factors such as packet loss, message queue congestion, message server restart, or physical host restart.
  • the restart of the message server or physical host will result in the loss of all messages in the message queue, which is fatal in some application scenarios where the reliability of the message is strict, such as the financial field.
  • the prior art proposes a method for message persistence. Generally, when creating a switch, a message queue, and a message, a persistent parameter is specified, and the switch receives the received message into the hard disk, and then the message queue.
  • the message to be sent is extracted from the hard disk to be sent, so that when the message server or the physical host is restarted, the message stored in the hard disk is not lost, thereby ensuring the reliability and continuity of the message transmission.
  • message persistence will frequently read and write to the hard disk during the message transmission process, especially when the amount of communication messages is large, causing great damage to the hard disk.
  • the main object of the present invention is to provide a message persistence method and apparatus, aiming at reducing damage to a hard disk caused by message persistence.
  • the present invention provides a message persistence method, and the message persistence method includes:
  • the persistent message stored in the memory is stored in the hard disk of the host.
  • the method further includes:
  • the persistent message stored by the hard disk is loaded into the memory.
  • the method further includes:
  • the step of pointing the persistent path of the message server to the memory of the host includes:
  • the RAMDISK area is divided in the memory, and the persistent path of the message server is directed to the RAMDISK area.
  • the step of storing the current persistent message of the memory into the hard disk of the host when detecting the shutdown signal of the host includes:
  • the persistent message stored in the memory is stored in a hard disk with the fastest read/write speed among the plurality of hard disks.
  • the present invention further provides a message persistence device, where the message persistence device includes:
  • a setting module configured to point a persistent path of the message server to the memory of the host when the host initializes the message server, so that the message server stores the received message into the memory
  • the persistence module is configured to store the persistent message stored in the memory to the hard disk of the host when the shutdown signal of the host is detected.
  • the message persistence device further includes a loading module configured to determine whether the hard disk stores a persistent message; and loading the persistent message stored by the hard disk when the hard disk stores the persistent message To the memory.
  • a loading module configured to determine whether the hard disk stores a persistent message; and loading the persistent message stored by the hard disk when the hard disk stores the persistent message To the memory.
  • the loading module is further configured to delete the persistent message stored by the hard disk.
  • the setting module comprises:
  • a determining unit configured to determine, when the host initializes the message server, whether the memory is divided into a memory virtual disk RAMDISK area;
  • a setting unit configured to point the persistent path of the message server to the RAMDISK area when the memory is divided into a RAMDISK area;
  • the setting unit is further configured to divide the RAMDISK area in the memory when the memory is not divided into the RAMDISK area, and then point the persistent path of the message server to the RAMDISK area.
  • the persistence module is further configured to store the persistent messages stored in the memory to the plurality of hard disks when detecting the shutdown signal of the host The fastest read and write hard drive.
  • the invention directs the persistent path of the message server to the memory of the host, so that during the message communication, the message server can use the memory to transfer the message; and when the host is shut down, the memory is stored persistently.
  • the message is stored in the hard disk of the host. Compared with the prior art, the frequent reading and writing of the hard disk due to message persistence is avoided, and the damage of the hard disk caused by the message persistence is reduced, and the message is also provided. Persistently comparable communication performance.
  • FIG. 1 is a schematic flowchart of a first embodiment of a message persistence method according to the present invention
  • FIG. 2 is a schematic diagram of functional modules of a first embodiment of a message persistence apparatus according to the present invention.
  • the present invention provides a message persistence method.
  • the message persistence method includes:
  • Step S10 when the host initializes the message server, point the persistent path of the message server to the memory of the host, so that the message server stores the received message into the memory;
  • the message server is based on a host operation, which includes a switch and a message queue for completing a connection between a message producer (sender) and a consumer (recipient).
  • a host operation which includes a switch and a message queue for completing a connection between a message producer (sender) and a consumer (recipient).
  • the association between the switch and the message queue is implemented by binding, and the switch is combined with multiple message queues to form a “routing table”, where the stored information includes a message queue constraint (Binding Key, binding). Key), when the switch receives the message, it will parse the Routing Key in its message header, and route the message to the message queue according to the routing key and binding key to complete the message delivery.
  • a message queue constraint Binding Key, binding
  • the persistent path of the message server is directed to the memory of the host, and the persistent path may be directed to any area of the memory or a specific area according to actual needs.
  • the switch stores the received message into the memory when receiving the message, and After the message is routed to the message queue to complete the transmission, the message stored in the memory is deleted. Specifically, after the message is sent, the message queue feeds back a successful response to the switch. In this embodiment, the message is successfully sent by detecting a successful response of the message queue feedback.
  • step S20 when the shutdown signal of the host is detected, the persistent message stored in the memory is stored in the hard disk of the host.
  • the shutdown signal of the host is detected. Storing the persistent message stored in the memory to the The hard disk of the host. It will be understood by those skilled in the art that in other embodiments, the persistent message in the memory is stored to the hard disk, and when the host is powered on again, the persistent message is loaded to the The message queue is available for transmission in memory.
  • the detecting the shutdown signal of the host is implemented based on a shutdown signal of an operating system running by the host registered in advance.
  • the persistent message in the memory is still valid, and can continue to be used after the message server is restarted.
  • the message persistence method proposed in this embodiment points the persistent path of the message server to the memory of the host, so that in the message communication process, the message server can use the memory to transfer the message; and when the host is shut down, the memory is persistent.
  • the message is stored in the hard disk of the host. Compared with the prior art, the frequent reading and writing of the hard disk due to message persistence is avoided, and the damage of the hard disk caused by the message persistence is reduced, and the message is also provided. Persistently comparable communication performance.
  • the method further includes:
  • the persistent message stored by the hard disk is loaded into the memory.
  • the purpose of message persistence is to ensure that the message can be securely received by the sender of the message to the receiver of the message without being affected by the message server or the host being shut down (restart).
  • the hard disk After the initial configuration of the message server is completed, it is determined whether the hard disk stores a persistent message. According to the description of the first embodiment of the present invention, those skilled in the art may understand that if the hard disk currently stores a persistent message, When the host is powered off, there is a message that the transmission is not completed. Therefore, in this embodiment, if the hard disk stores a persistent message, the persistent message stored by the hard disk is loaded into the memory. For the message queue to send, to send the persistent message to the target receiver, to ensure the reliability of the message communication.
  • a third embodiment of the message persistence method of the present invention is provided.
  • the step of loading the persistent message stored in the hard disk into the memory include:
  • a hard disk usually has a large capacity space, it still has an upper limit of physical storage. When the capacity is full, the service will not be provided normally, and it cannot be used to store persistent messages, which seriously affects The reliability of message communication. Therefore, in this embodiment, after the persistent message stored in the hard disk is loaded into the memory, it is sent by a message queue, and the persistent message stored in the hard disk obviously has no need to continue storage. At this time, the persistent message stored in the hard disk is deleted to save the capacity space of the hard disk.
  • the foregoing step S10 includes:
  • the RAMDISK area is divided in the memory, and the persistent path of the message server is directed to the RAMDISK area.
  • the RAMDISK technology is a technology for simulating a part of the memory as a hard disk. Compared with the direct hard disk file reading, this technology can greatly improve the file reading performed thereon. speed.
  • the host when the host initializes the message server, it is determined whether the memory is divided into a memory virtual disk RAMDISK area, and the persistent path of the message server is directly directed to the RAMDISK area, otherwise in the memory The RAMDISK area is divided and initialized, and the persistent path of the message server is directed to the RAMDISK area.
  • a fifth embodiment of the message persistence method of the present invention is provided.
  • the foregoing step S20 includes:
  • the persistent message stored in the memory is stored in a hard disk with the fastest read/write speed among the plurality of hard disks.
  • the host usually has multiple hard disks built in, and the read and write performances of these hard disks are often different.
  • the host has built-in SSD (Solid State Drive) and HDD (Mechanical Hard Disk).
  • SSD Solid State Drive
  • HDD Mechanism Hard Disk
  • the present invention dumps the persistent message stored in the memory to the hard disk when the host is powered off, and the time taken by the host to complete the shutdown operation is very short, so to further ensure that the message can be persisted,
  • the persistent message stored in the memory is stored in a hard disk with the fastest read/write speed among the plurality of hard disks.
  • the plurality of hard disks included in the host are respectively read and written to determine the hard disk with the fastest read/write speed among the plurality of hard disks.
  • the present invention further provides a message persistence device.
  • the message persistence device includes:
  • the setting module 10 is configured to, when the host initializes the message server, point the persistent path of the message server to the memory of the host, so that the message server stores the received message into the memory;
  • the message server is based on a host, which includes a switch and a message queue, and is used for Complete the connection between the message producer (sender) and the consumer (recipient).
  • a host which includes a switch and a message queue, and is used for Complete the connection between the message producer (sender) and the consumer (recipient).
  • the association between the switch and the message queue is implemented by binding, and the switch is combined with multiple message queues to form a “routing table”, where the stored information includes a message queue constraint (Binding Key, binding). Key), when the switch receives the message, it will parse the Routing Key in its message header, and route the message to the message queue according to the routing key and binding key to complete the message delivery.
  • a message queue constraint Binding Key, binding
  • the setting module 10 points the persistent path of the message server to the memory of the host, wherein the setting module 10 can point the persistent path to any area of the memory according to actual needs. Or a specific area.
  • the switch stores the received message into the memory when receiving the message. And deleting the message stored in the memory after the message is routed to the message queue to complete the transmission. Specifically, after the message is sent, the message queue feeds back a successful response to the switch. In this embodiment, the message is successfully sent by detecting a successful response of the message queue feedback.
  • the persistence module 20 is configured to store the persistent message stored in the memory to the hard disk of the host when the shutdown signal of the host is detected.
  • the shutdown signal of the host is detected.
  • the persistence module 20 stores the persistent message stored in the memory to the hard disk of the host. It will be understood by those skilled in the art that in other embodiments, the persistent message in the memory is stored to the hard disk, and when the host is powered on again, the persistent message is loaded to the The message queue is available for transmission in memory.
  • the persistence module 20 detects that the shutdown signal of the host is implemented based on a pre-registered shutdown signal of an operating system run by the host.
  • the persistent message in the memory is still valid, and can continue to be used after the message server is restarted.
  • the message persistence device proposed in this embodiment points the persistent path of the message server to the memory of the host, so that during the message communication process, the message server can use the memory to transfer the message; and when the host is powered off, the memory is persistent.
  • the message is stored in the hard disk of the host. Compared with the prior art, the frequent reading and writing of the hard disk due to message persistence is avoided, and the damage of the hard disk caused by the message persistence is reduced, and the message is also provided. Persistently comparable communication performance.
  • the message persistence device further includes a loading module configured to determine whether the hard disk is persistent. The message is loaded; and when the hard disk stores the persistent message, the persistent message stored by the hard disk is loaded into the memory.
  • the purpose of message persistence is to ensure that the message can be securely received by the sender of the message to the receiver of the message without being affected by the message server or the host being shut down (restart).
  • the loading module determines whether the hard disk stores a persistent message. According to the description of the first embodiment of the present invention, those skilled in the art can understand that The hard disk is currently stored with a persistent message, indicating that the host has a message that the transmission is not completed when the host was last powered off. Therefore, in this embodiment, if the hard disk stores a persistent message, the loading module will load the hard disk. Stored persistent messages are loaded into the memory for transmission by the message queue to send persistent messages to the target recipient, ensuring the reliability of message communication.
  • the loading module is further configured to delete the persistent message stored by the hard disk.
  • a hard disk usually has a large capacity space, it still has an upper limit of physical storage. When the capacity is full, the service will not be provided normally, and it cannot be set to store persistent messages, which seriously affects The reliability of message communication. Therefore, in this embodiment, after the persistent message stored in the hard disk is loaded into the memory, it is sent by a message queue, and the persistent message stored in the hard disk obviously has no need to continue storage. At this time, the loading module deletes the persistent message stored in the hard disk to save the capacity space of the hard disk.
  • the setting module 10 includes:
  • a determining unit configured to determine, when the host initializes the message server, whether the memory is divided into a memory virtual disk RAMDISK area;
  • a setting unit configured to point the persistent path of the message server to the RAMDISK area when the memory is divided into a RAMDISK area;
  • the setting unit is further configured to divide the RAMDISK area in the memory when the memory is not divided into the RAMDISK area, and then point the persistent path of the message server to the RAMDISK area.
  • the RAMDISK technology is a technology for simulating a part of the memory as a hard disk. Compared with the direct hard disk file reading, this technology can greatly improve the file reading performed thereon. speed.
  • the determining unit determines whether the memory is divided into a memory virtual disk RAMDISK area, and the setting unit directly points the persistent path of the message server to the RAMDISK area, otherwise The setting unit divides and initializes the RAMDISK area in the memory, and then points the persistent path of the message server to the RAMDISK area.
  • a fifth embodiment of the message persistence device of the present invention is proposed.
  • the persistence module 20 is further configured to detect Measured
  • the persistent message stored in the memory is stored in the hard disk with the fastest read/write speed among the plurality of hard disks.
  • the host usually has multiple hard disks built in, and the read and write performances of these hard disks are often different.
  • the host has built-in SSD (Solid State Drive) and HDD (Mechanical Hard Disk).
  • SSD Solid State Drive
  • HDD Mechanism Hard Disk
  • the present invention transfers the persistent message stored in the memory to the hard disk when the host is powered off, and the time taken by the host to complete the shutdown operation is very short, so in order to further ensure that the message can be persisted,
  • the persistence module 20 stores the persistent message stored in the memory to the hard disk with the fastest read/write speed among the plurality of hard disks.
  • the setting module 10 performs a read/write test on the plurality of hard disks included in the host, and determines a hard disk with the fastest reading and writing speed among the plurality of hard disks.
  • the above-mentioned module of setting module, persistence module, loading module and the like and its sub-module or unit may include software loaded into a server or related device and/or combined or interacted with related hardware, for example, the setting module may include corresponding logic circuit Or include the corresponding program in the server system.
  • the above modules may be each functional module in the same software system, or may belong to different software/operating systems.
  • the invention is applicable to the field of network communication technology, so as to avoid frequent reading and writing of the hard disk due to message persistence compared with the prior art, and reduce damage to the hard disk caused by message persistence, and at the same time, provide non-message information. Persistently comparable communication performance.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

一种消息持久化方法及装置,所述消息持久化方法包括:在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存(S10),以供所述消息服务器将接收到的消息存储至所述内存中;在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中(S20)。该方法及装置能够减小消息持久化对硬盘的损害。

Description

消息持久化方法及装置 技术领域
本发明涉及网络通信技术领域,尤其涉及一种消息持久化方法及装置。
背景技术
目前,消息中间件采用服务器/客户端模式,包含消息的生产者、消费者,由消息中间件完成生产者与消费者之间的连接,完成这部分功能的实体一般称为消息服务器,其中,消息服务器主要包括交换器和消息队列。
在实际使用场景中,由于底层网络传输层可能存在丢包、消息队列拥塞、消息服务器重启或者物理主机重启等因素,消息在生产者和消费者之间可能丢失。尤其是消息服务器或物理主机重启将导致消息队列中的消息全部丢失,这在一些对消息可靠性较为严格的应用场景比如金融领域的应用,是致命的。为了解决此问题,现有技术提出了消息持久化的方法,通常的,在创建交换器、消息队列以及消息时指定持久化参数,由交换器将接收的消息写入硬盘中,再由消息队列从硬盘中提取待发送的消息进行发送操作,这样,当消息服务器或者物理主机重启后,保存在硬盘中的消息不会丢失,从而保证消息传输的可靠性以及连续性。但是,消息持久化将会在消息传输过程中频繁读写硬盘,尤其是当通信消息量较大时,对硬盘造成较大的损害。
发明内容
本发明的主要目的在于提供一种消息持久化方法及装置,旨在减小消息持久化对硬盘的损害。
为实现上述目的,本发明提供一种消息持久化方法,所述消息持久化方法包括:
在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,以供所述消息服务器将接收到的消息存储至所述内存中;
在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中。
优选地,所述将消息服务器的持久化路径指向所述主机的内存的步骤之后,还包括:
判断所述硬盘是否存储有持久化消息;
在所述硬盘存储有持久化消息时,将所述硬盘存储的持久化消息加载至所述内存中。
优选地,所述将所述硬盘存储的持久化消息加载至所述内存中的步骤之后,还包括:
删除所述硬盘存储的所述持久化消息。
优选地,所述在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存的步骤包括:
在主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区;
若是,则将所述消息服务器的持久化路径指向所述RAMDISK区;
若否,则在所述内存划分RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
优选地,当所述主机包括多个硬盘时,所述在侦测到所述主机的关机信号时,将所述内存当前的持久化消息存储至所述主机的硬盘中的步骤包括:
在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
此外,为实现上述目的,本发明还提供了一种消息持久化装置,所述消息持久化装置包括:
设置模块,设置为在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,以供所述消息服务器将接收到的消息存储至所述内存中;
持久化模块,设置为在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中。
优选地,所述将消息持久化装置还包括加载模块,设置为判断所述硬盘是否存储有持久化消息;以及在所述硬盘存储有持久化消息时,将所述硬盘存储的持久化消息加载至所述内存中。
优选地,所述加载模块还设置为删除所述硬盘存储的所述持久化消息。
优选地,所述设置模块包括:
判断单元,设置为在主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区;
设置单元,设置为在所述内存划分有RAMDISK区时,将所述消息服务器的持久化路径指向所述RAMDISK区;
所述设置单元还设置为在所述内存未划分有RAMDISK区时,在所述内存划分RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
优选地,当所述主机包括多个硬盘时,所述持久化模块还设置为在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
本发明通过将消息服务器的持久化路径指向主机的内存,使得在消息通信过程中,消息服务器能够使用内存进行消息的中转;并在主机关机时,将内存存储的持久 化消息存储至所述主机的硬盘中,相较于现有技术,避免了因消息持久化对硬盘的频繁读写,减小了消息持久化对硬盘的损害,同时,还可提供与消息非持久化相当的通信性能。
附图说明
图1为本发明消息持久化方法第一实施例的流程示意图;
图2为本发明消息持久化装置第一实施例的功能模块示意图。
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
本发明提供一种消息持久化方法,参照图1,在本发明消息持久化方法的第一实施例中,所述消息持久化方法包括:
步骤S10,在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,以供所述消息服务器将接收到的消息存储至所述内存中;
需要说明的是,所述消息服务器基于主机运行,其包括交换器和消息队列,用于完成消息生产者(发送方)与消费者(接收方)之间的连接。具体的,交换器与消息队列的关联通过绑定实现,交换器与多个消息队列绑定后会形成一张“路由表”,其中存储的信息包括消息队列的限制条件(Binding Key,绑定键),交换器收到消息时会解析其消息包头中的Routing Key(路由键),根据路由键以及绑定键将消息路由到消息队列,从而完成消息传递。
本实施例中,在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,其中,可以按实际需要将持久化路径指向所述内存的任一区域或者某特定区域。本领域技术人员可以理解的是,在将消息服务器的持久化路径指向所述内存之后,所述交换器在接收到消息时,会将接收的所述消息存储至所述内存中,并在所述消息路由到消息队列完成发送之后,删除所述内存存储的所述消息。具体的,所述消息队列在完成消息的发送之后,向所述交换器反馈成功响应,本实施例中,通过侦测所述消息队列反馈的成功响应以判断消息是否被成功发送。
步骤S20,在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中。
容易理解的是,当消息通信量较大时,所述交换器接收的消息并不能实时发送,将会导致大量的消息拥塞在所述内存,等待发送。虽然内存相较于硬盘具备更高的读写性能,但是其并不具备断电存储的能力,因此,为确保消息能够被持久化,本实施例中,在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述 主机的硬盘中。本领域技术人员可以理解的是,在其他实施例中,在将所述内存中的持久化消息存储至所述硬盘,并在所述主机再次开机时,将所述持久化消息加载至所述内存中即可供所述消息队列进行发送。其中,侦测所述主机的关机信号基于预先注册的所述主机运行的操作系统的关机信号实现。
此外,当消息服务器重启而所述主机不重启时,由于主机并没有断电,所述内存中的持久化消息依然有效,在消息服务器重启后可以继续使用。
本实施例提出的消息持久化方法,将消息服务器的持久化路径指向主机的内存,使得在消息通信过程中,消息服务器能够使用内存进行消息的中转;并在主机关机时,将内存存储的持久化消息存储至所述主机的硬盘中,相较于现有技术,避免了因消息持久化对硬盘的频繁读写,减小了消息持久化对硬盘的损害,同时,还可提供与消息非持久化相当的通信性能。
进一步的,基于第一实施例,提出本发明消息持久化方法的第二实施例,在本实施例中,上述步骤S10之后,还包括:
判断所述硬盘是否存储有持久化消息;
在所述硬盘存储有持久化消息时,将所述硬盘存储的持久化消息加载至所述内存中。
本领域技术人员可以理解的是,消息持久化的目的在于确保消息能够安全的由消息的发送方到达消息的接收方,而不受消息服务器或者主机关机(重启)的影响,本实施例中,在完成消息服务器的初始化配置之后,判断所述硬盘是否存储有持久化消息,基于本发明第一实施例的描述,本领域技术人员可以理解的是,若所述硬盘当前存储有持久化消息,说明所述主机上次关机时,存在未完成发送的消息,因此,在本实施例中,若所述硬盘存储有持久化消息,则将所述硬盘存储的持久化消息加载至所述内存中,供所述消息队列发送,以将持久化消息发送至目标接收方,确保消息通信的可靠性。
进一步的,基于第二实施例,提出本发明消息持久化方法的第三实施例,在本实施例中,所述将所述硬盘存储的持久化消息加载至所述内存中的步骤之后,还包括:
删除所述硬盘存储的所述持久化消息。
本领域技术人员可以理解的是,虽然硬盘通常具备较大的容量空间,但是其仍然具有物理存储上限,当容量满时,将不能正常提供服务,也就不能用于存储持久化消息,严重影响消息通信的可靠性。因此,本实施例中,在将所述硬盘中存储的所述持久化消息加载至所述内存之后,由消息队列进行发送,所述硬盘中存储的所述持久化消息显然没有继续存储的必要,此时删除所述硬盘中存储的所述持久化消息,以节省所述硬盘的容量空间。
进一步的,基于前述任一实施例,提出本发明消息持久化方法的第四实施例,在本实施例中,上述步骤S10包括:
在主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区;
若是,则将所述消息服务器的持久化路径指向所述RAMDISK区;
若否,则在所述内存划分RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
需要说明的是,RAMDISK技术是将内存的一部分区域模拟为硬盘来使用的一种技术,相对于直接的硬盘文件读取来说,这种技术可以极大的提高在其上进行的文件读取的速度。本实施例中,在所述主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区,是则直接将所述消息服务器的持久化路径指向所述RAMDISK区,否则在所述内存划分并初始化RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
进一步的,基于前述任一实施例,提出本发明消息持久化方法的第五实施例,在本实施例中,当所述主机包括多个硬盘时,上述步骤S20包括:
在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
本领域技术人员可以理解的是,在实际使用过程中,主机通常内置有多个硬盘,而这些硬盘的读写性能往往不同,例如,主机内置有SSD(固态硬盘)和HDD(机械硬盘),显然的,SSD的读写性能远远高于HDD的读写性能,即写入同样大小的数据,SSD相较于HDD需要的时间更少。基于前述实施例的描述,本发明是在主机关机时将内存中存储的持久化消息转存至硬盘中,而主机完成关机操作花费的时间十分短暂,因此为进一步确保消息能够被持久化,本实施例中,在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
此外,在完成消息服务器的持久化设置之后,对主机包括的多个硬盘分别进行读写测试,确定多个所述硬盘中读写速度最快的硬盘。
进一步的,本发明还提供一种消息持久化装置,参照图2,在本发明消息持久化装置的第一实施例中,所述消息持久化装置包括:
设置模块10,设置为在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,以供所述消息服务器将接收到的消息存储至所述内存中;
需要说明的是,所述消息服务器基于主机运行,其包括交换器和消息队列,用于 完成消息生产者(发送方)与消费者(接收方)之间的连接。具体的,交换器与消息队列的关联通过绑定实现,交换器与多个消息队列绑定后会形成一张“路由表”,其中存储的信息包括消息队列的限制条件(Binding Key,绑定键),交换器收到消息时会解析其消息包头中的Routing Key(路由键),根据路由键以及绑定键将消息路由到消息队列,从而完成消息传递。
本实施例中,在主机初始化消息服务器时,设置模块10将消息服务器的持久化路径指向所述主机的内存,其中,设置模块10可以按实际需要将持久化路径指向所述内存的任一区域或者某特定区域。本领域技术人员可以理解的是,在设置模块10将消息服务器的持久化路径指向所述内存之后,所述交换器在接收到消息时,会将接收的所述消息存储至所述内存中,并在所述消息路由到消息队列完成发送之后,删除所述内存存储的所述消息。具体的,所述消息队列在完成消息的发送之后,向所述交换器反馈成功响应,本实施例中,通过侦测所述消息队列反馈的成功响应以判断消息是否被成功发送。
持久化模块20,设置为在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中。
容易理解的是,当消息通信量较大时,所述交换器接收的消息并不能实时发送,将会导致大量的消息拥塞在所述内存,等待发送。虽然内存相较于硬盘具备更高的读写性能,但是其并不具备断电存储的能力,因此,为确保消息能够被持久化,本实施例中,在侦测到所述主机的关机信号时,持久化模块20将所述内存中存储的持久化消息存储至所述主机的硬盘中。本领域技术人员可以理解的是,在其他实施例中,在将所述内存中的持久化消息存储至所述硬盘,并在所述主机再次开机时,将所述持久化消息加载至所述内存中即可供所述消息队列进行发送。其中,持久化模块20侦测所述主机的关机信号基于预先注册的所述主机运行的操作系统的关机信号实现。
此外,当消息服务器重启而所述主机不重启时,由于主机并没有断电,所述内存中的持久化消息依然有效,在消息服务器重启后可以继续使用。
本实施例提出的消息持久化装置,将消息服务器的持久化路径指向主机的内存,使得在消息通信过程中,消息服务器能够使用内存进行消息的中转;并在主机关机时,将内存存储的持久化消息存储至所述主机的硬盘中,相较于现有技术,避免了因消息持久化对硬盘的频繁读写,减小了消息持久化对硬盘的损害,同时,还可提供与消息非持久化相当的通信性能。
进一步的,基于第一实施例,提出本发明消息持久化装置的第二实施例,在本实施例中,所述将消息持久化装置还包括加载模块,设置为判断所述硬盘是否存储有持久化消息;以及在所述硬盘存储有持久化消息时,将所述硬盘存储的持久化消息加载至所述内存中。
本领域技术人员可以理解的是,消息持久化的目的在于确保消息能够安全的由消息的发送方到达消息的接收方,而不受消息服务器或者主机关机(重启)的影响,本实施例中,在所述设置模块10完成消息服务器的初始化配置之后,所述加载模块判断所述硬盘是否存储有持久化消息,基于本发明第一实施例的描述,本领域技术人员可以理解的是,若所述硬盘当前存储有持久化消息,说明所述主机上次关机时,存在未完成发送的消息,因此,在本实施例中,若所述硬盘存储有持久化消息,加载模块则将所述硬盘存储的持久化消息加载至所述内存中,供所述消息队列发送,以将持久化消息发送至目标接收方,确保消息通信的可靠性。
进一步的,基于第二实施例,提出本发明消息持久化装置的第三实施例,在本实施例中,所述加载模块还设置为删除所述硬盘存储的所述持久化消息。
本领域技术人员可以理解的是,虽然硬盘通常具备较大的容量空间,但是其仍然具有物理存储上限,当容量满时,将不能正常提供服务,也就不能设置为存储持久化消息,严重影响消息通信的可靠性。因此,本实施例中,在将所述硬盘中存储的所述持久化消息加载至所述内存之后,由消息队列进行发送,所述硬盘中存储的所述持久化消息显然没有继续存储的必要,此时加载模块删除所述硬盘中存储的所述持久化消息,以节省所述硬盘的容量空间。
进一步的,基于前述任一实施例,提出本发明消息持久化装置的第四实施例,在本实施例中,所述设置模块10包括:
判断单元,设置为在主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区;
设置单元,设置为在所述内存划分有RAMDISK区时,将所述消息服务器的持久化路径指向所述RAMDISK区;
所述设置单元还设置为在所述内存未划分有RAMDISK区时,在所述内存划分RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
需要说明的是,RAMDISK技术是将内存的一部分区域模拟为硬盘来使用的一种技术,相对于直接的硬盘文件读取来说,这种技术可以极大的提高在其上进行的文件读取的速度。本实施例中,在所述主机初始化消息服务器时,判断单元判断所述内存是否划分有内存虚拟磁盘RAMDISK区,是则设置单元直接将所述消息服务器的持久化路径指向所述RAMDISK区,否则设置单元在所述内存划分并初始化RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
进一步的,基于前述任一实施例,提出本发明消息持久化装置的第五实施例,在本实施例中,当所述主机包括多个硬盘时,所述持久化模块20还设置为在侦测到所 述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
本领域技术人员可以理解的是,在实际使用过程中,主机通常内置有多个硬盘,而这些硬盘的读写性能往往不同,例如,主机内置有SSD(固态硬盘)和HDD(机械硬盘),显然的,SSD的读写性能远远高于HDD的读写性能,即写入同样大小的数据,SSD相较于HDD需要的时间更少。基于前述实施例的描述,本发明是在主机关机时将内存中存储的持久化消息转存至硬盘中,而主机完成关机操作花费的时间十分短暂,因此,为进一步确保消息能够被持久化,本实施例中,在侦测到所述主机的关机信号时,所述持久化模块20将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
此外,在完成消息服务器的持久化设置之后,所述设置模块10对主机包括的多个硬盘分别进行读写测试,确定多个所述硬盘中读写速度最快的硬盘。
上述设置模块、持久化模块、加载模块等模块及其子模块或单元可包括加载到服务器或相关设备上的软件及/或与相关硬件的结合或交互,例如,设置模块可包括对应的逻辑电路,或包括服务器系统中相应的程序。上述各模块可以是同一软件系统中的各功能模块,也可能分属不同的软件/操作系统。
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。
工业实用性
本发明适用于网络通信技术领域,以实现相较于现有技术,避免了因消息持久化对硬盘的频繁读写,减小了消息持久化对硬盘的损害,同时,还可提供与消息非持久化相当的通信性能。

Claims (10)

  1. 一种消息持久化方法,包括:
    在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,以供所述消息服务器将接收到的消息存储至所述内存中;
    在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中。
  2. 如权利要求1所述的消息持久化方法,其中,所述将消息服务器的持久化路径指向所述主机的内存的步骤之后,还包括:
    判断所述硬盘是否存储有持久化消息;
    在所述硬盘存储有持久化消息时,将所述硬盘存储的持久化消息加载至所述内存中。
  3. 如权利要求2所述的消息持久化方法,其中,所述将所述硬盘存储的持久化消息加载至所述内存中的步骤之后,还包括:
    删除所述硬盘存储的所述持久化消息。
  4. 如权利要求1-3任一项所述的消息持久化方法,其中,所述在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存的步骤包括:
    在主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区;
    若是,则将所述消息服务器的持久化路径指向所述RAMDISK区;
    若否,则在所述内存划分RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
  5. 如权利要求1-3任一项所述的消息持久化方法,其中,当所述主机包括多个硬盘时,所述在侦测到所述主机的关机信号时,将所述内存当前的持久化消息存储至所述主机的硬盘中的步骤包括:
    在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
  6. 一种消息持久化装置,包括:
    设置模块,设置为在主机初始化消息服务器时,将消息服务器的持久化路径指向所述主机的内存,以供所述消息服务器将接收到的消息存储至所述内存中;
    持久化模块,设置为在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至所述主机的硬盘中。
  7. 如权利要求6所述的消息持久化装置,其中,所述将消息持久化装置还包括加载模块,设置为判断所述硬盘是否存储有持久化消息;以及在所述硬盘存储有持久化消息时,将所述硬盘存储的持久化消息加载至所述内存中。
  8. 如权利要求7所述的消息持久化装置,其中,所述加载模块还设置为删除所 述硬盘存储的所述持久化消息。
  9. 如权利要求6-8任一项所述的消息持久化装置,其中,所述设置模块包括:
    判断单元,设置为在主机初始化消息服务器时,判断所述内存是否划分有内存虚拟磁盘RAMDISK区;
    设置单元,设置为在所述内存划分有RAMDISK区时,将所述消息服务器的持久化路径指向所述RAMDISK区;
    所述设置单元还设置为在所述内存未划分有RAMDISK区时,在所述内存划分RAMDISK区,再将所述消息服务器的持久化路径指向所述RAMDISK区。
  10. 如权利要求6-8任一项所述的消息持久化装置,其中,当所述主机包括多个硬盘时,所述持久化模块还设置为在侦测到所述主机的关机信号时,将所述内存中存储的持久化消息存储至多个所述硬盘中读写速度最快的硬盘中。
PCT/CN2016/100872 2015-10-15 2016-09-29 消息持久化方法及装置 WO2017063506A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510671214.6A CN106598473B (zh) 2015-10-15 2015-10-15 消息持久化方法及装置
CN201510671214.6 2015-10-15

Publications (1)

Publication Number Publication Date
WO2017063506A1 true WO2017063506A1 (zh) 2017-04-20

Family

ID=58517775

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/100872 WO2017063506A1 (zh) 2015-10-15 2016-09-29 消息持久化方法及装置

Country Status (2)

Country Link
CN (1) CN106598473B (zh)
WO (1) WO2017063506A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114070831A (zh) * 2021-11-15 2022-02-18 中交第二航务工程勘察设计院有限公司 基于revit的bim云服务系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060117172A1 (en) * 2004-11-12 2006-06-01 Yaoxue Zhang Method and computing system for transparence computing on the computer network
CN101459627A (zh) * 2008-04-07 2009-06-17 中兴通讯股份有限公司 消息管理方法
CN104298619A (zh) * 2014-09-26 2015-01-21 北京控制工程研究所 基于Ramdisk和固态硬盘的高速二级存储系统及数据存取方法
CN104298474A (zh) * 2014-10-13 2015-01-21 张维加 一种基于服务端与外部缓存系统的外接式计算设备加速方法与实现该方法的设备
CN104734895A (zh) * 2013-12-18 2015-06-24 青岛海尔空调器有限总公司 业务监控系统及业务监控方法

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7562202B2 (en) * 2004-07-30 2009-07-14 United Parcel Service Of America, Inc. Systems, methods, computer readable medium and apparatus for memory management using NVRAM
CN101510838B (zh) * 2009-02-26 2012-07-04 北京北纬点易信息技术有限公司 实现持久化数据队列的方法
JP5520747B2 (ja) * 2010-08-25 2014-06-11 株式会社日立製作所 キャッシュを搭載した情報装置及びコンピュータ読み取り可能な記憶媒体
CN103019615B (zh) * 2012-07-19 2015-08-26 中国人民解放军国防科学技术大学 一种基于负载控制的提高闪存固态硬盘持久性方法
CN102868564A (zh) * 2012-10-10 2013-01-09 山东中创软件商用中间件股份有限公司 一种消息持久化方法及系统
CN103309733A (zh) * 2013-06-07 2013-09-18 深圳中兴网信科技有限公司 任务调度信息持久化装置和任务调度信息持久化方法
CN104424186B (zh) * 2013-08-19 2018-04-03 阿里巴巴集团控股有限公司 一种流计算应用中实现持久化的方法及装置
CN103870570B (zh) * 2014-03-14 2018-04-27 上海艾讯云计算有限公司 一种基于远程日志备份的 HBase 数据可用性及持久性的方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060117172A1 (en) * 2004-11-12 2006-06-01 Yaoxue Zhang Method and computing system for transparence computing on the computer network
CN101459627A (zh) * 2008-04-07 2009-06-17 中兴通讯股份有限公司 消息管理方法
CN104734895A (zh) * 2013-12-18 2015-06-24 青岛海尔空调器有限总公司 业务监控系统及业务监控方法
CN104298619A (zh) * 2014-09-26 2015-01-21 北京控制工程研究所 基于Ramdisk和固态硬盘的高速二级存储系统及数据存取方法
CN104298474A (zh) * 2014-10-13 2015-01-21 张维加 一种基于服务端与外部缓存系统的外接式计算设备加速方法与实现该方法的设备

Also Published As

Publication number Publication date
CN106598473A (zh) 2017-04-26
CN106598473B (zh) 2020-09-04

Similar Documents

Publication Publication Date Title
JP6605078B2 (ja) 情報処理方法、情報処理装置、サーバ及びコンピュータ読み取り可能な記録媒体
US9848047B2 (en) High density hosting for messaging service
US11403227B2 (en) Data storage method and apparatus, and server
US11237922B2 (en) Removing data from a data pipeline for efficient forwarding of live data
EP2921974A1 (en) Data restoration method and system
US10599675B2 (en) Hybrid data replication
US10592317B2 (en) Timeout processing for messages
CN110209341B (zh) 一种数据写入方法、装置和存储设备
CN108255576A (zh) 虚拟机热迁移异常处理方法、装置和存储介质
WO2017063506A1 (zh) 消息持久化方法及装置
CN113220650B (zh) 数据存储方法、装置、设备、存储介质及程序
CN112152872B (zh) 一种网络亚健康检测方法及装置
WO2017071430A1 (zh) 处理报文的方法、网卡及系统、更新信息的方法及主机
CN107656702B (zh) 加速硬盘读写的方法及其系统、以及电子设备
WO2020100271A1 (ja) 情報処理装置、情報処理方法及び情報処理プログラム
KR102284092B1 (ko) 데이터 중복 제거의 딕셔너리 동기화 방법
US20230273824A1 (en) Establishing coherent message analysis across distributed locations
CN108733753B (zh) 一种文件读取方法及应用实体
US11281580B2 (en) Edge device triggering a write-ahead logging (WAL) log when abnormal condition occurs
WO2023116438A1 (zh) 一种数据访问方法、装置以及设备
JP2020031375A (ja) 送信制御装置および送信制御プログラム
CN114189489A (zh) 一种消息推送方法、装置、服务器和介质
JP2007018534A (ja) オンラインシステム回復方法及びその実施装置並びにその処理プログラムを記録した記録媒体
CN114443383A (zh) 一种多路径对象链路状态检测方法、装置及存储介质
CN116541204A (zh) 一种基于流式复制的bmc数据同步的方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16854885

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16854885

Country of ref document: EP

Kind code of ref document: A1