WO2020228287A1 - IoT-MQ 的消息存储方法、装置、计算机设备和存储介质 - Google Patents

IoT-MQ 的消息存储方法、装置、计算机设备和存储介质 Download PDF

Info

Publication number
WO2020228287A1
WO2020228287A1 PCT/CN2019/118172 CN2019118172W WO2020228287A1 WO 2020228287 A1 WO2020228287 A1 WO 2020228287A1 CN 2019118172 W CN2019118172 W CN 2019118172W WO 2020228287 A1 WO2020228287 A1 WO 2020228287A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
hashcode
iot
target
request
Prior art date
Application number
PCT/CN2019/118172
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 WO2020228287A1 publication Critical patent/WO2020228287A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2291User-Defined Types; Storage management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application relates to the technical field of message queues, and in particular to a message storage method, device, computer equipment, and storage medium of the IoT-MQ message queue of the Internet of Things.
  • IoT-MQ Internet of Things Message Queue, Chinese is the Internet of Things message queue
  • the message characteristics of Internet of Things devices mainly include: 1. There are many types of messages, such as home appliance information, temperature information, and weather. Information etc. 2. The number of devices is large, and the volume of messages is large. Generally speaking, IoT devices refer to devices with more than tens of millions of levels. The message volume is generally billions of messages. The main function of IoT-MQ is to collect these messages from devices. Message distribution and message storage generally need to meet such a large amount of message storage: 1. The message storage is reliable, 2. The message storage has a small impact on the overall IoT MQ performance, and 3.
  • the stored messages are convenient for subsequent retrieval for secondary processing.
  • the current market solutions generally include: using traditional relational database storage, such as Mysql, pg, etc.
  • relational databases when the amount of data is very large, such as the storage of hundreds of millions of data, it is necessary to reprocess the sub-database and sub-tables, etc. And for query, it will be very bad when the amount of data is very large, and most relational databases are memory databases, resulting in unsatisfactory performance in message storage and message acquisition.
  • this application proposes a message storage method, device, computer equipment and storage medium for the IoT-MQ message queue of the Internet of Things, which aims to solve the problem of poor message storage performance when a relational database is used to store a large number of messages.
  • a message storage method of the IoT-MQ message queue of the Internet of Things includes:
  • hashCode correspondence table stores the correspondence between the hashCode calculated by the preset hash algorithm and the hashCode used to determine the storage location of the message library;
  • Each of the plurality of first tags is input as a key into a preset hash algorithm for calculation, and the first hashCode corresponding to each of the first tags is calculated;
  • the IoT-MQ messages corresponding to the different first hashCode are respectively stored in the hash slot of the second hashCode corresponding to each of the first hashCode.
  • the present application also provides a message storage device of the IoT-MQ message queue, the device includes:
  • the establishment of a relationship table module which is used to establish a hashCode correspondence table, in which the hashCode correspondence table stores the correspondence between the hashCode calculated by the preset hash algorithm and the hashCode used to determine the storage location of the message library;
  • the marking module is used to add a mark to each IoT-MQ message to obtain multiple first marks;
  • a calculation module for inputting each of the plurality of first tags as a key into a preset hash algorithm for calculation, and calculating the first hashCode corresponding to each of the first tags;
  • a search module configured to search for a second hashCode corresponding to each of the first hashCodes in a message library according to the hashCode correspondence table, and the message library is a distributed message library;
  • the storage module is configured to store IoT-MQ messages corresponding to different first hashCodes into the hash slots of the second hashCode corresponding to each of the first hashCodes.
  • the present application also provides a computer device, including a memory and a processor, the memory stores a computer program, and the processor implements the steps of any one of the foregoing methods when the computer program is executed.
  • the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the above methods are implemented.
  • IoT-MQ message tags use the first tag as the key to calculate through a preset hash algorithm to obtain multiple hashCodes corresponding to the first tags, find the corresponding hashCode in the message library, and store each IoT-MQ message to The hash slot of the corresponding hashCode in the message library is stored in the message library.
  • the message library is distributed and highly reliable, ensuring the reliability of a large number of message storage, and aims to solve the problem of using a relational database to store a large number of messages and poor message storage performance problem.
  • FIG. 1 is a flowchart of a message storage method using the IoT message queue IoT-MQ provided by an embodiment of the application;
  • FIG. 2 is a functional module diagram of a message storage device using the IoT message queue IoT-MQ provided by an embodiment of the present application;
  • FIG. 3 is a schematic block diagram of the structure of a computer device provided by an embodiment of the application.
  • an embodiment of the present application proposes a message storage method of IoT-MQ for the Internet of Things message queue.
  • the method includes the following steps:
  • Step S101 Establish a hashCode correspondence table, in which the hashCode correspondence table stores the correspondence between the hashCode calculated by the preset hash algorithm and the hashCode used to determine the storage location of the message library.
  • the hashCode correspondence table stores the correspondence between one hashCode and another hashCode.
  • One hashCode is a hashCode calculated by a preset hash algorithm
  • the other hashCode is a hashCode in the message library, which is used to store IoT-MQ messages.
  • Step S102 Add a tag to each IoT-MQ message to obtain multiple first tags.
  • IoT-MQ When IoT-MQ receives a message, it adds a tag to each IoT-MQ message, and after the tag is completed, multiple first tags are obtained.
  • the method before step S102, the method includes:
  • the IoT-MQ If it is detected that the IoT-MQ receives a message, it triggers a signal to add a tag to the IoT-MQ message.
  • the first mark is a category mark, such as Topic, which identifies which category the message belongs to.
  • the first tag is a device tag, such as a device ID, which identifies which device the message belongs to.
  • the method before step S102, the method includes:
  • the device ID corresponding to the device to which each IoT-MQ message belongs is obtained.
  • each IoT-MQ message identify the device to which each IoT-MQ message belongs, and after identifying the device to which each IoT-MQ message belongs, identify the device to which each IoT-MQ message belongs Device, obtain the device ID corresponding to the device to which each IoT-MQ message belongs.
  • step S102 includes:
  • each IoT-MQ message After obtaining the device ID corresponding to the device to which each IoT-MQ message belongs, add a corresponding device ID to each IoT-MQ message, use the device ID as a tag, and obtain multiple first tags.
  • Step S103 Input each of the plurality of first tags as a key into a preset hash algorithm for calculation, and calculate the first hashCode corresponding to each of the first tags.
  • each first tag in the multiple first tags uses each first tag in the multiple first tags as a key.
  • the key is a parameter in the hash algorithm.
  • the hashCode corresponding to the multiple first tags is calculated by the preset hash algorithm. , Get the first hashCode.
  • Step S104 According to the hashCode correspondence table, search for a second hashCode corresponding to each of the first hashCodes in a message library, where the message library is a distributed message library.
  • the message library is RocketMQ.
  • Step S105 Store the IoT-MQ messages corresponding to the different first hashCodes into the hash slots of the second hashCode corresponding to each of the first hashCodes.
  • step S105 includes:
  • the IoT-MQ messages are stored in the message list in the corresponding hash slot in the order of storage time.
  • the message list is used to store IoT-MQ messages.
  • IoT-MQ messages are stored in the hash slot of the corresponding hashCode in the message library, the IoT-MQ messages are stored in chronological order Store the message list in the corresponding hash slot to ensure that the head of the entire message queue is the latest message, and the tail is the oldest message.
  • step S105 the method includes:
  • a request for obtaining IoT-MQ messages is received.
  • the request includes a key.
  • the key in the request is obtained from the request.
  • the initiator of the request can also be obtained from the request.
  • the hashCode corresponding to the key in the request is calculated by the preset hash algorithm, and the target hashCode is obtained.
  • search for the hashCode corresponding to the target hashCode in the message library and find the corresponding Get the hash slot of the corresponding hashCode, get the first target hash slot, and return all messages in the first target hash slot to the initiator of the request.
  • the hash algorithm can be MD5 or SHA-1.
  • the method includes:
  • the step of returning all the messages in the first target hash slot to the initiator of the request includes:
  • the first target hash slot is a message
  • all messages in the first target hash slot are returned to the initiator of the request.
  • the method includes:
  • the request initiator When it is determined that the first target hash slot does not have a message, the request initiator needs to be notified of this situation, and then the information that there is no message in the first target hash slot is returned to the request initiator.
  • step S105 the method includes:
  • the message corresponding to the timestamp in the target hash slot is returned to the initiator of the request.
  • the key in the request is obtained from the request.
  • the initiator of the request can also be obtained from the request.
  • the hashCode corresponding to the key in the request is calculated by the preset hash algorithm calculation, and the second target hashCode is obtained.
  • the second target hashCode search the message library for the corresponding hashCode of the second target hashCode, according to find the corresponding hashCode, get the hash slot of the corresponding hashCode, get the target hash slot, get the timestamp from the request, judge the timestamp, and judge whether the timestamp is null, if the timestamp is empty Value, all messages in the target hash slot are returned to the initiator of the request. If the timestamp is not null, the message corresponding to the timestamp in the target hash slot is returned to the initiator of the request.
  • the step of returning the message corresponding to the time stamp in the target hash slot to the initiator of the request if the time stamp is not a null value includes:
  • the timestamp is not a null value
  • start searching from the head of the message list in the target hash slot find the storage time corresponding to the timestamp, and find the end of the message list, and end the search.
  • the search is found to correspond to the timestamp
  • the storage time is stored, the message corresponding to the found storage time is obtained, and the obtained corresponding message is returned to the initiator of the request.
  • start searching from the head of the message list in the target hash slot to find the storage time corresponding to the timestamp.
  • continue searching When the storage time that does not correspond to the timestamp is found, the search ends.
  • the storage time corresponding to the timestamp is found, the message corresponding to the found storage time is obtained, and the corresponding message is returned to the initiator of the request square.
  • step S105 the method includes:
  • IoT-MQ message tags use the first tag as the key to calculate through a preset hash algorithm to obtain multiple hashCodes corresponding to the first tags, search for the corresponding hashCode in the message library, and set each IoT-MQ
  • the messages are stored in the hash slot of the corresponding hashCode in the message library, and the message library is used for storage.
  • the message library is distributed and highly reliable, ensuring the reliability of a large number of message storage, and aims to solve the problem of using a relational database to store a large number of messages. Poor message storage performance.
  • an embodiment of the present application proposes a message storage device 1 for an IoT message queue IoT-MQ.
  • the device 1 includes a relationship table establishment module 11, a marking module 12, a calculation module 13, a search module 14 and a storage module 15. .
  • the establishment relationship table module 11 is used to establish a hashCode correspondence relationship table.
  • the hashCode correspondence relationship table stores the correspondence relationship between the hashCode calculated by the preset hash algorithm and the hashCode used to determine the storage location of the message library.
  • the marking module 12 is used to add a mark to each IoT-MQ message to obtain multiple first marks.
  • the device 1 includes:
  • the first detection module is used to detect whether the IoT-MQ receives a message
  • the first triggering module is configured to trigger a signal for adding a tag to the IoT-MQ message if it is detected that the IoT-MQ receives a message.
  • the device 1 includes:
  • the first identification module is used to identify the device to which each IoT-MQ message belongs;
  • the first obtaining module is used to obtain the device ID corresponding to the device to which each IoT-MQ message belongs according to the device to which each IoT-MQ message is identified.
  • the marking module 12 includes:
  • the device ID marking module is used to mark the device ID corresponding to the device to which each IoT-MQ message belongs;
  • the first sub-marking module is used to add a corresponding mark to each IoT-MQ message to obtain multiple first marks.
  • the calculation module 13 is configured to input each first mark of the plurality of first marks as a key into a preset hash algorithm for calculation, and calculate the first hashCode corresponding to each of the first marks.
  • the search module 14 is configured to search for a second hashCode corresponding to each of the first hashCodes in a message library according to the hashCode correspondence table, and the message library is a distributed message library.
  • the message library is RocketMQ.
  • the storage module 15 is configured to store IoT-MQ messages corresponding to different first hashCodes into the hash slots of the second hashCode corresponding to each of the first hashCodes.
  • the storage module 15 includes:
  • the first sub-storage module is used to store the IoT-MQ messages into the message list in the corresponding hash slot in the order of storage time.
  • the device 1 includes:
  • the first receiving module is configured to receive a request for obtaining IoT-MQ messages, where the request includes a key;
  • the first calculation module is configured to input the key in the request into the preset hash algorithm for calculation, calculate the hashCode corresponding to the key in the request, and obtain the target hashCode;
  • the first search module is configured to search for the hashCode corresponding to the target hashCode in the message library according to the hashCode correspondence table to obtain the first target hashCode;
  • the first obtaining module is configured to obtain the hash slot of the first target hashCode to obtain the first target hash slot;
  • the first return module is configured to return all the messages in the first target hash slot to the initiator of the request.
  • Device 1 includes:
  • the first judgment module is used to judge whether there is a message in the first target hash slot.
  • the first return module includes:
  • the first sub-return module is configured to, if it is determined that the first target hash slot is a message, return all the messages in the first target hash slot to the initiator of the request.
  • Device 1 includes:
  • the first return module is configured to, if it is determined that there is no message in the first target hash slot, return the information that there is no message in the first target hash slot to the initiator of the request.
  • the device 1 includes:
  • the second receiving module is configured to receive a request for obtaining IoT-MQ messages, where the request includes a key and a timestamp;
  • the third calculation module is configured to input the key in the request into the preset hash algorithm for calculation, calculate the hashCode corresponding to the key in the request, and obtain the second target hashCode;
  • the third search module is used to search for the hashCode corresponding to the second target hashCode in the message library to obtain the third target hashCode;
  • the second obtaining module is used to obtain the hash slot of the third target hashCode to obtain the target hash slot;
  • the second judgment module is used to judge whether the timestamp is a null value
  • the third return module is configured to return all messages in the target hash slot to the initiator of the request if the timestamp is a null value;
  • the fourth return module is configured to return the message corresponding to the timestamp in the target hash slot to the initiator of the request if the timestamp is not a null value.
  • the fourth return module includes:
  • the first sub-search module is configured to search for the storage time corresponding to the timestamp from the head of the message list in the target hash slot if the timestamp is not a null value;
  • the first sub-acquisition module is configured to, when the storage time corresponding to the timestamp is found, obtain the message corresponding to the found storage time;
  • the first sub-return module is used to return the obtained corresponding message to the initiator of the request.
  • the device 1 includes:
  • the fourth receiving module is used to receive the valid storage time input by the user
  • the fifth acquisition module is used to acquire the storage time of each message in each hash slot
  • the third judgment module is used to judge whether the storage time of each message is within the effective storage time
  • the sixth obtaining module is configured to, if it is determined that the storage time of each message is not within the effective storage time, obtain the message whose storage time is not within the effective storage time to obtain the target message;
  • the first deleting module is used to delete the target message from the corresponding hash slot.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 3.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, a computer program, and a database.
  • the memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium.
  • the database of the computer equipment is used to store data such as the model of the message storage method of the IoT-MQ message queue.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program is executed by the processor to realize a message storage method of the Internet of Things message queue IoT-MQ.
  • An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, a message storage method of the Internet of Things message queue IoT-MQ is realized.
  • the computer-readable storage medium is, for example, a non-volatile computer-readable storage medium or a volatile computer-readable storage medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)

