CN113986942B - Message queue management method and device based on man-machine conversation - Google Patents

Message queue management method and device based on man-machine conversation Download PDF

Info

Publication number
CN113986942B
CN113986942B CN202111615512.5A CN202111615512A CN113986942B CN 113986942 B CN113986942 B CN 113986942B CN 202111615512 A CN202111615512 A CN 202111615512A CN 113986942 B CN113986942 B CN 113986942B
Authority
CN
China
Prior art keywords
data
priority value
mongodb
priority
redis
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.)
Active
Application number
CN202111615512.5A
Other languages
Chinese (zh)
Other versions
CN113986942A (en
Inventor
王士祥
曾文佳
陈新月
宋成业
冯梦盈
梁鹏斌
李航
韩亚昕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lingxi Beijing Technology Co Ltd
Original Assignee
Lingxi Beijing Technology Co Ltd
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 Lingxi Beijing Technology Co Ltd filed Critical Lingxi Beijing Technology Co Ltd
Priority to CN202111615512.5A priority Critical patent/CN113986942B/en
Publication of CN113986942A publication Critical patent/CN113986942A/en
Application granted granted Critical
Publication of CN113986942B publication Critical patent/CN113986942B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/23Updating
    • G06F16/235Update request formulation
    • 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/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • 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/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2445Data retrieval commands; View definitions
    • 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
    • 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
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Abstract

The application provides a message queue management method and device based on man-machine conversation, which are used for solving the problem that data are difficult to delete according to a priority condition. The method comprises the following steps: acquiring a data deletion request, wherein the data deletion request comprises a first priority value; generating a conditional query statement according to the first priority value; inquiring a first data identifier corresponding to the condition inquiry statement in a database, wherein the database stores the corresponding relation between the data identifier and the priority value; and deleting the data record corresponding to the first data identifier in the ordered set of Redis, wherein the data record is stored in the Redis by taking the data identifier as a key and taking the priority value as a specific value.

Description

Message queue management method and device based on man-machine conversation
Technical Field
The application relates to the technical field of computer message queues and queue management, in particular to a message queue management method and device based on man-machine conversation.
Background
Priority Queue (Priority Queue), is a data structure in which elements are given Priority. A normal queue is a first-in-first-out data structure, with elements appended at the end of the queue and removed from the head of the queue. When accessing elements, the element with the highest priority is First deleted, so the priority queue has the behavior characteristic of First In (First Out).
At present, an outbound system needs to process several million tasks such as outbound calls, short messages and the like every day, the outbound system has limited concurrency capability, and needs to queue to execute each task, and each task is executed according to the priority from high to low, so that a RabbitMQ is usually used as a priority queue to complete the execution of each task, and the RabbitMQ is open-source message agent software (also called message-oriented middleware) for realizing a high-level message queue protocol. However, in a specific practical process, it is found that in some special cases, data needs to be deleted according to a priority condition, but the deletion of the data according to the priority condition is difficult to realize by using the RabbitMQ as a priority queue.
Disclosure of Invention
An object of the embodiments of the present application is to provide a message queue management method and device based on human-computer interaction, which are used to solve the problem that it is difficult to delete data according to a priority condition.
The embodiment of the application provides a message queue management method based on man-machine conversation, which comprises the following steps: acquiring a data deletion request, wherein the data deletion request comprises a first priority value; generating a conditional query statement according to the first priority value; inquiring a first data identifier corresponding to the condition inquiry statement in a database, wherein the database stores the corresponding relation between the data identifier and the priority value; and deleting the data record corresponding to the first data identifier in the ordered set of Redis, wherein the data record is stored in the Redis by taking the data identifier as a key and taking the priority value as a specific value. In the implementation process, the database is used for storing the corresponding relation between the data identifier and the priority value, the data identifier corresponding to the priority value can be obtained in the database, and the ordered set of Redis is used as the priority queue, so that the data record corresponding to the data identifier can be deleted in the ordered set of Redis, the condition that the data cannot be deleted according to the priority condition by using the RabbitMQ as the priority queue is avoided, and the function of deleting the data in the priority queue according to the priority condition is realized.
Optionally, in this embodiment of the present application, the data deletion request further includes: a first data attribute; generating a conditional query statement according to the first priority value, comprising: analyzing a first priority value and a first data attribute from the data deletion request; and splicing the first priority value and the first data attribute to obtain a conditional query statement.
Optionally, in an embodiment of the present application, the database includes: MongoDB; inquiring a first data identifier corresponding to the conditional query statement in a database, wherein the first data identifier comprises: and executing the conditional query statement in the MongoDB to obtain a query result returned by the MongoDB, wherein the query result comprises a data identifier corresponding to the conditional query statement. In the implementation process, MongoDB is used as an executor of the conditional query statement needing to operate data, the MongoDB executes the conditional query statement to obtain a query result returned by the MongoDB, and therefore the execution speed of the conditional query statement is effectively improved.
Optionally, in the embodiments of the present application, the ordered set is a ZSet; deleting the data record corresponding to the first data identifier in the ordered set of Redis, wherein the deleting comprises the following steps: all data records identified by keys for data are deleted in the ZSet of Redis.
Optionally, in an embodiment of the present application, the method further includes: acquiring a data insertion request; analyzing a second priority value and a second data attribute from the data insertion request, and generating a data insertion statement according to the second priority value and the second data attribute; and executing a data insertion statement in the MongoDB to obtain an insertion result returned by the MongoDB, wherein the insertion result represents whether the insertion is successful under the unique index constraint of the data attribute. In the implementation process, the unique index constraint of the data attribute is set in the MongoDB, so that the data in the message queue can be effectively subjected to the operations of duplicate removal and the like.
Optionally, in an embodiment of the present application, the insertion result includes: the insertion state and the second data identification; after obtaining the insertion result returned by the MongoDB, the method further comprises the following steps: judging whether the insertion state is successful; and if so, storing the second data identifier as a key into the ordered set of Redis in a mode of taking the second priority value as a specific value.
Optionally, in an embodiment of the present application, the method further includes: acquiring a data updating request; analyzing a third priority value and a third data attribute from the data updating request, and generating a data updating statement according to the third priority value and the third data attribute; and executing a data updating statement in the MongoDB to obtain an updating result returned by the MongoDB, wherein the updating result represents whether the updating is successful under the unique index constraint of the data attribute. In the implementation process, a third priority value and a third data attribute are analyzed from the data updating request, and a data updating statement is generated according to the third priority value and the third data attribute; and executing a data updating statement in the MongoDB to obtain an updating result returned by the MongoDB, thereby realizing the function of updating data in the MongoDB.
The embodiment of the present application further provides a message queue management device based on human-computer interaction, including: the device comprises a deletion request acquisition module, a data deletion request processing module and a data deletion processing module, wherein the deletion request acquisition module is used for acquiring a data deletion request which comprises a first priority value; the query statement generating module is used for generating a conditional query statement according to the first priority value; the data identifier query module is used for querying a first data identifier corresponding to the condition query statement in a database, and the database stores the corresponding relation between the data identifier and the priority value; and the data record deleting module is used for deleting the data record corresponding to the first data identifier in the ordered set of Redis, wherein the data record is stored in the Redis by taking the data identifier as a key and taking the priority value as a specific value.
Optionally, in this embodiment of the present application, the data deletion request further includes: a first data attribute; a query statement generation module comprising: the deletion request analysis module is used for analyzing a first priority value and a first data attribute from the data deletion request; and the query statement obtaining module is used for splicing the first priority value and the first data attribute to obtain the conditional query statement.
Optionally, in an embodiment of the present application, the database includes: MongoDB; a data identification query module comprising: and the query result obtaining module is used for executing the conditional query statement in the MongoDB and obtaining a query result returned by the MongoDB, wherein the query result comprises a data identifier corresponding to the conditional query statement.
Optionally, in the embodiments of the present application, the ordered set is a ZSet; a data record deletion module comprising: all data records identified by keys for data are deleted in the ZSet of Redis.
Optionally, in this embodiment of the present application, the message queue management apparatus based on human-computer interaction further includes: the insertion request acquisition module is used for acquiring a data insertion request; the insertion statement generation module is used for analyzing a second priority value and a second data attribute from the data insertion request and generating a data insertion statement according to the second priority value and the second data attribute; and the insertion result obtaining module is used for executing a data insertion statement in the MongoDB and obtaining an insertion result returned by the MongoDB, wherein the insertion result represents whether the insertion is successful under the unique index constraint of the data attribute.
Optionally, in an embodiment of the present application, the insertion result includes: the insertion state and the second data identification; the message queue management device based on man-machine conversation further comprises: the insertion state judging module is used for judging whether the insertion state is successful or not; and the data record storage module is used for storing the second data identifier as a key into the ordered set of Redis in a form of taking the second priority value as a specific value if the insertion state is successful.
Optionally, in this embodiment of the present application, the message queue management apparatus based on human-computer interaction further includes: the updating request acquisition module is used for acquiring a data updating request; the update statement generation module is used for analyzing a third priority value and a third data attribute from the data update request and generating a data update statement according to the third priority value and the third data attribute; and the updating structure obtaining module is used for executing a data updating statement in the MongoDB and obtaining an updating result returned by the MongoDB, wherein the updating result represents whether the updating is successful under the unique index constraint of the data attribute.
An embodiment of the present application further provides an electronic device, including: a processor and a memory, the memory storing processor-executable machine-readable instructions, the machine-readable instructions when executed by the processor performing the method as described above.
Embodiments of the present application also provide a computer-readable storage medium having a computer program stored thereon, where the computer program is executed by a processor to perform the method as described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic flow chart illustrating a data deletion process in a man-machine conversation based message queue management method according to an embodiment of the present application;
fig. 2 is a schematic flow chart illustrating a data insertion process in a man-machine conversation-based message queue management method according to an embodiment of the present application;
fig. 3 is a schematic flow chart illustrating a data updating process in a man-machine conversation-based message queue management method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a message queue management device based on human-machine conversation according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, as presented in the figures, is not intended to limit the scope of the embodiments of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments obtained by a person skilled in the art based on the embodiments of the present application without any creative effort belong to the protection scope of the embodiments of the present application.
Before introducing the man-machine conversation-based message queue management method provided in the embodiment of the present application, some concepts related in the embodiment of the present application are introduced:
redis (remote Dictionary Server), a remote Dictionary service, is an open-source, network-supported, memory-based, distributed, and optionally persistent key-value pair storage database written using ANSI C. There are a wide variety of value types that Redis supports storage, including but not limited to: string (String), linked List (List), Set (Set), ordered Set (Sorted Set, ZSet for short), and Hash type (Hash).
A DataBase (DataBase, DB) which is a collection for storing electronic data or electronic files, and in short, can be regarded as an electronic file cabinet, and a user can perform operations such as adding, intercepting, updating, and deleting on data in a file; the database is a collection of data that is stored together in a manner that can be shared by multiple users, has as little redundancy as possible, and is independent of the application.
Structured Query Language (SQL) is a special purpose programming Language, and is also a Database Query and programming Language for accessing data and querying, updating, and managing Relational Database Management systems (RDBMS), or processing in Relational flow data Management systems (RDSMS).
It should be noted that the message queue management method based on human-computer interaction provided in the embodiment of the present application may be executed by an electronic device, where the electronic device refers to a device terminal having a function of executing a computer program or the server described above, and the device terminal includes, for example: a smart phone, a personal computer, a tablet computer, a personal digital assistant, or a mobile internet device, etc. The server is for example: x86 server and non-x 86 server, non-x 86 server includes: mainframe, minicomputer, and UNIX server.
Application scenarios applicable to the man-machine conversation based message queue management method are described below, where the application scenarios include but are not limited to: the message queue management method based on the man-machine conversation is used for managing the message queue in the outbound scene, so that the data in the message queue can be deleted according to the priority condition, the data in the message queue can be effectively removed from duplicate, and the like, and the function of the priority message queue can be enhanced by using the message queue management method based on the man-machine conversation, so that the requirements of the message queue in more application scenes can be met.
Please refer to fig. 1, which is a schematic flow chart of a data deletion process in a message queue management method based on human-machine interaction according to an embodiment of the present application; the main idea of the message queue management method based on the man-machine conversation is that the corresponding relation between the data identification and the priority value is stored through the database, the data identification corresponding to the priority value can be obtained in the database, and the ordered set of Redis is used as the priority queue, so that the data record corresponding to the data identification can be deleted in the ordered set of Redis, the condition that the data cannot be deleted according to the priority condition by using the RabbitMQ as the priority queue is avoided, and the function of deleting the data in the priority queue according to the priority condition is realized. The message queue management method based on man-machine conversation can comprise the following steps: data deletion, data insertion, data update and the like, the following respectively describes a man-machine conversation based message queue management method in the order of data deletion, data insertion and data update, and firstly describes a data deletion process as follows:
step S110: the electronic equipment acquires a data deletion request, wherein the data deletion request comprises a first priority value.
The Data Delete Request (Data Delete Request) refers to a Request for deleting Data corresponding to the same Data identifier in the ordered set of the database and the Redis, and the Data Delete Request may include: a priority value and a data attribute. In a specific practical process, a score field of ZSet in Redis may be used to store a priority value, and a Key corresponding to the score field stores a data Identification (ID), so that the ZSet score characteristic of Redis utilized to implement the sorting of priorities.
The embodiment of step S110 described above is, for example: the terminal device sends a data deletion request to the electronic device through a hypertext Transfer Protocol (HTTP) or a Hypertext Transfer Protocol Security (HTTPs). Then, the electronic device receives the data deletion request sent by the terminal device through the HTTP protocol or the HTTPs protocol. The data deletion request may include a first priority value, although the data deletion request may include other data attributes. Taking the outbound scenario as an example, with the priority of the outbound client as the priority value, assuming high (indicated by 5), medium (indicated by 3) and low (indicated by 1), the phone number of each client can be used as the data identifier, and other data attributes such as: name, age, and industry, etc.
It can be understood that the data identifier in the embodiment of the present application may be generated by using a snowflow algorithm, which not only can ensure that the data is executed according to the order of priorities, but also can ensure that the data is executed according to the time sequence when the data identifier is executed under the condition of the same priority.
After step S110, step S120 is performed: the electronic device generates a conditional query statement according to the first priority value in the data deletion request.
The above step S120 can be implemented in various ways, including but not limited to:
in a first embodiment, data is deleted only by the first priority value, for example: the electronic device parses the first priority value from the data deletion request. And the electronic equipment splices and encapsulates the first priority value to obtain a conditional query statement, wherein the conditional query statement is used for querying the data identifier of the data to be deleted. It is understood that the format of the concatenation and packaging is specifically determined according to a database, the database may be selected from a relational database or a non-relational database, taking the relational database as an example, if the first priority value is low, the priority may be represented as priority =1, and the SQL statements used by the concatenation and packaging to form the relational database are, for example: select from priority wheel priority = 1; wherein, priority refers to the name of the data table in the relational database, and priority =1 indicates that the data with the first priority value at the low level is filtered out.
In a second embodiment, data is deleted by the first priority value and the first data attribute, for example: it is to be understood that the data deletion request may further include: a first data attribute; as described above, taking the calling scenario as an example, the first data attribute here is, for example: name, age, and industry, etc. The electronic device parses the first priority value and the first data attribute from the data deletion request. The electronic device splices and encapsulates the first priority value and the first data attribute to obtain a conditional query statement, where the conditional query statement is used to query a data identifier that needs to delete data, and the specific manner refers to the first embodiment, and the technical principle is similar, so that details are not repeated. The difference is. It will be appreciated that the first priority value and the first data attribute form a plurality of conditions, which may be connected by logical operators, and then form a conditional query statement.
In the third embodiment, data is deleted by using the first priority value and the plurality of data attributes, the technical principle of this embodiment is similar to that of the second embodiment, and for a specific way, reference is made to the second embodiment, and the technical principle is similar, so that details are not repeated. In a specific practical process, if a non-relational database (e.g., MongoDB) is used, the first priority value and the first data attribute should be encapsulated as a conditional query statement in the format required by MongoDB.
After step S120, step S130 is performed: the electronic equipment queries a first data identifier corresponding to the condition query statement in a database, and the database stores the corresponding relation between the data identifier and the priority value.
In a specific practical process, the database can be a relational database or a non-relational database; relational databases that can be used are for example: mysql, PostgreSQL, Oracle, SQLSever, etc.; non-relational databases that may be used include: grakn database, Neo4j database, Hadoop subsystem HBase, MongoDB and CouchDB, etc. For ease of understanding and explanation, the following description will be made in detail using the MongoDB database as an example.
The embodiment of step S130 described above is, for example: it is understood that the MongoDB database may store the correspondence between the data identifier and the priority value and the correspondence between the data identifier and the other data attribute in advance, that is, the MongoDB stores the data representation, the priority value and the other data attribute in the same data set (corresponding to the data table in the relational database). Therefore, the conditional query statement can be executed in the MongoDB, and a query result returned by the MongoDB is obtained, wherein the query result comprises the data identifier corresponding to the conditional query statement.
After step S130, step S140 is performed: and the electronic equipment deletes the data record corresponding to the first data identifier in the ordered set of Redis, wherein the data record is stored in the Redis by taking the data identifier as a key and taking the priority value as a specific value.
The embodiment of step S140 described above is, for example: in particular practice, ordered sets that may be used include, but are not limited to: ZSet in Redis, etc.; distributed locks may also be added when inserting and taking data from a ZSet in Redis, thus ensuring atomic operations of synchronous insertion and taking in the Redis and database (e.g., MongoDB) for each piece of data. Deleting the data records with all keys as data identifications in the Zset of Redis, wherein the data records are stored in Redis with the data identifications as keys (namely keys) and with the priority values as specific values (namely values).
In the implementation process, firstly, a conditional query statement is generated according to a first priority value, then, a first data identifier corresponding to the conditional query statement is queried in a database (e.g., MongoDB), and finally, a data record corresponding to the first data identifier is deleted in a priority queue (e.g., ZSet of Redis). Data Identification (ID) and priority value are stored in both Redis and MongoDB, but the roles of the data Identification (ID) and the priority value stored in the Redis and the MongoDB are not the same, the data Identification (ID) and the priority value in the Redis are used for determining the order of data processing (namely consumption or consumption), and the data Identification (ID) and the priority value stored in the MongoDB are used as conditions for screening out the data needing to be deleted.
That is to say, the database is used for storing the corresponding relationship between the data identifier and the priority value, the data identifier corresponding to the priority value can be obtained in the database, and the ordered set of the Redis is used as the priority queue, so that the data record corresponding to the data identifier can be deleted in the ordered set of the Redis, the condition that the data cannot be deleted according to the priority condition by using the RabbitMQ as the priority queue is avoided, and the function of deleting the data in the priority queue according to the priority condition is realized.
Please refer to fig. 2, which is a schematic flow chart illustrating a data insertion process in a man-machine conversation-based message queue management method according to an embodiment of the present application; the data deletion process is described above, followed by the data insertion process, which may include:
step S210: the electronic device obtains a data insertion request.
The embodiment of step S210 described above is, for example: the electronic equipment receives a data insertion request sent by the terminal equipment through an HTTP protocol or an HTTPS protocol.
After step S210, step S220 is performed: the electronic device parses the second priority value and the second data attribute from the data insertion request, and generates a data insertion statement according to the second priority value and the second data attribute.
After step S220, step S230 is performed: the electronic equipment executes a data insertion statement in the MongoDB and obtains an insertion result returned by the MongoDB.
Wherein, the insertion result includes: an insertion status and a second data identification.
The embodiment of the step S230 is, for example: the only index can be set in advance in the MongoDB required to be deduplicated in the MongoDB on the electronic equipment, and when data is inserted into the MongoDB, if the data of the repeated field is inserted, the data cannot be successfully inserted. Specifically, the electronic device executes a data insertion statement in the mongoDB, the MongoDB returns a return result of whether the unique index rule is violated, if the unique index rule is violated, the data is not allowed to be inserted, and the insertion result is failure; and if the unique index rule is not violated, allowing data to be inserted, wherein the insertion result is successful, obtaining the insertion result returned by the MongoDB, and representing whether the data is successfully inserted under the unique index constraint of the data attribute.
It will be appreciated that unique indices do not allow rows with the same index value, thereby prohibiting duplicate indices or key values. The unique index is used to ensure that the index field does not store duplicate values, i.e., to enforce uniqueness of the index field. MongoDB checks if there are duplicate keys when creating the index, and checks each time insert (insert) data or update (update) data is used. Therefore, the MongoDB unique index can be used for effectively removing the duplicate of the data.
Optionally, after obtaining the insertion result returned by the MongoDB, the method further includes:
after step S230, step S240 is performed: the electronic device determines whether the insertion status is successful.
After step S240, step S250 is performed: and if the inserting state is successful, the second data identifier is used as a key, and the second priority value is stored into the ordered set of Redis in a specific value mode.
After step S240, step S260 is performed: if the insertion state is failure, the execution of the output data insertion request fails.
The above embodiments of step S240 to step S260 are, for example: the electronic equipment judges whether the insertion state is successful; if the insertion state is successful, the second data identifier is used as a key, and the second priority value is stored into the ordered set zset of Redis in a specific value form; if the insertion state is failure, the execution of the output data insertion request fails, which means that the data corresponding to the index field is repeated, and the data is not allowed to enter Redis. In a specific implementation process, data operations of the MongoDB and the Redis can be bound as atomic operations, and the MongoDB and the Redis can be implemented in a mode of adding distributed locks.
In the implementation process, the unique index constraint of the data attribute is set in the MongoDB, so that the data in the message queue can be effectively subjected to the operations of duplicate removal and the like. And the MongoDB and the Redis are locked to realize that the data operation of the MongoDB and the Redis is bound into the atomic operation, so that the data consistency of the MongoDB and the Redis is effectively ensured.
Please refer to fig. 3, which is a schematic flow chart illustrating a data updating process in a man-machine conversation based message queue management method according to an embodiment of the present application; the data insertion process is described above, followed by the data update process, which may include:
step S310: the electronic device obtains a data update request.
The embodiment of step S310 described above is, for example: the electronic device obtains a data update (update) request through an HTTP protocol or an HTTPs protocol.
After step S310, step S320 is performed: the electronic equipment analyzes the data identifier, the third priority value and the third data attribute from the data updating request, and generates a data updating statement according to the data identifier, the third priority value and the third data attribute.
After step S320, step S330 is performed: the electronic equipment executes a data updating statement in the MongoDB to obtain an updating result returned by the MongoDB.
After step S330, step S340 is performed: and the electronic equipment updates the third priority value corresponding to the data identification in the Zset of Redis according to the updating result.
The embodiments of the above steps S320 to S340 are, for example: the electronic equipment analyzes the data identification, the third priority value and the third data attribute from the data updating request, generates a data updating statement according to the data identification, the third priority value and the third data attribute, executes the data updating statement in the MongoDB to obtain an updating result returned by the MongoDB, and the updating result represents whether the updating is successful under the unique index constraint of the data attribute. If the updating result is successful, updating a third priority value corresponding to the data identifier in the Zset of Redis; correspondingly, if the updating result is failure, the data updating statement is executed in the MongoDB again, and the updating result returned by the MongoDB is obtained.
In the implementation process, a third priority value and a third data attribute are analyzed from the data updating request, and a data updating statement is generated according to the third priority value and the third data attribute; and executing a data updating statement in the MongoDB to obtain an updating result returned by the MongoDB, thereby realizing the function of updating data in the MongoDB.
Please refer to fig. 4, which is a schematic structural diagram of a message queue management device based on human-machine interaction according to an embodiment of the present application; the embodiment of the present application provides a message queue management device 400 based on human-computer interaction, including:
a delete request obtaining module 410, configured to obtain a data delete request, where the data delete request includes a first priority value.
And a query statement generating module 420, configured to generate a conditional query statement according to the first priority value.
The data identifier query module 430 is configured to query a database for a first data identifier corresponding to the conditional query statement, where the database stores a corresponding relationship between the data identifier and the priority value.
And the data record deleting module 440 is configured to delete a data record corresponding to the first data identifier in the ordered set of Redis, where the data record is stored in the Redis with the data identifier as a key and the priority value as a specific value.
Optionally, in this embodiment of the present application, the data deletion request further includes: a first data attribute; a query statement generation module comprising:
and the deletion request analysis module is used for analyzing the first priority value and the first data attribute from the data deletion request.
And the query statement obtaining module is used for splicing the first priority value and the first data attribute to obtain the conditional query statement.
Optionally, in an embodiment of the present application, the database includes: MongoDB; a data identification query module comprising:
and the query result obtaining module is used for executing the conditional query statement in the MongoDB and obtaining a query result returned by the MongoDB, wherein the query result comprises a data identifier corresponding to the conditional query statement.
Optionally, in the embodiments of the present application, the ordered set is a ZSet; a data record deletion module comprising:
all data records identified by keys for data are deleted in the ZSet of Redis.
Optionally, in this embodiment of the present application, the message queue management apparatus based on human-computer interaction further includes:
and the insertion request acquisition module is used for acquiring the data insertion request.
And the insertion statement generation module is used for analyzing the second priority value and the second data attribute from the data insertion request and generating the data insertion statement according to the second priority value and the second data attribute.
And the insertion result obtaining module is used for executing a data insertion statement in the MongoDB and obtaining an insertion result returned by the MongoDB, wherein the insertion result represents whether the insertion is successful under the unique index constraint of the data attribute.
Optionally, in an embodiment of the present application, the insertion result includes: the insertion state and the second data identification; the message queue management device based on man-machine conversation further comprises:
and the insertion state judging module is used for judging whether the insertion state is successful or not.
And the data record storage module is used for storing the second data identifier as a key into the ordered set of Redis in a form of taking the second priority value as a specific value if the insertion state is successful.
Optionally, in this embodiment of the present application, the message queue management apparatus based on human-computer interaction further includes:
and the updating request acquisition module is used for acquiring the data updating request.
And the update statement generation module is used for analyzing the third priority value and the third data attribute from the data update request and generating the data update statement according to the third priority value and the third data attribute.
And the updating structure obtaining module is used for executing a data updating statement in the MongoDB and obtaining an updating result returned by the MongoDB, wherein the updating result represents whether the updating is successful under the unique index constraint of the data attribute.
It should be understood that the apparatus corresponds to the above-mentioned message queue management method based on man-machine interaction, and can perform the steps related to the above-mentioned method embodiment, and the specific functions of the apparatus can be referred to the above description, and the detailed description is appropriately omitted here to avoid repetition. The device includes at least one software function that can be stored in memory in the form of software or firmware (firmware) or solidified in the Operating System (OS) of the device.
Please refer to fig. 5, which illustrates a schematic structural diagram of an electronic device according to an embodiment of the present application. An electronic device 500 provided in an embodiment of the present application includes: a processor 510 and a memory 520, the memory 520 storing machine readable instructions executable by the processor 510, the machine readable instructions when executed by the processor 510 performing the method as above.
Embodiments of the present application also provide a computer-readable storage medium 530, where the computer-readable storage medium 530 stores thereon a computer program, and when the computer program is executed by the processor 510, the computer program performs the method as described above.
The computer-readable storage medium 530 may be implemented by any type of volatile or nonvolatile storage device or combination thereof, such as a Static Random Access Memory (SRAM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), an Erasable Programmable Read-Only Memory (EPROM), a Programmable Read-Only Memory (PROM), a Read-Only Memory (ROM), a magnetic Memory, a flash Memory, a magnetic disk, or an optical disk.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
In addition, functional modules of the embodiments in the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an alternative embodiment of the embodiments of the present application, but the scope of the embodiments of the present application is not limited thereto, and any person skilled in the art can easily conceive of changes or substitutions within the technical scope of the embodiments of the present application, and all the changes or substitutions should be covered by the scope of the embodiments of the present application.

Claims (9)

1. A message queue management method based on man-machine conversation is characterized by comprising the following steps:
acquiring a data deletion request, wherein the data deletion request comprises a first priority value and at least one data attribute;
generating a conditional query statement according to the first priority value;
querying a first data identifier corresponding to the conditional query statement in a database, wherein the database stores a corresponding relation between the data identifier and the priority value;
deleting a data record corresponding to the first data identifier in an ordered set of Redis, wherein the data record is stored in the ordered set of Redis by taking the data identifier as a key and taking a priority value as a specific value, and the ordered set is used as a priority queue;
wherein the database comprises: MongoDB; the querying out the first data identifier corresponding to the conditional query statement in the database includes: executing the conditional query statement in the MongoDB to obtain a query result returned by the MongoDB, wherein the query result comprises a data identifier corresponding to the conditional query statement;
data identification and priority values are stored in both the Redis and the MongoDB, the data identification and the priority values in the Redis are used for determining the data processing sequence, and the data identification and the priority values in the MongoDB are used as conditions for screening out data needing to be deleted; generating a conditional query statement according to the first priority value, comprising: encapsulating the first priority value and the at least one data attribute as the conditional query statement in the format required by the MongoDB.
2. The method of claim 1, wherein the data deletion request further comprises: a first data attribute; generating a conditional query statement according to the first priority value, comprising:
parsing the first priority value and the first data attribute from the data deletion request;
and splicing the first priority value and the first data attribute to obtain a conditional query statement.
3. The method of claim 1, wherein the ordered set is a ZSet; the deleting the data record corresponding to the first data identifier in the ordered set of Redis includes:
and deleting the data records identified by all keys for the data in the Zset of the Redis.
4. The method of claim 3, further comprising:
acquiring a data insertion request;
analyzing a second priority value and a second data attribute from the data insertion request, and generating a data insertion statement according to the second priority value and the second data attribute;
and executing the data insertion statement in the MongoDB to obtain an insertion result returned by the MongoDB, wherein the insertion result represents whether the insertion is successful under the unique index constraint of the data attribute.
5. The method of claim 4, wherein the insertion result comprises: the insertion state and the second data identification; after the obtaining of the insertion result returned by the MongoDB, the method further comprises:
judging whether the insertion state is successful;
and if so, storing the second data identifier as a key into the ordered set of Redis in a form of taking the second priority value as a specific value.
6. The method of claim 3, further comprising:
acquiring a data updating request;
analyzing a third priority value and a third data attribute from the data updating request, and generating a data updating statement according to the third priority value and the third data attribute;
and executing the data updating statement in the MongoDB to obtain an updating result returned by the MongoDB, wherein the updating result represents whether the updating is successful under the unique index constraint of the data attribute.
7. A message queue management device based on human-computer conversation, comprising:
a deletion request obtaining module, configured to obtain a data deletion request, where the data deletion request includes a first priority value and at least one data attribute;
the query statement generating module is used for generating a conditional query statement according to the first priority value;
the data identifier query module is used for querying a first data identifier corresponding to the conditional query statement in a database, and the database stores the corresponding relation between the data identifier and the priority value;
a data record deleting module, configured to delete a data record corresponding to the first data identifier from an ordered set of Redis, where the data record is stored in the ordered set of Redis with a data identifier as a key and a priority value as a specific value, and the ordered set is used as a priority queue;
wherein the database comprises: MongoDB; the querying out the first data identifier corresponding to the conditional query statement in the database includes: executing the conditional query statement in the MongoDB to obtain a query result returned by the MongoDB, wherein the query result comprises a data identifier corresponding to the conditional query statement;
data identification and priority values are stored in both the Redis and the MongoDB, the data identification and the priority values in the Redis are used for determining the data processing sequence, and the data identification and the priority values in the MongoDB are used as conditions for screening out data needing to be deleted; generating a conditional query statement according to the first priority value, comprising: encapsulating the first priority value and the at least one data attribute as the conditional query statement in the format required by the MongoDB.
8. An electronic device, comprising: a processor and a memory, the memory storing machine-readable instructions executable by the processor, the machine-readable instructions, when executed by the processor, performing the method of any of claims 1 to 6.
9. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the method of any one of claims 1 to 6.
CN202111615512.5A 2021-12-28 2021-12-28 Message queue management method and device based on man-machine conversation Active CN113986942B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111615512.5A CN113986942B (en) 2021-12-28 2021-12-28 Message queue management method and device based on man-machine conversation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111615512.5A CN113986942B (en) 2021-12-28 2021-12-28 Message queue management method and device based on man-machine conversation

Publications (2)

Publication Number Publication Date
CN113986942A CN113986942A (en) 2022-01-28
CN113986942B true CN113986942B (en) 2022-04-26

Family

ID=79734594

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111615512.5A Active CN113986942B (en) 2021-12-28 2021-12-28 Message queue management method and device based on man-machine conversation

Country Status (1)

Country Link
CN (1) CN113986942B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116719821B (en) * 2023-08-09 2023-10-10 北京联云天下科技有限公司 Concurrent data insertion elastic search weight removing method, device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105868033A (en) * 2016-04-06 2016-08-17 江苏物联网研究发展中心 Method and system for achieving priority message queues based on Redis
CN108460041A (en) * 2017-02-20 2018-08-28 腾讯科技(深圳)有限公司 The treating method and apparatus of data

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6885990B1 (en) * 1999-05-31 2005-04-26 Nippon Telegraph And Telephone Company Speech recognition based on interactive information retrieval scheme using dialogue control to reduce user stress
CN110019213A (en) * 2017-12-04 2019-07-16 北京京东尚科信息技术有限公司 Data managing method, device, electronic equipment and storage medium
CN109101580A (en) * 2018-07-20 2018-12-28 北京北信源信息安全技术有限公司 A kind of hot spot data caching method and device based on Redis
CN109977139B (en) * 2019-03-18 2022-12-02 京东科技控股股份有限公司 Data processing method and device based on class structured query statement

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105868033A (en) * 2016-04-06 2016-08-17 江苏物联网研究发展中心 Method and system for achieving priority message queues based on Redis
CN108460041A (en) * 2017-02-20 2018-08-28 腾讯科技(深圳)有限公司 The treating method and apparatus of data

Also Published As

Publication number Publication date
CN113986942A (en) 2022-01-28

Similar Documents

Publication Publication Date Title
US8219575B2 (en) Method and system for specifying, preparing and using parameterized database queries
CN109857724B (en) Method and equipment for supporting various databases based on block chain
CN111367925A (en) Data dynamic real-time updating method, device and storage medium
CN109086382B (en) Data synchronization method, device, equipment and storage medium
CN111026749B (en) Service alarm method and device
CN112214617B (en) Digital file management method and system based on block chain technology
CN113986942B (en) Message queue management method and device based on man-machine conversation
CN110650164B (en) File uploading method and device, terminal and computer storage medium
CN114385760A (en) Method and device for real-time synchronization of incremental data, computer equipment and storage medium
CN111984732A (en) Method, node and block chain network for realizing decentralized retrieval on block chain
CN114461247A (en) Hot update method, device, electronic equipment and computer readable medium
CN108108126B (en) Data processing method, device and equipment
CN114048201A (en) Distributed stream computing engine Flink-based key field real-time deduplication method
CN115988001A (en) Consensus voting processing method, device, equipment and medium for block chain system
WO2020192663A1 (en) Data management method and related device
CN112347355A (en) Data processing method, device, server and storage medium
CN111159142B (en) Data processing method and device
CN111488117B (en) Method, electronic device, and computer-readable medium for managing metadata
CN112748866A (en) Method and device for processing incremental index data
CN115203260A (en) Abnormal data determination method and device, electronic equipment and storage medium
US11347689B2 (en) Method, device and computer program product for event ordering
CN110990640B (en) Data determination method, device, equipment and computer readable storage medium
CN114490865A (en) Database synchronization method, device, equipment and computer storage medium
CN109739883B (en) Method and device for improving data query performance and electronic equipment
CN108491448B (en) Data pushing method and device

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
GR01 Patent grant
GR01 Patent grant