Abstract

本申请涉及消息列队技术领域,特别涉及一种物联网消息队列IoT-MQ的消息存储方法、装置、计算机设备和存储介质。所述方法包括:建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;对每一条IoT-MQ的消息添加标记,获得多个第一标记;将所述多个第一标记中每一个第一标记作为key输入到预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。解决采用关系型数据库存储大量的消息,消息存储性能差的问题。

Description

IoT-MQ的消息存储方法、装置、计算机设备和存储介质
本申请要求于2019年5月13日提交中国专利局、申请号为201910394580X,申请名称为“IoT-MQ的消息存储方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及消息列队技术领域,特别涉及一种物联网消息队列IoT-MQ的消息存储方法、装置、计算机设备和存储介质。
背景技术
IoT-MQ(Internet of Things Message Queue,中文是物联网消息队列)主要是解决物联网设备在互联网进行消息传输的问题,物联网设备的消息特点主要有:1.消息类型多,比如有家电信息,温度信息,天气信息等。2.设备数多,消息量大,一般来说物联网设备都是指千万级以上的设备,消息量一般是亿级的消息,IoT-MQ的主要功能就是对设备的这些消息进行采集,消息分发与消息存储,对于如此大量的消息存储一般需要满足:1.消息存储可靠,2.消息存储对整体IoT MQ的性能影响较小,3.存储的消息方便后续获取以便进行二次处理。目前市场的解决大致有:利用传统的关系数据库存储,例如用Mysql,pg等,对于关系型数据库,在数据量非常大时,例如对于上亿的数据的存储等需要重新处理分库分表等,并且对于查询来说,在数据量非常大时会非常不好,并且大多关系型数据库是内存数据库,导致在消息存储和消息获取的性能并不理想。
技术问题
针对现有技术不足,本申请提出一种物联网消息队列IoT-MQ的消息存储方法、装置、计算机设备和存储介质,旨在解决采用关系型数据库存储大量的消息,消息存储性能差的问题。
技术解决方案
本申请提出的技术方案是:
一种物联网消息队列IoT-MQ的消息存储方法,所述方法包括:
建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;
对每一条IoT-MQ的消息添加标记,获得多个第一标记;
将所述多个第一标记中每一个第一标记作为key输入到预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;
根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;
将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
本申请还提供一种物联网消息队列IoT-MQ的消息存储装置,所述装置包括:
建立关系表模块,用于建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;
标记模块,用于对每一条IoT-MQ的消息添加标记,获得多个第一标记;
计算模块,用于将所述多个第一标记中每一个第一标记作为key输入到预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;
查找模块,用于根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;
存储模块,用于将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
本申请还提供一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现上述任一项所述的方法的步骤。
本申请还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述任一项所述的方法的步骤。
有益效果
对IoT-MQ的消息标记,将第一标记作为key通过预设hash算法计算,得到多个第一标记对应的hashCode,在消息库中查找对应的hashCode,将各IoT-MQ的消息分别存储到在消息库中对应的hashCode的hash槽,采用消息库存储,消息库是分布式高可靠的,保证大量消息存储的可靠性,旨在解决采用关系型数据库存储大量的消息,消息存储性能差的问题。
附图说明
图1是应用本申请实施例提供的物联网消息队列IoT-MQ的消息存储方法的流程图;
图2是应用本申请实施例提供的物联网消息队列IoT-MQ的消息存储装置的功能模块图;
图3是应用本申请实施例提供的计算机设备的结构示意框图。
本发明的最佳实施方式
如图1所示,本申请实施例提出一种物联网消息队列IoT-MQ的消息存储方法,所述方法包括以下步骤:
步骤S101、建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系。
hashCode对应关系表中存储一个hashCode与另一个hashCode的对应关系,其中,一个hashCode是通过预设hash算法计算所得的hashCode,另一个hashCode是消息库中的hashCode,用来存储IoT-MQ的消息。
步骤S102、对每一条IoT-MQ的消息添加标记,获得多个第一标记。
在IoT-MQ接收到消息时,对每一条IoT-MQ的消息添加标记,在完成标记之后,获得多个第一标记。
在本实施例中,在步骤S102之前,包括:
检测IoT-MQ是否接收到消息;
若检测到IoT-MQ接收到消息,则触发对IoT-MQ的消息添加标记的信号。
在本实施例中,第一标记为类别标记,例如Topic,识别该消息属于哪一类别消息。
在一些实施例中,第一标记为设备标记,例如设备ID,识别该消息属于哪个设备。
在一些实施例中,在步骤S102之前,包括:
识别每一条IoT-MQ的消息所属的设备;
根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID。
对每一条IoT-MQ的消息进行识别,识别每一条IoT-MQ的消息所属的设备,在识别出每一条IoT-MQ的消息所属的设备之后,根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID。
对应地,在步骤S102中,包括:
将每一条IoT-MQ的消息所属的设备对应的设备ID作为标记;
对每一条IoT-MQ的消息添加对应的标记,获得多个第一标记。
在获取每一条IoT-MQ的消息所属的设备对应的设备ID之后,对每一条IoT-MQ的消息添加对应的设备ID,将设备ID作为标记,获得多个第一标记。
步骤S103、将所述多个第一标记中每一个第一标记作为key输入到预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode。
在获得多个第一标记之后,将多个第一标记中每一个第一标记作为key,key是hash算法中的一个参数,通过预设hash算法计算,计算出多个第一标记对应的hashCode,得到第一hashCode。
步骤S104、根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库。
在计算出多个第一标记对应的hashCode之后,根据多个第一标记对应的hashCode,在消息库中查找对应的hashCode,即是在在消息库中查找与多个第一标记对应的hashCode相同的hashCode。
在本实施例中,消息库是RocketMQ。
步骤S105、将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
在消息库中查找到对应的hashCode,根据多个第一标记对应的hashCode与在消息库中的hashCode的对应关系,在消息库中获取对应的hashCode的hash槽,将各IoT-MQ的消息分别存储到在消息库中对应的hashCode的hash槽。
在本实施例中,在步骤S105中,包括:
将所述IoT-MQ的消息按存储时间先后顺序存入对应的hash槽中的消息列表。
在hash槽中配置消息列表,消息列表用于存放IoT-MQ的消息,当IoT-MQ的消息存储到在消息库中对应的hashCode的hash槽时,将IoT-MQ的消息按存储时间先后顺序存入对应的hash槽中的消息列表,这样保证整个消息队表的头部是最新消息,尾部是最旧的消息。
在本实施例中,在步骤S105之后,包括:
接收获取IoT-MQ的消息的请求,其中所述请求包括key;
将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得目标hashCode;
根据所述hashCode对应关系表,在消息库中查找与所述目标hashCode对应的hashCode,获得第一目标hashCode;
获取所述第一目标hashCode的hash槽,得到第一目标hash槽;
将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
接收获取IoT-MQ的消息的请求,请求包括key,在接收到请求之后,从请求中获取请求中的key,在本实施例中,还可以从请求中获取请求的发起方。在获取到请求中的key之后,通过预设hash算法计算,计算出请求中的key对应的hashCode,获得目标hashCode,根据目标hashCode,在消息库中查找与目标hashCode对应的hashCode,根据查找到对应的hashCode,获取查找到对应的hashCode的hash槽,得到第一目标hash槽,将第一目标hash槽中的全部消息返回给请求的发起方。其中,hash算法可以是MD5或者SHA-1。
在所述获取所述第一目标hashCode的hash槽,得到第一目标hash槽的步骤之后,包括:
判断所述第一目标hash槽是否存在消息。
对应地,在所述将所述第一目标hash槽中的全部消息返回给所述请求的发起方的步骤中,包括:
若判定所述第一目标hash槽是存在消息,则将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
在所述判断所述第一目标hash槽是否存在消息的步骤之后,包括:
若判定所述第一目标hash槽是不存在消息,则将所述第一目标hash槽中不存在消息的信息返回给所述请求的发起方。
在判定所述第一目标hash槽是不存在消息时,需要将此情况通知给请求的发起方,那么将第一目标hash槽中不存在消息的信息返回给请求的发起方。
在一些实施例中,在步骤S105之后,包括:
接收获取IoT-MQ的消息的请求,其中所述请求包括key和时间戳;
将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得第二目标hashCode;
根据所述hashCode对应关系表,在消息库中查找与所述第二目标hashCode对应的hashCode,获得第三目标hashCode;
获取所述第三目标hashCode的hash槽,得到目标hash槽;
判断所述时间戳是否为空值;
若所述时间戳为空值,则将所述目标hash槽中的全部消息返回给所述请求的发起方;
若所述时间戳不为空值,则将所述目标hash槽中的与所述时间戳对应的消息返回给所述请求的发起方。
接收获取IoT-MQ的消息的请求,其中请求包括key和时间戳,在接收到请求之后,从请求中获取请求中的key,在本实施例中,还可以从请求中获取请求的发起方。在获取到请求中的key之后,通过预设hash算法计算,计算出请求中的key对应的hashCode,获得第二目标hashCode,根据第二目标hashCode,在消息库中查找与第二目标hashCode对应的hashCode,根据查找到对应的hashCode,获取查找到对应的hashCode的hash槽,得到目标hash槽,从请求中获取时间戳,对时间戳进行判断,判断时间戳是否为空值,若时间戳为空值,则将目标hash槽中的全部消息返回给请求的发起方,若时间戳不为空值,则将目标hash槽中的与时间戳对应的消息返回给请求的发起方。
在所述若所述时间戳不为空值,则将所述目标hash槽中的与所述时间戳对应的消息返回给所述请求的发起方的步骤中,包括:
若所述时间戳不为空值,则从所述目标hash槽中的消息列表的头部开始查找与所述时间戳对应的存储时间;
当查找到与所述时间戳对应的存储时间时,获取查找到的存储时间对应的消息;
将获取到对应的消息返回给所述请求的发起方。
如果时间戳不为空值,则从目标hash槽中的消息列表的头部开始查找,查找与时间戳对应的存储时间,一直查找到消息列表的尾部,结束查找,当查找到与时间戳对应的存储时间时,获取查找到的存储时间对应的消息,将获取到对应的消息返回给请求的发起方。还可以是,如果时间戳不为空值,则从目标hash槽中的消息列表的头部开始查找,查找与时间戳对应的存储时间,当查找到与时间戳对应的存储时间之后,继续查找,当查找到不与时间戳对应的存储时间时,结束查找,当查找到与时间戳对应的存储时间时,获取查找到的存储时间对应的消息,将获取到对应的消息返回给请求的发起方。
在本实施例中,在步骤S105之后,包括:
接收用户输入的有效存储时间;
获取每一hash槽的各消息的存储时间;
判断各消息的存储时间是否在所述有效存储时间内;
若判断出各消息的中存在存储时间不在所述有效存储时间内,则获取存储时间不在所述有效存储时间内的消息,获得目标消息;
将所述目标消息从对应的hash槽删除。
综上所述,对IoT-MQ的消息标记,将第一标记作为key通过预设hash算法计算,得到多个第一标记对应的hashCode,在消息库中查找对应的hashCode,将各IoT-MQ的消息分别存储到在消息库中对应的hashCode的hash槽,采用消息库存储,消息库是分布式高可靠的,保证大量消息存储的可靠性,旨在解决采用关系型数据库存储大量的消息,消息存储性能差的问题。
如图2所示,本申请实施例提出一种物联网消息队列IoT-MQ的消息存储装置1,装置1包括建立关系表模块11、标记模块12、计算模块13、查找模块14和存储模块15。
建立关系表模块11,用于建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系。
标记模块12,用于对每一条IoT-MQ的消息添加标记,获得多个第一标记。
在本实施例中,装置1包括:
第一检测模块,用于检测IoT-MQ是否接收到消息;
第一触发模块,用于若检测到IoT-MQ接收到消息,则触发对IoT-MQ的消息添加标记的信号。
在一些实施例中,装置1包括:
第一识别模块,用于识别每一条IoT-MQ的消息所属的设备;
第一获取模块,用于根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID。
对应地,标记模块12包括:
设备ID标记模块,用于将每一条IoT-MQ的消息所属的设备对应的设备ID作为标记;
第一子标记模块,用于对每一条IoT-MQ的消息添加对应的标记,获得多个第一标记。
计算模块13,用于将所述多个第一标记中每一个第一标记作为key输入到预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode。
查找模块14,用于根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库。
在本实施例中,消息库是RocketMQ。
存储模块15,用于将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
在本实施例中,存储模块15包括:
第一子存储模块,用于将所述IoT-MQ的消息按存储时间先后顺序存入对应的hash槽中的消息列表。
在本实施例中,装置1包括:
第一接收模块,用于接收获取IoT-MQ的消息的请求,其中所述请求包括key;
第一计算模块,用于将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得目标hashCode;
第一查找模块,用于根据所述hashCode对应关系表,在消息库中查找与所述目标hashCode对应的hashCode,获得第一目标hashCode;
第一获得模块,用于获取所述第一目标hashCode的hash槽,得到第一目标hash槽;
第一返回模块,用于将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
装置1包括:
第一判断模块,用于判断所述第一目标hash槽是否存在消息。
对应地,第一返回模块包括:
第一子返回模块,用于若判定所述第一目标hash槽是存在消息,则将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
装置1包括:
第一返回模块,用于若判定所述第一目标hash槽是不存在消息,则将所述第一目标hash槽中不存在消息的信息返回给所述请求的发起方。
在一些实施例中,装置1包括:
第二接收模块,用于接收获取IoT-MQ的消息的请求,其中所述请求包括key和时间戳;
第三计算模块,用于将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得第二目标hashCode;
第三查找模块,用于在消息库中查找与所述第二目标hashCode对应的hashCode,获得第三目标hashCode;
第二获得模块,用于获取所述第三目标hashCode的hash槽,得到目标hash槽;
第二判断模块,用于判断所述时间戳是否为空值;
第三返回模块,用于若所述时间戳为空值,则将所述目标hash槽中的全部消息返回给所述请求的发起方;
第四返回模块,用于若所述时间戳不为空值,则将所述目标hash槽中的与所述时间戳对应的消息返回给所述请求的发起方。
第四返回模块包括:
第一子查找模块,用于若所述时间戳不为空值,则从所述目标hash槽中的消息列表的头部开始查找与所述时间戳对应的存储时间;
第一子获取模块,用于当查找到与所述时间戳对应的存储时间时,获取查找到的存储时间对应的消息;
第一子返回模块,用于将获取到对应的消息返回给所述请求的发起方。
在本实施例中,装置1包括:
第四接收模块,用于接收用户输入的有效存储时间;
第五获取模块,用于获取每一hash槽的各消息的存储时间;
第三判断模块,用于判断各消息的存储时间是否在所述有效存储时间内;
第六获取模块,用于若判断出各消息的中存在存储时间不在所述有效存储时间内,则获取存储时间不在所述有效存储时间内的消息,获得目标消息;
第一删除模块,用于将所述目标消息从对应的hash槽删除。
如图3所示,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机程序和数据库。该内存器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储物联网消息队列IoT-MQ的消息存储方法的模型等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机程序被处理器执行时以实现一种物联网消息队列IoT-MQ的消息存储方法。
本申请一实施例还提供一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现一种物联网消息队列IoT-MQ的消息存储方法。所述计算机可读存储介质,例如为非易失性的计算机可读存储介质,或者为易失性的计算机可读存储介质。

Claims (20)

  1. 一种物联网消息队列IoT-MQ的消息存储方法,其特征在于,所述方法包括:
    建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;
    对每一条IoT-MQ的消息添加标记,获得多个第一标记;
    将所述多个第一标记中每一个第一标记作为key输入到所述预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;
    根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;
    将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
  2. 根据权利要求1所述的物联网消息队列IoT-MQ的消息存储方法,其特征在于,在所述根据所述对每一条IoT-MQ的消息添加标记,获得多个第一标记的步骤之前,包括:
    识别每一条IoT-MQ的消息所属的设备;
    根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID;
    在所述根据所述对每一条IoT-MQ的消息添加标记,获得多个第一标记的步骤中,包括:
    将每一条IoT-MQ的消息所属的设备对应的设备ID作为标记;
    对每一条IoT-MQ的消息添加对应的标记,获得多个第一标记。
  3. 根据权利要求1所述的物联网消息队列IoT-MQ的消息存储方法,其特征在于,在所述将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽的步骤中,包括:
    将所述IoT-MQ的消息按存储时间先后顺序存入对应的hash槽中的消息列表。
  4. 根据权利要求1所述的物联网消息队列IoT-MQ的消息存储方法,其特征在于,在所述将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽的步骤之后,包括:
    接收获取IoT-MQ的消息的请求,其中所述请求包括key;
    将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得目标hashCode;
    根据所述hashCode对应关系表,在消息库中查找与所述目标hashCode对应的hashCode,获得第一目标hashCode;
    获取所述第一目标hashCode的hash槽,得到第一目标hash槽;
    将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
  5. 根据权利要求1所述的物联网消息队列IoT-MQ的消息存储方法,其特征在于,在所述将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽的步骤之后,包括:
    接收获取IoT-MQ的消息的请求,其中所述请求包括key和时间戳;
    将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得第二目标hashCode;
    根据所述hashCode对应关系表,在消息库中查找与所述第二目标hashCode对应的hashCode,获得第三目标hashCode;
    获取所述第三目标hashCode的hash槽,得到目标hash槽;
    判断所述时间戳是否为空值;
    若所述时间戳为空值,则将所述目标hash槽中的全部消息返回给所述请求的发起方;
    若所述时间戳不为空值,则将所述目标hash槽中的与所述时间戳对应的消息返回给所述请求的发起方。
  6. 根据权利要求5所述的物联网消息队列IoT-MQ的消息存储方法,其特征在于,在所述若所述时间戳不为空值,则将所述目标hash槽中的与所述时间戳对应的消息返回给所述请求的发起方的步骤中,包括:
    若所述时间戳不为空值,则从所述目标hash槽中的消息列表的头部开始查找与所述时间戳对应的存储时间;
    当查找到与所述时间戳对应的存储时间时,获取查找到的存储时间对应的消息;
    将获取到对应的消息返回给所述请求的发起方。
  7. 根据权利要求1所述的物联网消息队列IoT-MQ的消息存储方法,其特征在于,在所述将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽的步骤之后,包括:
    接收用户输入的有效存储时间;
    获取每一hash槽的各消息的存储时间;
    判断各消息的存储时间是否在所述有效存储时间内;
    若判断出各消息的中存在存储时间不在所述有效存储时间内,则获取存储时间不在所述有效存储时间内的消息,获得目标消息;
    将所述目标消息从对应的hash槽删除。
  8. 一种物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述装置包括:
    建立关系表模块,用于建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;
    标记模块,用于对每一条IoT-MQ的消息添加标记,获得多个第一标记;
    计算模块,用于将所述多个第一标记中每一个第一标记作为key输入到预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;
    查找模块,用于根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;
    存储模块,用于将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
  9. 根据权利要求8所述的物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述装置包括:
    第一识别模块,用于识别每一条IoT-MQ的消息所属的设备;
    第一获取模块,用于根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID;
    对应地,所述标记模块包括:
    设备ID标记模块,用于将每一条IoT-MQ的消息所属的设备对应的设备ID作为标记;
    第一子标记模块,用于对每一条IoT-MQ的消息添加对应的标记,获得多个第一标记。
  10. 根据权利要求8所述的物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述存储模块包括:
    第一子存储模块,用于将所述IoT-MQ的消息按存储时间先后顺序存入对应的hash槽中的消息列表。
  11. 根据权利要求8所述的物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述装置包括:
    第一接收模块,用于接收获取IoT-MQ的消息的请求,其中所述请求包括key;
    第一计算模块,用于将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得目标hashCode;
    第一查找模块,用于根据所述hashCode对应关系表,在消息库中查找与所述目标hashCode对应的hashCode,获得第一目标hashCode;
    第一获得模块,用于获取所述第一目标hashCode的hash槽,得到第一目标hash槽;
    第一返回模块,用于将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
  12. 根据权利要求8所述的物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述装置包括:
    第二接收模块,用于接收获取IoT-MQ的消息的请求,其中所述请求包括key和时间戳;
    第三计算模块,用于将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得第二目标hashCode;
    第三查找模块,用于根据所述hashCode对应关系表,在消息库中查找与所述第二目标hashCode对应的hashCode,获得第三目标hashCode;
    第二获得模块,用于获取所述第三目标hashCode的hash槽,得到目标hash槽;
    第二判断模块,用于判断所述时间戳是否为空值;
    第三返回模块,用于若所述时间戳为空值,则将所述目标hash槽中的全部消息返回给所述请求的发起方;
    第四返回模块,用于若所述时间戳不为空值,则将所述目标hash槽中的与所述时间戳对应的消息返回给所述请求的发起方。
  13. 根据权利要求12所述的物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述第四返回模块包括:
    第一子查找模块,用于若所述时间戳不为空值,则从所述目标hash槽中的消息列表的头部开始查找与所述时间戳对应的存储时间;
    第一子获取模块,用于当查找到与所述时间戳对应的存储时间时,获取查找到的存储时间对应的消息;
    第一子返回模块,用于将获取到对应的消息返回给所述请求的发起方。
  14. 根据权利要求8所述的物联网消息队列IoT-MQ的消息存储装置,其特征在于,所述装置包括:
    第四接收模块,用于接收用户输入的有效存储时间;
    第五获取模块,用于获取每一hash槽的各消息的存储时间;
    第三判断模块,用于判断各消息的存储时间是否在所述有效存储时间内;
    第六获取模块,用于若判断出各消息的中存在存储时间不在所述有效存储时间内,则获取存储时间不在所述有效存储时间内的消息,获得目标消息;
    第一删除模块,用于将所述目标消息从对应的hash槽删除。
  15. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其特征在于,所述处理器执行所述计算机程序时实现物联网消息队列IoT-MQ的消息存储方法,所述方法包括:
    建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;
    对每一条IoT-MQ的消息添加标记,获得多个第一标记;
    将所述多个第一标记中每一个第一标记作为key输入到所述预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;
    根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;
    将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
  16. 根据权利要求1所述的计算机设备,其特征在于,在所述根据所述对每一条IoT-MQ的消息添加标记,获得多个第一标记的步骤之前,包括:
    识别每一条IoT-MQ的消息所属的设备;
    根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID;
    在所述根据所述对每一条IoT-MQ的消息添加标记,获得多个第一标记的步骤中,包括:
    将每一条IoT-MQ的消息所属的设备对应的设备ID作为标记;
    对每一条IoT-MQ的消息添加对应的标记,获得多个第一标记。
  17. 根据权利要求1所述的计算机设备,其特征在于,在所述将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽的步骤中,包括:
    将所述IoT-MQ的消息按存储时间先后顺序存入对应的hash槽中的消息列表。
  18. 根据权利要求1所述的计算机设备,其特征在于,在所述将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽的步骤之后,包括:
    接收获取IoT-MQ的消息的请求,其中所述请求包括key;
    将所述请求中的key输入到所述预设hash算法中计算,计算出所述请求中的key对应的hashCode,获得目标hashCode;
    根据所述hashCode对应关系表,在消息库中查找与所述目标hashCode对应的hashCode,获得第一目标hashCode;
    获取所述第一目标hashCode的hash槽,得到第一目标hash槽;
    将所述第一目标hash槽中的全部消息返回给所述请求的发起方。
  19. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现物联网消息队列IoT-MQ的消息存储方法,所述方法包括:
    建立hashCode对应关系表,所述hashCode对应关系表中存储通过预设hash算法计算所得的hashCode与用于确定在消息库存储位置的hashCode的对应关系;
    对每一条IoT-MQ的消息添加标记,获得多个第一标记;
    将所述多个第一标记中每一个第一标记作为key输入到所述预设hash算法中计算,计算出每一个所述第一标记对应的第一hashCode;
    根据所述hashCode对应关系表,在消息库中查找与每一个所述第一hashCode对应的第二hashCode,所述消息库为分布式的消息库;
    将对应不同所述第一hashCode的IoT-MQ的消息分别存储到与各所述第一hashCode对应的第二hashCode的hash槽。
  20. 根据权利要求19所述的计算机可读存储介质,其特征在于,在所述根据所述对每一条IoT-MQ的消息添加标记,获得多个第一标记的步骤之前,包括:
    识别每一条IoT-MQ的消息所属的设备;
    根据识别出每一条IoT-MQ的消息所属的设备,获取每一条IoT-MQ的消息所属的设备对应的设备ID;
    在所述根据所述对每一条IoT-MQ的消息添加标记,获得多个第一标记的步骤中,包括:
    将每一条IoT-MQ的消息所属的设备对应的设备ID作为标记;
    对每一条IoT-MQ的消息添加对应的标记,获得多个第一标记。
PCT/CN2019/118172 2019-05-13 2019-11-13 IoT-MQ 的消息存储方法、装置、计算机设备和存储介质 WO2020228287A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910394580X 2019-05-13
CN201910394580.XA CN110245028B (zh) 2019-05-13 2019-05-13 IoT-MQ的消息存储方法、装置、计算机设备和存储介质

Publications (1)

Publication Number Publication Date
WO2020228287A1 true WO2020228287A1 (zh) 2020-11-19

Family

ID=67884275

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118172 WO2020228287A1 (zh) 2019-05-13 2019-11-13 IoT-MQ 的消息存储方法、装置、计算机设备和存储介质

Country Status (2)

Country Link
CN (1) CN110245028B (zh)
WO (1) WO2020228287A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112769924A (zh) * 2020-12-31 2021-05-07 平安科技(深圳)有限公司 RocketMQ的分布式部署方法、装置、设备及介质
CN115065647A (zh) * 2022-06-20 2022-09-16 中银金融科技有限公司 一种数据计算方法、装置及电子设备

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110245028B (zh) * 2019-05-13 2023-08-25 平安科技(深圳)有限公司 IoT-MQ的消息存储方法、装置、计算机设备和存储介质
CN110928609B (zh) * 2020-01-20 2020-06-16 武汉斗鱼鱼乐网络科技有限公司 一种标记设备的方法、装置、介质及计算机设备

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103761141A (zh) * 2013-12-13 2014-04-30 北京奇虎科技有限公司 一种实现消息队列的方法及装置
CN104536958A (zh) * 2014-09-26 2015-04-22 杭州华为数字技术有限公司 一种复合索引方法,及装置
CN105516367A (zh) * 2016-02-02 2016-04-20 北京百度网讯科技有限公司 分布式数据存储系统、方法和装置
US9652310B1 (en) * 2013-09-30 2017-05-16 EMC IP Holding Company LLC Method and apparatus for using consistent-hashing to ensure proper sequencing of message processing in a scale-out environment
CN108833438A (zh) * 2018-07-18 2018-11-16 电子科技大学 一种基于区块链的工业物联网信息安全存储方法
CN109274730A (zh) * 2018-09-04 2019-01-25 上海联寓智能科技有限公司 物联网系统、mqtt消息传输的优化方法及装置
CN110245028A (zh) * 2019-05-13 2019-09-17 平安科技(深圳)有限公司 IoT-MQ的消息存储方法、装置、计算机设备和存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120110343A1 (en) * 2010-10-29 2012-05-03 Bandic Zvonimir Z Trustworthy timestamps on data storage devices
CN103503388B (zh) * 2011-09-01 2016-08-03 华为技术有限公司 一种分布式队列消息读取方法及设备、系统
US9043334B2 (en) * 2012-12-26 2015-05-26 Industrial Technology Research Institute Method and system for accessing files on a storage system
US10230681B2 (en) * 2015-12-14 2019-03-12 International Business Machines Corporation Method and apparatus for unified message adaptation
CN106055630A (zh) * 2016-05-27 2016-10-26 北京小米移动软件有限公司 日志存储的方法及装置
CN109739930A (zh) * 2018-12-19 2019-05-10 平安普惠企业管理有限公司 基于分布式缓存系统的数据存储方法、装置、计算机设备

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9652310B1 (en) * 2013-09-30 2017-05-16 EMC IP Holding Company LLC Method and apparatus for using consistent-hashing to ensure proper sequencing of message processing in a scale-out environment
CN103761141A (zh) * 2013-12-13 2014-04-30 北京奇虎科技有限公司 一种实现消息队列的方法及装置
CN104536958A (zh) * 2014-09-26 2015-04-22 杭州华为数字技术有限公司 一种复合索引方法,及装置
CN105516367A (zh) * 2016-02-02 2016-04-20 北京百度网讯科技有限公司 分布式数据存储系统、方法和装置
CN108833438A (zh) * 2018-07-18 2018-11-16 电子科技大学 一种基于区块链的工业物联网信息安全存储方法
CN109274730A (zh) * 2018-09-04 2019-01-25 上海联寓智能科技有限公司 物联网系统、mqtt消息传输的优化方法及装置
CN110245028A (zh) * 2019-05-13 2019-09-17 平安科技(深圳)有限公司 IoT-MQ的消息存储方法、装置、计算机设备和存储介质

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112769924A (zh) * 2020-12-31 2021-05-07 平安科技(深圳)有限公司 RocketMQ的分布式部署方法、装置、设备及介质
CN112769924B (zh) * 2020-12-31 2022-04-15 平安科技(深圳)有限公司 RocketMQ的分布式部署方法、装置、设备及介质
CN115065647A (zh) * 2022-06-20 2022-09-16 中银金融科技有限公司 一种数据计算方法、装置及电子设备
CN115065647B (zh) * 2022-06-20 2024-04-16 中银金融科技有限公司 一种数据计算方法、装置及电子设备

Also Published As

Publication number Publication date
CN110245028A (zh) 2019-09-17
CN110245028B (zh) 2023-08-25

Similar Documents

Publication Publication Date Title
WO2020228287A1 (zh) IoT-MQ 的消息存储方法、装置、计算机设备和存储介质
CN106100902B (zh) 云端指标监控方法和装置
WO2020119430A1 (zh) 协议接口测试方法、装置、计算机设备和存储介质
CN110569214B (zh) 用于日志文件的索引构建方法、装置及电子设备
WO2019218475A1 (zh) 异常行为对象的识别方法、装置、终端设备及介质
US10592327B2 (en) Apparatus, system, and method for analyzing logs
CN111881011A (zh) 日志管理方法、平台、服务器及存储介质
JP2020057416A (ja) 分散データベースにおけるデータブロックを処理する方法およびデバイス
CN110147470B (zh) 一种跨机房数据比对系统及方法
WO2022068540A1 (zh) 一种数据库状态的确定方法及装置、设备、存储介质
CN111258956B (zh) 一种面向远端海量数据文件预读的方法及设备
CN107085568A (zh) 一种文本相似度判别方法及装置
CN111708942A (zh) 多媒体资源推送方法、装置、服务器及存储介质
US8732323B2 (en) Recording medium storing transaction model generation support program, transaction model generation support computer, and transaction model generation support method
CN110717130B (zh) 打点方法、装置、终端及存储介质
CN111930753A (zh) 一种数据找回方法、装置、电子设备及存储介质
CN106096804B (zh) 一种智能电网调度控制系统模型维护全过程的监视方法
CN110347726A (zh) 一种高效时序数据集成存储查询系统及方法
CN108763291B (zh) 一种数据管理方法、装置及电子设备
US20120239656A1 (en) Information processing apparatus, message classifying method and non-transitory medium
CN110515923B (zh) 一种分布式数据库之间的数据迁移方法和系统
CN109710673B (zh) 作品处理方法、装置、设备和介质
CN108509328B (zh) 数据库校验方法及装置
CN111723146A (zh) 监测数据库的方法、管理系统及存储介质
CN114265739A (zh) 数据处理方法、装置、设备及存储介质

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: 19928601

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: 19928601

Country of ref document: EP

Kind code of ref document: A1