WO2012162969A1 - Distributed queue message reading method, device and system - Google Patents

Distributed queue message reading method, device and system Download PDF

Info

Publication number
WO2012162969A1
WO2012162969A1 PCT/CN2011/079241 CN2011079241W WO2012162969A1 WO 2012162969 A1 WO2012162969 A1 WO 2012162969A1 CN 2011079241 W CN2011079241 W CN 2011079241W WO 2012162969 A1 WO2012162969 A1 WO 2012162969A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
distributed
client
internal
distributed queue
Prior art date
Application number
PCT/CN2011/079241
Other languages
French (fr)
Chinese (zh)
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 华为技术有限公司
Priority to PCT/CN2011/079241 priority Critical patent/WO2012162969A1/en
Priority to CN201180001873.9A priority patent/CN103503388B/en
Publication of WO2012162969A1 publication Critical patent/WO2012162969A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • H04L49/9063Intermediate storage in different physical parts of a node or terminal

Definitions

  • the present invention relates to the field of data processing, and in particular, to a distributed queue message reading method, device, and system.
  • distributed queues In distributed queues, in order to improve the reliability of distributed queues, distributed queues often store multiple copies of a message when storing a message; and when a message of a distributed queue is read by a client, distributed The queue needs to delete all copies of the message, so that the same message is not read and processed by the client, which affects the business process.
  • a distributed queue may have a large number of concurrent accesses. After a message of a distributed queue is read, it takes a period of time to delete all copies of the message. When the number of copies of the message is large, all copies of the message are deleted. The required period of time is also longer, during which time the client may read the same message, which increases the risk of message duplication.
  • the distributed queue message reading method, device, and system provided by the embodiments of the present invention can prevent the client from reading the same message from the distributed queue, and reduce the risk of repeated message processing.
  • a method for reading a distributed queue message comprising:
  • Another method for reading distributed queue messages includes:
  • a distributed queue message reading device comprising:
  • a receiving unit configured to receive a request for obtaining a message sent by the client
  • An obtaining unit configured to obtain, from the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
  • a determining unit configured to extract an internal identifier ID of the message, and determine whether the internal identifier ID is stored in the distributed database
  • control unit configured to delete an internal identifier ID carried by the message stored in the distributed database, and delete the internal identifier ID from the obtained message, when the judgment result of the determining unit is YES, And sending a message that deletes the internal identifier ID to the client;
  • the distributed database is configured to store an internal identification ID of the message.
  • Another distributed queue message reading device includes:
  • a second receiving unit configured to receive a request for acquiring a message sent by the client
  • a second obtaining unit configured to obtain, from the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
  • An extracting unit configured to extract an internal identifier ID of the message, and determine a corresponding distributed row level lock according to the internal identifier ID;
  • a identifying unit configured to identify whether the Value value stored in the distributed row level lock is readable; and a second control unit, configured to: when the value value stored in the distributed row level lock is readable, The Value value is set to indicate that it is unreadable, and the internal identification ID is deleted from the obtained message, and a message that the internal identification ID is deleted is sent to the client.
  • a distributed queue message reading system comprising a client and any of the above distributed queue message reading devices
  • the client is configured to send a get message request to the distributed queue message reading device, to And receiving a message corresponding to the acquired message request sent by the distributed queue message reading device for performing service processing.
  • the message corresponding to the request for obtaining the message may be obtained from the distributed queue and the internal identifier ID carried by the message may be extracted, if the distributed database stores The internal identifier ID deletes the internal identifier ID carried in the message stored in the distributed database, deletes the internal identifier ID from the message, and sends a message that deletes the internal identifier ID to the client.
  • the internal ID of the ID is not sent to the client for processing. This prevents the client from reading the same message from the distributed queue and reduces the risk of repeated message processing.
  • the message corresponding to the request for obtaining the message may be obtained from the distributed queue, and the internal identifier ID carried by the message is extracted, and the internal identifier carried by the message is received.
  • the identifier ID determines the distributed row level lock, it identifies whether the Value value stored in the distributed row level lock indicates readability, and if the representation is readable, the Value value is set to indicate unreadable, and the content is deleted from the message. The internal ID is identified and a message with the internal ID removed is sent to the client.
  • FIG. 1 is a schematic flowchart of a method for reading a distributed queue message according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a method for storing a distributed queue message included in the method shown in FIG.
  • FIG. 4 is a schematic flowchart of another method for reading a distributed queue message according to an embodiment of the present invention.
  • FIG. 5 is a schematic flow chart of still another method for reading a distributed queue message according to an embodiment of the present disclosure
  • FIG. 6 is a modular schematic diagram of another method for reading a distributed queue message according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a distributed queue message reading device according to an embodiment of the present invention
  • FIG. 9 is a schematic structural diagram of a distributed queue message reading system according to an embodiment of the present invention
  • FIG. 11 is a schematic flowchart of a distributed queue message storage method included in the method shown in FIG. 10;
  • FIG. 12 is a schematic diagram of a modular diagram of the distributed queue message storage method shown in FIG.
  • FIG. 13 is a schematic flow chart of another method for reading a distributed queue message according to an embodiment of the present disclosure.
  • FIG. 14 is a schematic flow chart of still another method for reading a distributed queue message according to an embodiment of the present disclosure
  • FIG. 15 is a schematic diagram of a DHT according to an embodiment of the present invention.
  • FIG. 16 and FIG. 17 are schematic structural diagrams of a distributed queue message reading device according to an embodiment of the present invention.
  • FIG. 18 is a schematic structural diagram of another distributed queue message reading system according to an embodiment of the present invention.
  • the method, device and system for reading distributed queue messages provided by the embodiments of the present invention can prevent the client from reading the same message from the distributed queue, and reduce the risk of repeated processing of the message.
  • the following is a detailed description.
  • FIG. 1 is a schematic diagram of a method for reading a distributed queue message according to an embodiment of the present invention. Schematic diagram of the process. As shown in FIG. 1, the method may include the following steps:
  • the get message request sent by the client may be received by the deduplication proxy server.
  • the obtaining message request sent by the client carries the indication information (for example, the message self identifier), and the indication information is used to indicate the message that the client wants to obtain, which is common knowledge known to those skilled in the art, and is implemented by the present invention. The case is not described in detail.
  • the obtaining the message corresponding to the foregoing obtaining the message request from the distributed queue may be:
  • the deduplication proxy server forwards the get message request sent by the client to the distributed queue, and receives the message corresponding to the above acquired message request sent by the distributed queue.
  • the distributed queue may send the message corresponding to the foregoing acquisition message request to the deduplication proxy server according to the indication information (for example, the message self identifier) carried in the acquisition message request sent by the client.
  • the indication information for example, the message self identifier
  • the extracted internal identifier ID may be compared with the internal identifier ID stored in the distributed database, and if the message is found to be stored in the distributed database, The internal identification ID (that is, the extracted internal identification ID is the same as one of the internal identification IDs stored in the distributed database), indicating that the message currently obtained from the distributed queue corresponding to the above-mentioned acquisition message request has not been used by the client.
  • step 104 After reading, step 104 can be performed; otherwise, if the internal identifier ID carried by the message is not stored in the distributed database (that is, the extracted internal identifier ID is different from the internal identifier ID stored in the distributed database), then The message corresponding to the above-mentioned acquisition message request that has been obtained from the distributed queue has been read by the client, and step 105 can be performed.
  • Delete the internal identifier ID carried in the message stored in the distributed database delete the internal identifier ID from the obtained message, and send the message that deletes the internal identifier ID to the client.
  • the message currently obtained from the distributed queue corresponding to the foregoing acquisition message request is not yet obtained. It has been read by the client.
  • the proxy server can be deleted to delete the internal identification ID carried in the above message stored in the distributed database.
  • the proxy server deletes the internal identifier ID carried in the message stored in the distributed database
  • the internal identifier ID carried in the message may be deleted, and the message that the internal identifier ID has been deleted is sent to the client, so that the message is sent to the client.
  • the client can perform business processing on the message.
  • the deduplication proxy server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
  • the distributed queue can delete all the copies of the message corresponding to the above-mentioned acquisition message request, thereby preventing the client from reading from the distributed queue as much as possible. Repeated processing of the same message also keeps the distributed queue as free as possible for storing other messages and their copies.
  • the foregoing method provided by the embodiment of the present invention may further include a message storing process before the step 101, and the storing process may include the following steps:
  • the deduplication proxy server receives the input message from the client.
  • the deduplication proxy server generates an internal identification ID for the client input message, and adds the internal identification ID to the client input message.
  • the deduplication proxy server may generate an internal identification ID for the client input message by using a random generation manner or a hash HASH algorithm, where the deduplication proxy server generates different internal identification IDs for each client input message. .
  • the deduplication proxy server stores the message after joining the internal identification ID to the distributed queue; wherein the distributed queue also stores at least one copy of the message after joining the internal identification ID.
  • the deduplication proxy server stores the internal ID ID generated for the client input message to the distributed database.
  • the deduplication proxy server can generate an internal identification ID for the client input message, join the client input message, and store the message after adding the internal identification ID to the distributed queue, and will be the client.
  • the internal identification ID generated by the end input message is stored in the distributed database, so that the deduplication proxy server can perform the distributed queue message reading according to the method shown in FIG. 1 to prevent the client from reading the same message from the distributed queue. Reduce the risk of message duplication.
  • the message stored in the distributed queue carries the internal identifier ID.
  • the message corresponding to the request for obtaining the message may be obtained from the distributed queue, and the distribution is determined.
  • the internal identifier ID is stored in the database, if the internal identifier ID is the same as the internal identifier ID stored in the distributed database, the internal identifier carried in the message stored in the distributed data may be deleted. The ID, and the internal identification ID carried in the above message are deleted, and the message that the internal identification ID is deleted is sent to the client.
  • FIG. 2 is a schematic flowchart of a distributed queue message storage method included in the method shown in FIG. 1. As shown in FIG. 2, the distributed queue message storage method includes the following steps:
  • the deduplication proxy server receives the message M input by the client.
  • the deduplication proxy server uses the HASH algorithm to generate an internal identification ID for the message M, and adds the generated internal identification ID to the message M.
  • the deduplication proxy server stores the internal identification ID generated for the message M to the distributed database. 204. The deduplication proxy server receives the storage confirmation message returned by the distributed database.
  • the foregoing step 205 may be performed first, and then the step 203 and the step 204 are performed, which are not limited in the embodiment of the present invention.
  • the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 1 to prevent the client from reading the same message from the distributed queue, and reducing the repeated processing of the message. risk.
  • FIG. 3 is a modular schematic diagram of the distributed queue message storage method shown in FIG. 2. As shown in FIG. 3, the process of the distributed queue message storage method is as follows:
  • client A sends a message to the deduplication proxy server
  • the deduplication proxy server generates an internal identification ID for the message sent by the client A, and stores the internal identification ID in the distributed database;
  • the deduplication proxy server sends the message sent by the client A after joining the internal identifier ID to the distributed queue storage; wherein, the distributed queue further stores at least one message sent by the client A after joining the internal identifier ID. A copy.
  • the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 1 to prevent the client from reading the same message from the distributed queue, and reducing the message repetition processing. risks of.
  • FIG. 4 is a schematic flowchart diagram of another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 4, the distributed queue message reading method includes the following steps:
  • the deduplication proxy server receives the Get message request Get sent by the client.
  • the deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
  • the de-duplication proxy server receives the message M corresponding to the foregoing get message request Get sent by the distributed queue, where the message M carries an internal identifier ID.
  • the deduplication proxy server extracts the internal identifier ID of the message M.
  • the deduplication proxy server determines, according to the extracted internal identifier ID, that the internal identifier ID is not stored in the distributed database (ie, the extracted internal identifier ID and the internal storage stored in the distributed data) The IDs are not the same).
  • the deduplication proxy server sends an error response null to the client.
  • the deduplication proxy server determines that the internal identification ID is not stored in the distributed database (ie, the extracted internal identification ID is different from the internal identification ID stored in the distributed data), indicating that the current a message sent by the distributed queue corresponding to the above obtained message request Get
  • the deduplication proxy server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
  • FIG. 5 is a schematic flowchart diagram of still another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 5, the distributed queue message reading method includes the following steps:
  • the deduplication proxy server receives the Get message request Get sent by the client.
  • the deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
  • the de-duplication proxy server receives the message M corresponding to the foregoing get message request Get sent by the distributed queue, where the message M carries an internal identifier ID.
  • the distributed queue may delete all the copies of the message M stored in the distributed queue after the message M corresponding to the above-mentioned acquisition message request Get is sent to the de-duplication proxy server.
  • the deduplication proxy server extracts the internal identifier ID of the message M.
  • the deduplication proxy server determines, according to the extracted internal identifier ID, that the internal identifier ID is stored in the distributed database (that is, the extracted internal identifier ID is the same as one of the internal identifier IDs stored in the distributed data).
  • the deduplication proxy server deletes the internal identifier ID carried by the foregoing message stored in the distributed database.
  • the deduplication proxy server deletes the internal identifier ID carried in the message, and sends a message that deletes the internal identifier ID to the client.
  • a distributed queue may have a large number of concurrent client accesses, in which case
  • FIG. 6 is a schematic diagram of a modularization of another method for reading a distributed queue message according to an embodiment of the present invention.
  • the clients A, B, and C respectively access the distributed queue through their respective deduplication proxy servers, that is, the client A sends a message request to the distributed queue through its corresponding deduplication proxy server; End B sends a get message request to the distributed queue through its corresponding deduplication proxy server; client C sends a get message request to the distributed queue through its corresponding deduplication proxy server, thereby constituting concurrent access to the distributed queue.
  • the distributed queue may send the message M corresponding to the acquisition message request sent by the client A to the client according to the indication information (for example, the message self identifier) carried in the acquisition message request sent by the client A.
  • the de-duplication proxy server corresponding to the terminal A after receiving the message M corresponding to the request for obtaining the message sent by the client A, the de-duplication proxy server corresponding to the client A may extract the internal identifier ID of the message M, And determining whether the internal identifier ID is stored in the distributed database, and if yes, deleting the internal identifier ID carried by the message M stored in the distributed database, deleting the internal identifier ID carried by the message M, and deleting the The message of the internal identification ID is sent to client A.
  • the distributed queue After the distributed queue sends the message M corresponding to the get message request sent by the client A to the deduplication proxy server corresponding to the client A, the distributed queue can start all the copy operations of deleting the message M. Since the distributed queue deletes all the copies of the message M, it takes a period of time, and during this time, the distributed queue will continue to process the request messages of the client B and C, so the message M is deleted in the distributed queue. Before all copies of the distributed queue, it is still possible for the distributed queue to send a copy of the message M to the client B or the deduplication proxy server corresponding to the client C.
  • the deduplication proxy server corresponding to the client B receives the acquisition message request sent by the distributed queue and sent by the client B. After the corresponding M message (ie, copy), the message M can be extracted.
  • the internal ID is determined, and it is determined that the internal identification ID is not stored in the distributed database (deleted by the deduplication proxy server corresponding to the client A), and the deduplication proxy server corresponding to the client B sends an error response null to the client B. Therefore, it can be avoided that client B reads the same message M from the distributed queue for repeated processing. In the case of concurrent access, it is also possible to prevent the client from reading the same message from the distributed queue, reducing the risk of repeated processing of the message.
  • FIG. 7 is a schematic structural diagram of a distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 7, the device may include:
  • the receiving unit 701 is configured to receive a request for acquiring a message sent by the client.
  • the obtaining unit 702 is configured to obtain, from the distributed queue, a message corresponding to the foregoing get message request, where the message carries an internal identifier ID;
  • the determining unit 703 is configured to determine, according to the extracted internal identifier ID, whether the internal identifier ID is stored in the distributed row database 705;
  • the control unit 704 is configured to: when the determination result of the determining unit 703 is YES, delete the internal identification ID carried in the message stored in the distributed database 705, and delete the internal identification ID from the obtained message, and delete the The message of the internal identifier ID is sent to the client; or when the judgment result of the determining unit 703 is negative, the error response is sent to the client;
  • a distributed database 705, configured to store an internal identifier ID of the foregoing message
  • FIG. 8 is a schematic structural diagram of another distributed queue message reading device according to an embodiment of the present invention.
  • the device further includes a generating unit 706 and a storage unit 707 on the basis of the device shown in FIG. 7.
  • the receiving unit 701 is further configured to receive a client input message, and correspondingly, the generating unit 706 is configured to generate an internal identifier ID for the client input message, and join the client input message; The client input message after the internal ID is added to the distributed queue; wherein the distributed queue further stores at least one join A copy of the client input message after the ID is identified; and an internal identification ID generated for the client input message is stored to the distributed database 705.
  • the generating unit 706 in the device shown in FIG. 8 is specifically configured to generate an internal identifier ID for the client input message by using a random generation manner or a hash HASH algorithm, and join the client input message;
  • the internal identification ID generated by each client input message is different from each other.
  • the obtaining unit 702 is specifically configured to forward the acquisition message request sent by the client to the distributed queue, and receive the acquired message sent by the distributed queue.
  • the corresponding message is requested, and the message carries an internal identification ID.
  • the distributed queue after the distributed queue sends a message corresponding to the above-mentioned acquisition message request to the acquisition unit 702, the distributed queue is also used for all copies of the message.
  • the message stored in the distributed queue carries the internal identifier ID.
  • the obtaining unit 702 may obtain the request corresponding to the obtained message from the distributed queue.
  • the message determining unit 703 can determine whether the internal identifier ID is stored in the distributed database based on the extracted internal identifier ID. If yes, the control unit 704 deletes the internal identifier ID carried in the message stored in the distributed database 705. And deleting the internal identification ID carried by the message, and sending a message that deletes the internal identification ID to the client.
  • the internal identification ID carried by the message is deleted in the distributed database, and is not sent to the client for processing. It can prevent the client from reading the same message from the distributed queue, reducing the risk of message duplication.
  • FIG. 9 is a schematic structural diagram of a distributed queue message reading system according to an embodiment of the present invention.
  • the system may include a client 901 and a distributed queue message reading device 902; wherein the structure and functions of the distributed queue message reading device 902 are the same as those of the distributed queue shown in FIG. 7 or 8.
  • the message reading device is the same, and is not described in the embodiment of the present invention.
  • the client 901 is configured to send a get message request to the distributed queue message reading device 902, and receive a message corresponding to the get message request sent by the distributed queue message reading device 902 for service processing.
  • the distributed queue message reading system provided by the embodiment of the present invention can avoid the client 901 from dividing The same message is read in the layout queue, reducing the risk of message duplication.
  • the internal identifier ID generated for the client input message is stored in the distributed database, thereby preventing the client from reading the same message from the distributed queue, thereby reducing The risk of repeated processing of messages.
  • the internal identification ID generated for the client input message may also be stored in the distributed row level lock, which also prevents the client from reading the same message from the distributed queue and reducing the message. The risk of repeated processing. The details are described below.
  • FIG. 10 is a schematic flowchart diagram of another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 10, the method may include the following steps:
  • the steps 1001 and 1002 are the same as the steps 101 and 102 in the foregoing embodiment, and the embodiments of the present invention are not repeated herein.
  • a key value key-Value value pair is stored in each distributed row level lock. If the key value key stored in a distributed row level lock is the internal ID, the corresponding correspondence may be determined. Distributed row-level locks. The distributed row level lock will be described in detail later in the embodiment of the present invention.
  • step 1004. Determine whether the value of the value stored in the determined distributed row-level lock indicates that the value is readable. If yes, go to step 1005. If no, go to step 1006.
  • the value of Value the internal ID of the above may be readable, and the value of Value is unreadable when other values are used; or, when the value is non-zero, the value is readable, and the value of Value is zero.
  • the embodiment of the present invention is not limited.
  • the corresponding distributed row-level lock may be determined according to the internal identifier ID, and if the value of the value stored in the distributed row-level lock is found to be readable, It is indicated that the message currently obtained from the distributed queue corresponding to the above obtained message request has not been read by the client, and then step 1005 may be performed; otherwise, if the value of the value stored in the distributed row level lock is found to be unreadable.
  • step 1005 the value of the value stored in the distributed row level lock is found to be unreadable
  • step 1005 set the Value value to indicate that it is unreadable, and delete the internal identifier ID from the obtained message, and send a message that deletes the internal identifier ID to the client.
  • the Value value stored in the distributed row-level lock if it is found to be readable, it indicates that the message currently obtained from the distributed queue corresponding to the above-mentioned acquisition message request has not been read by the client.
  • the deduplication proxy server can set the Value value stored in the distributed row-level lock to indicate that it is unreadable, so that even if the same message (ie, a copy of the message) exists in the distributed queue, it will be stored in the distributed row-level lock.
  • the Value value indicates that it is unreadable and will not be sent to the client for processing, thus avoiding the client reading the same message from the distributed queue and reducing the risk of message duplication.
  • the deduplication proxy server sets the value of the value stored in the distributed row-level lock to indicate that it is unreadable
  • the internal identifier ID carried by the message may be deleted, and the message of the deleted internal identifier ID is sent to the client, so that the client The terminal can perform business processing on the message.
  • the Value value stored in the distributed row-level lock if the Value value stored in the distributed row-level lock is found to be unreadable, it indicates that the message currently obtained from the distributed queue corresponding to the above-mentioned acquisition message request has been read by the client, and the proxy is deduplicated.
  • the server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
  • the method shown in FIG. 10 may further include the following steps:
  • the distributed queue After the distributed queue sends the message corresponding to the above-mentioned acquisition message request to the deduplication proxy server, the distributed queue can delete all the copies of the message corresponding to the above-mentioned acquisition message request, thereby preventing the client from reading from the distributed queue as much as possible. Repeated processing of the same message also keeps the distributed queue as free as possible for storing other messages and their copies.
  • the method shown in FIG. 10 may further include a storage process of the message before the step 1001, and the storing process may include the following steps:
  • the deduplication proxy server receives the input message from the client.
  • the deduplication proxy server generates an internal identification ID for the client input message, and adds the internal identification ID to the client input message.
  • the deduplication proxy server may generate an internal identification ID for the client input message by using a random generation method or a hash HASH algorithm, where the deduplication proxy server is each The internal IDs generated by the client input messages are different from each other.
  • the deduplication proxy server stores the message after joining the internal ID to the distributed queue; wherein the distributed queue also stores at least one copy of the message after joining the internal ID.
  • the internal identifier ID generated by the client input message is stored as a key value key in the distributed row level lock, and the key value key matches a Value value (ie, a key-value value pair is stored in the distributed row level lock) ), the Value value indicates readability.
  • the deduplication proxy server can generate an internal identification ID for the client input message, join the client input message, and store the message after adding the internal identification ID to the distributed queue, and will be the client.
  • the internal identification ID generated by the end input message is stored to the distributed row level lock, so that the deduplication proxy server can perform the distributed queue message reading according to the method shown in FIG. 10, so as to prevent the client from reading the same from the distributed queue. Messages, reducing the risk of message duplication.
  • the deduplication proxy server may obtain a message corresponding to the acquired message request from the distributed queue and extract an internal identification ID carried by the message, and After determining the distributed row level lock according to the internal identifier ID carried by the message, identifying whether the Value value stored in the distributed row level lock indicates readability, if readable, setting the Value value to indicate unreadable, and The internal ID ID carried in the message is deleted, and a message for deleting the internal ID is sent to the client.
  • the Value value in the distributed row-level lock is not readable, and is not sent to the client for processing, thereby avoiding The client reads the same message from the distributed queue, reducing the risk of repeated processing of the message.
  • FIG. 11 is a schematic flowchart of a distributed queue message storage method included in the method shown in FIG. As shown in FIG. 11, the distributed queue message storage method includes the following steps:
  • the deduplication proxy server receives the message M input by the client.
  • the deduplication proxy server uses the HASH algorithm to generate an internal identification ID for the message M, and adds the generated internal identification ID to the message M.
  • the internal identifier is stored as a key value key in a distributed row-level lock.
  • the key value key matches a Value value (ie, a key-value value pair is stored in the distributed row-level lock), and the Value value indicates readability.
  • the deduplication proxy server receives the storage confirmation message returned by the distributed row level lock.
  • the deduplication proxy server stores the message M after adding the internal identifier ID to the distributed team ;l; wherein the distributed queue further stores at least one copy of the message M after joining the internal identifier ID.
  • step 1105 may be performed first, and then the step 1103 and the step 1104 are performed, which are not limited in the embodiment of the present invention.
  • the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 10, so as to prevent the client from reading the same message from the distributed queue, and reducing the message repetitive processing. risk.
  • FIG. 12 is a modular schematic diagram of the distributed queue message storage method shown in FIG. As shown in FIG. 12, the process of the distributed queue message storage method is as follows:
  • client A sends a message to the deduplication proxy server
  • the deduplication proxy server generates an internal identification ID for the message sent by the client A, and stores the internal identification ID as a key value key in the distributed row level lock, and the key value key matches a Value value ( That is, a key-value pair is stored in the distributed row-level lock, and the Value value is readable;
  • the deduplication proxy server sends the message sent by the client A after joining the internal identifier ID to the distributed queue storage; wherein, the distributed queue further stores at least one message sent by the client A after joining the internal identifier ID. A copy.
  • the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 10, so as to prevent the client from reading the same message from the distributed queue, and the message is repeated. The risk of processing.
  • FIG. 13 is a schematic flowchart diagram of another method for reading a distributed queue message according to an embodiment of the present invention.
  • the distributed queue message reading method includes the following steps: 1301.
  • the deduplication proxy server receives the Get message request Get sent by the client.
  • the deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
  • the deduplication proxy server receives the request for obtaining the message from the distributed queue.
  • the deduplication proxy server extracts the internal identifier ID of the message M.
  • the deduplication proxy server determines a corresponding distributed row level lock according to the internal identifier ID, and determines that the value value stored in the distributed row level lock indicates that the value is unreadable;
  • the deduplication proxy server sends an error response null to the client.
  • the deduplication proxy server determines that the Value value stored in the distributed row-level lock indicates that the value is unreadable, the message M corresponding to the acquired message request Get currently obtained from the distributed queue is indicated. It has been read by the client.
  • the deduplication proxy server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
  • FIG. 14 is a schematic flowchart diagram of still another method for reading a distributed queue message according to an embodiment of the present invention.
  • the distributed queue message reading method includes the following steps: 1401.
  • the deduplication proxy server receives the Get message request Get sent by the client.
  • the deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
  • the de-duplication proxy server receives the message M corresponding to the foregoing get message request Get sent by the distributed queue, where the message M carries an internal identifier ID.
  • the distributed queue may delete all the copies of the message M stored in the distributed queue after the message M corresponding to the above-mentioned acquisition message request Get is sent to the de-duplication proxy server.
  • the deduplication proxy server extracts an internal identifier ID of the message M.
  • the deduplication proxy server determines a corresponding distributed row level lock according to the internal identifier ID, and determines that the value value stored in the distributed row level lock is readable.
  • the deduplication proxy server sets the value of the value stored in the distributed row level lock to indicate that it is unreadable.
  • the deduplication proxy server deletes the internal identifier ID carried in the message, and sends a message that deletes the internal identifier ID to the client.
  • the client can also prevent the client from reading the same message from the distributed queue, reducing the risk of message duplication.
  • the message sent by the client carries its own identifier (belonging to the prior art), it can be based on the self-identity carried by the message, and generates an internal identifier ID through the hash algorithm (because of the principle of the hash algorithm, different messages) It will correspond to a different internal ID).
  • the generated internal ID is stored as a Key in the distributed row-level lock to form a key-Value value pair.
  • the distributed row-level lock storing the key-value pair may be regarded as a KV storage engine implemented by a distributed hash table (DHT) algorithm.
  • the principle of storing data by the KV storage engine is to first fix the space for storing data and form a 0 ⁇ 2 ⁇ 32 ring (as shown in Figure 15), and then generate a value through the Hash algorithm.
  • the value forms a host node in the data space, and then when the Key-Value value pair is stored, the KV storage engine obtains a hash value through the Hash algorithm, and the hash value is represented as a value node on the storage space ring. If the value node does not fall on a host node, the KV storage engine will find the first (or N if N backups are needed) along the storage space ring.
  • the host node stores the key-value pair host.
  • the deduplication proxy server determines the corresponding distributed row level lock (ie, the KV storage engine) according to the extracted internal identifier ID, and determines the internal identifier stored in the determined distributed row level lock (ie, the KV storage engine).
  • this process is also called the acquisition lock process; if the Value value indicates readable, it indicates that the current acquisition from the distributed queue corresponds to the above-mentioned acquisition message request.
  • the message has not been read by the client and can be read by the client. Among them, the client can read the message to indicate that the lock is acquired.
  • the proxy server deletes and sends the internal ID ID carried by the above message to the client
  • the value of the value stored in the distributed row-level lock (that is, the KV storage engine) can be set to indicate that it is unreadable.
  • Step 3 above describes the DHT implementation principle of the KV storage engine.
  • the Key-Value value is uniformly distributed on a certain host (or a few hosts), and distributed throughout the distributed external service.
  • the access of the row-level locks will also be distributed to different hosts, which will not generate massive access to one host, and avoid distributed row-level locks as a new performance bottleneck.
  • FIG. 16 is a schematic structural diagram of another distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 16, the device may include:
  • the second receiving unit 1601 is configured to receive a request for acquiring a message sent by the client.
  • the second obtaining unit 1602 is configured to obtain, from the distributed queue, a message corresponding to the foregoing acquiring message request, where the message carries an internal identifier ID;
  • the extracting unit 1603 is configured to extract an internal identifier ID of the message, and determine a corresponding distributed row level lock 1606 according to the internal identifier ID;
  • the identifying unit 1604 is configured to identify whether the value stored in the distributed row level lock 1606 is readable;
  • a second control unit 1605 configured to: when the Value value representation stored in the distributed row level lock 1606 is readable, set the Value value to indicate unreadable, and delete the internal identification ID from the obtained message, and A message with the above internal ID is deleted and sent to the client.
  • FIG. 17 is a schematic structural diagram of another distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 17, the device further includes a second generating unit 1607 and a second storage unit 1608 on the basis of the device shown in FIG. 16. In the device shown in FIG. 17, the device further includes a second generating unit 1607 and a second storage unit 1608 on the basis of the device shown in FIG. 16. In the device shown in FIG. 17, the device further includes a second generating unit 1607 and a second storage unit 1608 on the basis of the device shown in FIG. 16. In the device shown in FIG.
  • the second receiving unit 1601 is further configured to receive a client input message; correspondingly, the second generating unit 1607 is configured to generate an internal identifier ID for the client input message, and join the client input message;
  • the second storage unit 1608 is configured to store the client input message after joining the internal identifier ID to the distributed queue; wherein the distributed queue further stores at least one copy of the client input message after joining the internal identifier ID; and the second The storage unit 1608 stores the internal identification ID generated for the client input message as a key value key into the distributed row level lock 1606, the key value key matching a Value value, the Value value being readable.
  • FIG. 18 is a schematic structural diagram of a distributed queue message reading system according to an embodiment of the present invention. As shown in FIG. 18, the system may include a client 1801 and a distributed queue message reading device 1802; wherein the structure and functions of the distributed queue message reading device 1802 are the same as the distributed queue shown in FIG. 16 or FIG. The message reading device is the same, and is not described in the embodiment of the present invention.
  • the client 1801 is configured to send a get message request to the distributed queue message reading device.
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing storage medium includes: a Read-Only Memory (ROM), a Random Access Memory (RAM), a disk or an optical disk, and the like, which can store program codes. Medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A distributed queue message reading method, device and system. The method includes: receiving an acquisition message request sent from a client; acquiring a message corresponding to the acquisition message request from a distributed queue, with the message carrying an internal identifier ID; extracting the internal identifier ID carried in the message, and judging whether or not a distributed database has stored the internal identifier ID; and if it is yes, then the internal identifier ID stored in the distributed database carried in the message is deleted, and the internal identifier ID is deleted from the acquired message, and the message with the internal identifier ID deleted is sent to the client. The embodiments of the present invention can avoid a client reading the same message from a distributed queue, reducing the risk of message re-processing.

Description

一种分布式队列消息读取方法及设备、 系统 技术领域  Distributed queue message reading method, device and system
本发明涉及数据处理领域, 尤其涉及一种分布式队列消息读取方法及设 备、 系统。  The present invention relates to the field of data processing, and in particular, to a distributed queue message reading method, device, and system.
背景技术 Background technique
随着云计算兴起, 分布式也成为软件设计开发的趋势, 而分布式软件开发 的核心之一就是分布式队列。在分布式队列中,为了提高分布式队列的可靠性, 分布式队列在存储一条消息时往往存储该消息的多个副本;而当分布式队列的 某一条消息被客户端读取时, 分布式队列需要删除该消息的所有副本,从而避 免相同的消息被客户端读取后进行重复处理, 影响业务流程。  With the rise of cloud computing, distributed has also become a trend of software design and development, and one of the core of distributed software development is distributed queues. In distributed queues, in order to improve the reliability of distributed queues, distributed queues often store multiple copies of a message when storing a message; and when a message of a distributed queue is read by a client, distributed The queue needs to delete all copies of the message, so that the same message is not read and processed by the client, which affects the business process.
实际应用中, 分布式队列可能存在大量并发访问, 分布式队列某一条消息 被读取后, 需要一段时间来删除该消息的所有副本, 当该消息的副本数量较多 时,删除该消息的所有副本所需要的一段时间也较长,在这段时间内客户端可 能读取到相同的消息, 加剧了消息重复处理的风险。  In a practical application, a distributed queue may have a large number of concurrent accesses. After a message of a distributed queue is read, it takes a period of time to delete all copies of the message. When the number of copies of the message is large, all copies of the message are deleted. The required period of time is also longer, during which time the client may read the same message, which increases the risk of message duplication.
发明内容 Summary of the invention
针对上述缺陷, 本发明实施例提供的一种分布式队列消息读取方法及设 备、 系统, 能够避免客户端从分布式队列中读取到相同的消息, 降低消息重复 处理的风险。  In the above-mentioned deficiencies, the distributed queue message reading method, device, and system provided by the embodiments of the present invention can prevent the client from reading the same message from the distributed queue, and reduce the risk of repeated message processing.
一种分布式队列消息读取方法, 包括:  A method for reading a distributed queue message, comprising:
接收客户端发送的获取消息请求;  Receiving a request for obtaining a message sent by the client;
从分布式队列中获取与所述获取消息请求对应的消息,所述消息中携带有 内部标识 ID;  Obtaining, by the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
提取所述消息携带的内部标识 ID, 并且判断分布式数据库中是否存储有 所述内部标识 ID; 若是, 则删除所述分布式数据库中存储的所述消息携带的 内部标识 ID, 以及从获取的所述消息中删除所述内部标识 ID, 并将删除了所 述内部标识 ID的消息发送给所述客户端。  Extracting an internal identifier ID carried by the message, and determining whether the internal identifier ID is stored in the distributed database; if yes, deleting the internal identifier ID carried by the message stored in the distributed database, and obtaining the obtained The internal ID is deleted from the message, and a message that the internal ID is deleted is sent to the client.
另一种分布式队列消息读取方法, 包括:  Another method for reading distributed queue messages includes:
接收客户端发送的获取消息请求; 从分布式队列中获取与所述获取消息请求对应的消息,所述消息中携带有 内部标识 ID; Receiving a request for obtaining a message sent by the client; Obtaining, by the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
提取所述消息的内部标识 ID,并 ^据所述内部标识 ID确定出对应的分布 式行级锁, 若所述分布式行级锁中存储的 Value值表示可读, 则将所述 Value 值置为表示不可读, 以及从获取的所述消息中删除所述内部标识 ID, 并将删 除了所述内部标识 ID的消息发送给所述客户端。  Extracting an internal identification ID of the message, and determining a corresponding distributed row-level lock according to the internal identification ID, and if the Value value stored in the distributed row-level lock indicates readable, the Value value is The indication is unreadable, and the internal identification ID is deleted from the obtained message, and a message that the internal identification ID is deleted is sent to the client.
一种分布式队列消息读取设备, 包括:  A distributed queue message reading device, comprising:
接收单元, 用于接收客户端发送的获取消息请求;  a receiving unit, configured to receive a request for obtaining a message sent by the client;
获取单元, 用于从分布式队列中获取与所述获取消息请求对应的消息, 所 述消息中携带有内部标识 ID;  An obtaining unit, configured to obtain, from the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
判断单元, 用于提取所述消息的内部标识 ID, 并且判断分布式数据库中 是否存储有所述内部标识 ID;  a determining unit, configured to extract an internal identifier ID of the message, and determine whether the internal identifier ID is stored in the distributed database;
控制单元, 用于在所述判断单元的判断结果为是时,删除所述分布式数据 库中存储的所述消息携带的内部标识 ID, 以及从获取的所述消息中删除所述 内部标识 ID, 并将删除了所述内部标识 ID的消息发送给所述客户端;  a control unit, configured to delete an internal identifier ID carried by the message stored in the distributed database, and delete the internal identifier ID from the obtained message, when the judgment result of the determining unit is YES, And sending a message that deletes the internal identifier ID to the client;
所述分布式数据库, 用于存储所述消息的内部标识 ID。  The distributed database is configured to store an internal identification ID of the message.
另一种分布式队列消息读取设备, 包括:  Another distributed queue message reading device includes:
第二接收单元, 用于接收客户端发送的获取消息请求;  a second receiving unit, configured to receive a request for acquiring a message sent by the client;
第二获取单元, 用于从分布式队列中获取与所述获取消息请求对应的消 息, 所述消息中携带有内部标识 ID;  a second obtaining unit, configured to obtain, from the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
提取单元, 用于提取所述消息的内部标识 ID, 并根据所述内部标识 ID确 定出对应的分布式行级锁;  An extracting unit, configured to extract an internal identifier ID of the message, and determine a corresponding distributed row level lock according to the internal identifier ID;
识别单元, 用于识别所述分布式行级锁中存储的 Value值是否表示可读; 第二控制单元, 用于在所述分布式行级锁中存储的 Value值表示可读时, 将所述 Value值置为表示不可读, 以及从获取的所述消息中删除所述内部标识 ID, 并将删除了所述内部标识 ID的消息发送给所述客户端。  a identifying unit, configured to identify whether the Value value stored in the distributed row level lock is readable; and a second control unit, configured to: when the value value stored in the distributed row level lock is readable, The Value value is set to indicate that it is unreadable, and the internal identification ID is deleted from the obtained message, and a message that the internal identification ID is deleted is sent to the client.
一种分布式队列消息读取系统,包括客户端以及上述任意一种分布式队列 消息读取设备;  A distributed queue message reading system, comprising a client and any of the above distributed queue message reading devices;
所述客户端, 用于发送获取消息请求给所述分布式队列消息读取设备, 以 及接收所述分布式队列消息读取设备发送的与所述获取消息请求对应的消息 进行业务处理。 The client is configured to send a get message request to the distributed queue message reading device, to And receiving a message corresponding to the acquired message request sent by the distributed queue message reading device for performing service processing.
本发明实施例中, 当接收到客户端发送的获取消息请求后, 可以从分布式 队列中获取与该获取消息请求对应的消息并提取该消息携带的内部标识 ID, 若分布式数据库中存储有该内部标识 ID, 则删除分布式数据库中存储的该消 息携带的内部标识 ID , 以及从该消息中删除该内部标识 ID , 并将删除了该内 部标识 ID的消息发送给客户端。 基于该技术方案, 当任意客户端对已经读取 过的消息进行重复读取时, 即使分布式队列中存在相同的消息 (即消息的副 本), 也会因为分布式数据库中已删除了该消息携带的内部标识 ID, 而不会发 送给客户端进行处理, 从而可以避免客户端从分布式队列中读取到相同的消 息, 降低消息重复处理的风险。  In the embodiment of the present invention, after receiving the request for obtaining the message sent by the client, the message corresponding to the request for obtaining the message may be obtained from the distributed queue and the internal identifier ID carried by the message may be extracted, if the distributed database stores The internal identifier ID deletes the internal identifier ID carried in the message stored in the distributed database, deletes the internal identifier ID from the message, and sends a message that deletes the internal identifier ID to the client. Based on this technical solution, when any client repeatedly reads a message that has already been read, even if the same message (ie, a copy of the message) exists in the distributed queue, the message has been deleted in the distributed database. The internal ID of the ID is not sent to the client for processing. This prevents the client from reading the same message from the distributed queue and reduces the risk of repeated message processing.
本发明实施例中, 当接收到客户端发送的获取消息请求后, 可以从分布式 队列中获取与该获取消息请求对应的消息并提取该消息携带的内部标识 ID, 以及根据该消息携带的内部标识 ID确定出分布式行级锁后, 识别分布式行级 锁中存储的 Value值是否表示可读, 若表示可读, 则将该 Value值置为表示不 可读, 以及从该消息中删除该内部标识 ID , 并将删除了该内部标识 ID的消息 发送给客户端。基于该技术方案, 当任意客户端对已经读取过的消息进行重复 读取时, 即使分布式队列中存在相同的消息 (即消息的副本), 也会因为分布 式行级锁中的 Value值表示不可读, 而不会发送给客户端进行处理, 从而可以 防止客户端从分布式队列中读取到相同的消息, 降低消息重复处理的风险。  In the embodiment of the present invention, after receiving the request for obtaining a message sent by the client, the message corresponding to the request for obtaining the message may be obtained from the distributed queue, and the internal identifier ID carried by the message is extracted, and the internal identifier carried by the message is received. After the identifier ID determines the distributed row level lock, it identifies whether the Value value stored in the distributed row level lock indicates readability, and if the representation is readable, the Value value is set to indicate unreadable, and the content is deleted from the message. The internal ID is identified and a message with the internal ID removed is sent to the client. Based on this technical solution, when any client repeatedly reads a message that has already been read, even if the same message (ie, a copy of the message) exists in the distributed queue, the value of the value in the distributed row-level lock is The representation is unreadable and will not be sent to the client for processing, which prevents the client from reading the same message from the distributed queue, reducing the risk of message duplication.
附图说明 DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例中所需要 使用的附图作筒单地介绍,显而易见地, 下面描述中的附图仅仅是本发明的一 些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的前提下, 还 可以根据这些附图获得其他的附图。  In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other drawings may also be obtained from those of ordinary skill in the art in view of the drawings.
图 1为本发明实施例提供的一种分布式队列消息读取方法的流程示意图; 图 2为图 1所示方法包含的分布式队列消息存储方法的流程示意图; 图 3为图 2所示的分布式队列消息存储方法的模块化示意图;  1 is a schematic flowchart of a method for reading a distributed queue message according to an embodiment of the present invention; FIG. 2 is a schematic flowchart of a method for storing a distributed queue message included in the method shown in FIG. A modular schematic diagram of a distributed queue message storage method;
图 4 为本发明实施例提供的另一种分布式队列消息读取方法的流程示意 图; FIG. 4 is a schematic flowchart of another method for reading a distributed queue message according to an embodiment of the present invention; Figure
图 5 为本发明实施例提供的又一种分布式队列消息读取方法的流程示意 图;  FIG. 5 is a schematic flow chart of still another method for reading a distributed queue message according to an embodiment of the present disclosure;
图 6 为本发明实施例提供的另一种分布式队列消息读取方法的模块化示 意图;  6 is a modular schematic diagram of another method for reading a distributed queue message according to an embodiment of the present invention;
图 7、图 8为本发明实施例提供的分布式队列消息读取设备的结构示意图; 图 9为本发明实施例提供的分布式队列消息读取系统的结构示意图; 图 10为本发明实施例提供的又一种分布式队列消息读取方法的流程示意 图;  FIG. 7 is a schematic structural diagram of a distributed queue message reading device according to an embodiment of the present invention; FIG. 9 is a schematic structural diagram of a distributed queue message reading system according to an embodiment of the present invention; A flow diagram of another distributed queue message reading method provided;
图 11为图 10所示方法包含的分布式队列消息存储方法的流程示意图; 图 12为图 11所示的分布式队列消息存储方法的模块化示意图;  11 is a schematic flowchart of a distributed queue message storage method included in the method shown in FIG. 10; FIG. 12 is a schematic diagram of a modular diagram of the distributed queue message storage method shown in FIG.
图 13为本发明实施例提供的另一种分布式队列消息读取方法的流程示意 图;  FIG. 13 is a schematic flow chart of another method for reading a distributed queue message according to an embodiment of the present disclosure;
图 14为本发明实施例提供的又一种分布式队列消息读取方法的流程示意 图;  FIG. 14 is a schematic flow chart of still another method for reading a distributed queue message according to an embodiment of the present disclosure;
图 15为本发明实施例提供的一种 DHT的原理图;  FIG. 15 is a schematic diagram of a DHT according to an embodiment of the present invention;
图 16、 图 17为本发明实施例提供的分布式队列消息读取设备的结构示意 图;  16 and FIG. 17 are schematic structural diagrams of a distributed queue message reading device according to an embodiment of the present invention;
图 18为本发明实施例提供的另一种分布式队列消息读取系统的结构示意 图。  FIG. 18 is a schematic structural diagram of another distributed queue message reading system according to an embodiment of the present invention.
具体实施方式 detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清 楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而不是 全部的实施例。基于本发明中的实施例, 本领域普通技术人员在没有作出创造 性劳动前提下所获得的所有其他实施例, 都属于本发明保护的范围。  BRIEF DESCRIPTION OF THE DRAWINGS The technical solutions in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative work are within the scope of the present invention.
本发明实施例提供的一种分布式队列消息读取方法及设备、 系统, 能够避 免客户端从分布式队列中读取到相同的消息, 降低消息重复处理的风险。 以下 分别进行详细说明。  The method, device and system for reading distributed queue messages provided by the embodiments of the present invention can prevent the client from reading the same message from the distributed queue, and reduce the risk of repeated processing of the message. The following is a detailed description.
请参阅图 1 , 图 1为本发明实施例提供的一种分布式队列消息读取方法的 流程示意图。 如图 1所示, 该方法可以包括以下步骤: Referring to FIG. 1, FIG. 1 is a schematic diagram of a method for reading a distributed queue message according to an embodiment of the present invention. Schematic diagram of the process. As shown in FIG. 1, the method may include the following steps:
101、 接收客户端发送的获取消息请求。  101. Receive a request for obtaining a message sent by a client.
一个实施例中,可以由去重复代理服务器来接收客户端发送的获取消息请 求。 一般地, 客户端发送的获取消息请求中都会携带有指示信息(例如消息自 身标识), 该指示信息用于指示客户端希望获取到的消息, 这是本领域技术人 员公知的常识, 本发明实施例不作详细介绍。  In one embodiment, the get message request sent by the client may be received by the deduplication proxy server. Generally, the obtaining message request sent by the client carries the indication information (for example, the message self identifier), and the indication information is used to indicate the message that the client wants to obtain, which is common knowledge known to those skilled in the art, and is implemented by the present invention. The case is not described in detail.
102、 从分布式队列中获取与上述获取消息请求对应的消息, 其中, 该消 息中携带有内部标识 ID;  102. Obtain a message corresponding to the foregoing obtaining a message request from a distributed queue, where the message carries an internal identifier ID;
一个实施例中,从分布式队列中获取与上述获取消息请求对应的消息具体 可以为:  In an embodiment, the obtaining the message corresponding to the foregoing obtaining the message request from the distributed queue may be:
去重复代理服务器将客户端发送的获取消息请求转发至分布式队列,并且 接收分布式队列发送的与上述获取消息请求对应的消息。  The deduplication proxy server forwards the get message request sent by the client to the distributed queue, and receives the message corresponding to the above acquired message request sent by the distributed queue.
其中,分布式队列可以根据客户端发送的获取消息请求中携带的指示信息 (例如消息自身标识 ), 将与上述获取消息请求对应的消息发送给去重复代理 服务器。  The distributed queue may send the message corresponding to the foregoing acquisition message request to the deduplication proxy server according to the indication information (for example, the message self identifier) carried in the acquisition message request sent by the client.
103、 提取上述消息的内部标识 ID, 并且判断分布式数据库中是否存储有 该内部标识 ID; 若是, 则执行步骤 104; 若否, 则执行步骤 105。  103. Extract an internal identifier ID of the message, and determine whether the internal identifier ID is stored in the distributed database; if yes, execute step 104; if no, execute step 105.
一个实施例中, 去重复代理服务器提取上述消息的内部标识 ID之后, 可 以将提取的内部标识 ID和分布式数据库中存储的内部标识 ID进行比对,如果 发现分布式数据库中存储有上述消息携带的内部标识 ID (即所提取的内部标 识 ID与分布式数据库中存储的某一个内部标识 ID相同), 则说明当前从分布 式队列中获取的与上述获取消息请求对应的消息还没有被客户端读取过,进而 可以执行步骤 104; 反之, 如果发现分布式数据库中没有存储上述消息携带的 内部标识 ID (即提取的内部标识 ID与分布式数据库中存储的内部标识 ID均 不相同), 则说明当前从分布式队列中获取的与上述获取消息请求对应的消息 已经被客户端读取过, 进而可以执行步骤 105。  In an embodiment, after the deduplication proxy server extracts the internal identifier ID of the message, the extracted internal identifier ID may be compared with the internal identifier ID stored in the distributed database, and if the message is found to be stored in the distributed database, The internal identification ID (that is, the extracted internal identification ID is the same as one of the internal identification IDs stored in the distributed database), indicating that the message currently obtained from the distributed queue corresponding to the above-mentioned acquisition message request has not been used by the client. After reading, step 104 can be performed; otherwise, if the internal identifier ID carried by the message is not stored in the distributed database (that is, the extracted internal identifier ID is different from the internal identifier ID stored in the distributed database), then The message corresponding to the above-mentioned acquisition message request that has been obtained from the distributed queue has been read by the client, and step 105 can be performed.
104、 删除分布式数据库中存储的上述消息携带的内部标识 ID, 以及从获 取的上述消息中删除上述内部标识 ID,并将删除了上述内部标识 ID的消息发 送给客户端。 一个实施例中, 如果发现从上述消息中提取的内部标识 ID与分布式数据 库中存储的某一个内部标识 ID相同, 则说明当前从分布式队列中获取的与上 述获取消息请求对应的消息还没有被客户端读取过,此时去重复代理服务器可 以删除分布式数据库中存储的上述消息携带的内部标识 ID。 这样即使分布式 队列中还存在相同的消息 (即消息的副本), 也会因为分布式数据库中已删除 了该消息中携带的内部标识 ID, 而不会发送给客户端进行处理, 从而可以防 止客户端从分布式队列中读取到相同的消息, 降低消息重复处理的风险。 104. Delete the internal identifier ID carried in the message stored in the distributed database, delete the internal identifier ID from the obtained message, and send the message that deletes the internal identifier ID to the client. In an embodiment, if it is found that the internal identifier ID extracted from the foregoing message is the same as the one of the internal identifier IDs stored in the distributed database, the message currently obtained from the distributed queue corresponding to the foregoing acquisition message request is not yet obtained. It has been read by the client. At this time, the proxy server can be deleted to delete the internal identification ID carried in the above message stored in the distributed database. In this way, even if the same message (that is, a copy of the message) exists in the distributed queue, the internal identification ID carried in the message has been deleted in the distributed database, and is not sent to the client for processing, thereby preventing The client reads the same message from the distributed queue, reducing the risk of message duplication.
另夕卜,去重复代理服务器删除分布式数据库中存储的上述消息携带的内部 标识 ID之后,可以将上述消息携带的内部标识 ID删除,并将已删除内部标识 ID的消息发送给客户端, 使客户端可以对该消息进行业务处理。  In addition, after the proxy server deletes the internal identifier ID carried in the message stored in the distributed database, the internal identifier ID carried in the message may be deleted, and the message that the internal identifier ID has been deleted is sent to the client, so that the message is sent to the client. The client can perform business processing on the message.
105、 发送错误响应给客户端。  105. Send an error response to the client.
一个实施例中, 如果发现从上述消息中提取的内部标识 ID与分布式数据 库中存储的内部标识 ID均不相同, 则说明当前从分布式队列中获取的与上述 获取消息请求对应的消息已经被客户端读取过,去重复代理服务器可以发送错 误响应 null给客户端,防止客户端从分布式队列中读取到相同的消息进行重复 处理。 分布式队列发送与上述获取消息请求对应的消息给去重复代理服务器之 后, 分布式队列可以删除上述获取消息请求对应的消息的所有副本,从而可以 尽量地避免客户端从分布式队列中读取到相同的消息进行重复处理,也使得分 布式队列保持尽可能多的空闲空间, 用于存储其他的消息及其副本。  In an embodiment, if it is found that the internal identifier ID extracted from the foregoing message is different from the internal identifier ID stored in the distributed database, the message corresponding to the foregoing acquisition message request currently obtained from the distributed queue has been After the client reads it, the deduplication proxy server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing. After the distributed queue sends the message corresponding to the above-mentioned acquisition message request to the deduplication proxy server, the distributed queue can delete all the copies of the message corresponding to the above-mentioned acquisition message request, thereby preventing the client from reading from the distributed queue as much as possible. Repeated processing of the same message also keeps the distributed queue as free as possible for storing other messages and their copies.
一个实施例中,对应于上述读取过程, 本发明实施例提供的上述方法在上 述步骤 101之前还可以包括消息的存储过程, 该存储过程可以包括以下步骤: In an embodiment, corresponding to the above-mentioned reading process, the foregoing method provided by the embodiment of the present invention may further include a message storing process before the step 101, and the storing process may include the following steps:
A、 去重复代理服务器接收客户端的输入消息。 A. The deduplication proxy server receives the input message from the client.
B、去重复代理服务器为客户端输入消息生成内部标识 ID, 并将所述内部 标识 ID加入客户端输入消息。  B. The deduplication proxy server generates an internal identification ID for the client input message, and adds the internal identification ID to the client input message.
一个实施例中, 去重复代理服务器可以采用随机生成方式或哈希 HASH 算法为客户端输入消息生成内部标识 ID, 其中, 去重复代理服务器为每一个 客户端输入消息生成的内部标识 ID互不相同。 C、 去重复代理服务器将加入内部标识 ID后的消息存储到分布式队列; 其中, 分布式队列还存储至少一个加入内部标识 ID后的消息的副本。 In an embodiment, the deduplication proxy server may generate an internal identification ID for the client input message by using a random generation manner or a hash HASH algorithm, where the deduplication proxy server generates different internal identification IDs for each client input message. . C. The deduplication proxy server stores the message after joining the internal identification ID to the distributed queue; wherein the distributed queue also stores at least one copy of the message after joining the internal identification ID.
D、 去重复代理服务器将为客户端输入消息生成的内部标识 ID存储到分 布式数据库。  D. The deduplication proxy server stores the internal ID ID generated for the client input message to the distributed database.
其中, 通过上述步骤 A~B , 去重复代理服务器可以为客户端输入消息生 成内部标识 ID, 并加入客户端输入消息, 以及将加入内部标识 ID后的消息存 储到分布式队列, 以及将为客户端输入消息生成的内部标识 ID存储到分布式 数据库,使得去重复代理服务器可以根据图 1所示的方法进行分布式队列消息 读取,避免客户端从分布式队列中读取到相同的消息, 降低消息重复处理的风 险。  Through the above steps A~B, the deduplication proxy server can generate an internal identification ID for the client input message, join the client input message, and store the message after adding the internal identification ID to the distributed queue, and will be the client. The internal identification ID generated by the end input message is stored in the distributed database, so that the deduplication proxy server can perform the distributed queue message reading according to the method shown in FIG. 1 to prevent the client from reading the same message from the distributed queue. Reduce the risk of message duplication.
其中, 上述步骤( 、 步骤 D之间的顺序可以调换, 或者上述步骤 C、 步骤 D可以同时进行, 本发明实施例不作限定。  The foregoing steps (the sequence between the steps D and the step D may be reversed, or the steps C and D may be performed at the same time, which are not limited in the embodiment of the present invention.
本发明实施例中, 分布式队列存储的消息中携带有内部标识 ID, 当接收 到客户端发送的获取消息请求后,可以从分布式队列中获取与该获取消息请求 对应的消息, 并判断分布式数据库中是否存储有该内部标识 ID, 如果有 (即 提取的内部标识 ID与分布式数据库中存储的某一个内部标识 ID相同), 则可 以删除分布式数据中存储的上述消息携带的内部标识 ID, 以及删除上述消息 携带的内部标识 ID, 以及将删除了内部标识 ID的消息发送给客户端。 基于上 述技术方案, 即使分布式队列中存在相同的消息 (即消息的副本), 也会因为 分布式数据库中已删除了该消息中携带的内部标识 ID, 而不会发送给客户端 进行处理,从而可以防止客户端从分布式队列中读取到相同的消息, 降低消息 重复处理的风险。  In the embodiment of the present invention, the message stored in the distributed queue carries the internal identifier ID. After receiving the request for obtaining the message sent by the client, the message corresponding to the request for obtaining the message may be obtained from the distributed queue, and the distribution is determined. Whether the internal identifier ID is stored in the database, if the internal identifier ID is the same as the internal identifier ID stored in the distributed database, the internal identifier carried in the message stored in the distributed data may be deleted. The ID, and the internal identification ID carried in the above message are deleted, and the message that the internal identification ID is deleted is sent to the client. Based on the above technical solution, even if the same message (ie, a copy of the message) exists in the distributed queue, the internal identification ID carried in the message is deleted in the distributed database, and is not sent to the client for processing. This prevents the client from reading the same message from the distributed queue, reducing the risk of message duplication.
请参阅图 2, 图 2为图 1所示方法包含的分布式队列消息存储方法的流程 示意图。 如图 2所示, 该分布式队列消息存储方法包括以下步骤:  Referring to FIG. 2, FIG. 2 is a schematic flowchart of a distributed queue message storage method included in the method shown in FIG. 1. As shown in FIG. 2, the distributed queue message storage method includes the following steps:
201、 去重复代理服务器接收客户端输入的消息 M。  201. The deduplication proxy server receives the message M input by the client.
202、 去重复代理服务器采用 HASH算法为消息 M生成内部标识 ID, 并 将生成的内部标识 ID加入消息 M。  202. The deduplication proxy server uses the HASH algorithm to generate an internal identification ID for the message M, and adds the generated internal identification ID to the message M.
203、 去重复代理服务器将为消息 M生成的内部标识 ID存储到分布式数 据库。 204、 去重复代理服务器接收分布式数据库返回的存储确认消息 OK。203. The deduplication proxy server stores the internal identification ID generated for the message M to the distributed database. 204. The deduplication proxy server receives the storage confirmation message returned by the distributed database.
205、 去重复代理服务器将加入内部标识 ID后的消息 M存储到分布式队 歹1 J; 其中, 分布式队列还存储至少一个加入内部标识 ID后的消息 M的副本。 205, was added to duplicate proxy server stores the message M to the distributed internal identification ID team bad 1 J; wherein the distributed queue also stores at least one message M is added after the replica internal identification ID.
在图 2所示方法中, 也可以先执行上述步骤 205 , 然后再执行步骤 203和 步骤 204, 本发明实施例不作限定。  In the method shown in FIG. 2, the foregoing step 205 may be performed first, and then the step 203 and the step 204 are performed, which are not limited in the embodiment of the present invention.
在图 2所示方法的基础上,去重复代理服务器可以根据图 1所示的方法进 行分布式队列消息读取,避免客户端从分布式队列中读取到相同的消息, 降低 消息重复处理的风险。  On the basis of the method shown in FIG. 2, the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 1 to prevent the client from reading the same message from the distributed queue, and reducing the repeated processing of the message. risk.
请参阅图 3,图 3为图 2所示的分布式队列消息存储方法的模块化示意图。 如图 3所示, 该分布式队列消息存储方法的过程如下:  Please refer to FIG. 3. FIG. 3 is a modular schematic diagram of the distributed queue message storage method shown in FIG. 2. As shown in FIG. 3, the process of the distributed queue message storage method is as follows:
( 1 )、 客户端 A发送消息给去重复代理服务器;  (1), client A sends a message to the deduplication proxy server;
( 2 )、 去重复代理服务器为客户端 A发送的消息生成一个内部标识 ID, 并将该内部标识 ID存入分布式数据库;  (2), the deduplication proxy server generates an internal identification ID for the message sent by the client A, and stores the internal identification ID in the distributed database;
( 3 )、去重复代理服务器将加入内部标识 ID后的客户端 A发送的消息发 送到分布式队列存储; 其中, 分布式队列还存储至少一个加入内部标识 ID后 的客户端 A发送的消息的副本。  (3) The deduplication proxy server sends the message sent by the client A after joining the internal identifier ID to the distributed queue storage; wherein, the distributed queue further stores at least one message sent by the client A after joining the internal identifier ID. A copy.
在图 3所示模块图的基础上,去重复代理服务器可以根据图 1所示的方法 进行分布式队列消息读取,避免客户端从分布式队列中读取到相同的消息, 降 低消息重复处理的风险。  On the basis of the module diagram shown in FIG. 3, the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 1 to prevent the client from reading the same message from the distributed queue, and reducing the message repetition processing. risks of.
请参阅图 4, 图 4为本发明实施例提供的另一种分布式队列消息读取方法 的流程示意图。 如图 4所示, 该分布式队列消息读取方法包括以下步骤:  Referring to FIG. 4, FIG. 4 is a schematic flowchart diagram of another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 4, the distributed queue message reading method includes the following steps:
401、 去重复代理服务器接收客户端发送的获取消息请求 Get。  401. The deduplication proxy server receives the Get message request Get sent by the client.
402、 去重复代理服务器将客户端发送的获取消息请求 Get转发至分布式 队列。  402. The deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
403、 去重复代理服务器接收分布式队列发送的与上述获取消息请求 Get 对应的消息 M , 其中, 该消息 M中携带有内部标识 ID。  403. The de-duplication proxy server receives the message M corresponding to the foregoing get message request Get sent by the distributed queue, where the message M carries an internal identifier ID.
404、 去重复代理服务器提取上述消息 M的内部标识 ID。  404. The deduplication proxy server extracts the internal identifier ID of the message M.
405、 去重复代理服务器基于提取的内部标识 ID, 判断出分布式数据库中 没有存储有该内部标识 ID (即提取的内部标识 ID与分布式数据中存储的内部 标识 ID均不相同)。 405. The deduplication proxy server determines, according to the extracted internal identifier ID, that the internal identifier ID is not stored in the distributed database (ie, the extracted internal identifier ID and the internal storage stored in the distributed data) The IDs are not the same).
406、 去重复代理服务器发送错误响应 null给客户端。  406. The deduplication proxy server sends an error response null to the client.
在图 4所示的方法中,去重复代理服务器判断出分布式数据库中没有存储 有该内部标识 ID (即提取的内部标识 ID与分布式数据中存储的内部标识 ID 均不相同 ), 说明当前分布式队列发送的与上述获取消息请求 Get对应的消息 In the method shown in FIG. 4, the deduplication proxy server determines that the internal identification ID is not stored in the distributed database (ie, the extracted internal identification ID is different from the internal identification ID stored in the distributed data), indicating that the current a message sent by the distributed queue corresponding to the above obtained message request Get
M已经被客户端读取过, 去重复代理服务器可以发送错误响应 null给客户端, 避免客户端从分布式队列中读取到相同的消息进行重复处理。 M has been read by the client, and the deduplication proxy server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
请参阅图 5 , 图 5为本发明实施例提供的又一种分布式队列消息读取方法 的流程示意图。 如图 5所示, 该分布式队列消息读取方法包括以下步骤:  Referring to FIG. 5, FIG. 5 is a schematic flowchart diagram of still another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 5, the distributed queue message reading method includes the following steps:
501、 去重复代理服务器接收客户端发送的获取消息请求 Get。  501. The deduplication proxy server receives the Get message request Get sent by the client.
502、 去重复代理服务器将客户端发送的获取消息请求 Get转发至分布式 队列。  502. The deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
503、 去重复代理服务器接收分布式队列发送的与上述获取消息请求 Get 对应的消息 M , 其中, 该消息 M中携带有内部标识 ID。  503. The de-duplication proxy server receives the message M corresponding to the foregoing get message request Get sent by the distributed queue, where the message M carries an internal identifier ID.
其中, 分布式队列将与上述获取消息请求 Get对应的消息 M发送给去重 复代理服务器之后, 可以删除分布式队列中存储的消息 M的所有副本。  The distributed queue may delete all the copies of the message M stored in the distributed queue after the message M corresponding to the above-mentioned acquisition message request Get is sent to the de-duplication proxy server.
504、 去重复代理服务器提取上述消息 M的内部标识 ID。  504. The deduplication proxy server extracts the internal identifier ID of the message M.
505、 去重复代理服务器基于提取的内部标识 ID, 判断出分布式数据库中 存储有该内部标识 ID (即提取的内部标识 ID与分布式数据中存储的某一个内 部标识 ID相同)。  505. The deduplication proxy server determines, according to the extracted internal identifier ID, that the internal identifier ID is stored in the distributed database (that is, the extracted internal identifier ID is the same as one of the internal identifier IDs stored in the distributed data).
506、 去重复代理服务器删除分布式数据库中存储的上述消息携带的内部 标识 ID。  506. The deduplication proxy server deletes the internal identifier ID carried by the foregoing message stored in the distributed database.
507、去重复代理服务器将上述消息携带的内部标识 ID删除, 并将删除了 内部标识 ID的消息发送给客户端。  507. The deduplication proxy server deletes the internal identifier ID carried in the message, and sends a message that deletes the internal identifier ID to the client.
在图 5 所示的方法中, 即使分布式队列中存在相同的消息 (即消息的副 本), 也会因为分布式数据库中已删除了该消息中携带的内部标识 ID, 而不会 发送给客户端进行处理,从而可以避免客户端从分布式队列中读取到相同的消 息, 降低消息重复处理的风险。  In the method shown in Figure 5, even if the same message (that is, a copy of the message) exists in the distributed queue, the internal identification ID carried in the message is deleted in the distributed database, and is not sent to the client. The processing is performed to prevent the client from reading the same message from the distributed queue and reducing the risk of message duplication.
一个实施例中,分布式队列可能存在大量客户端并发访问,在这种情况下, 应用本发明实施例提供的上述方法,可以避免客户端从分布式队列中读取到相 同的消息, 降低消息重复处理的风险。 以下通过具体实施例进行详细说明。 In one embodiment, a distributed queue may have a large number of concurrent client accesses, in which case By applying the foregoing method provided by the embodiment of the present invention, the client can be prevented from reading the same message from the distributed queue, and the risk of repeated processing of the message is reduced. The details are described below by way of specific examples.
请参阅图 6, 图 6为本发明实施例提供的另一种分布式队列消息读取方法 的模块化示意图。 如图 6所示, 客户端 A、 B、 C分别通过各自对应的去重复 代理服务器并发访问分布式队列, 即客户端 A通过其对应的去重复代理服务 器发送获取消息请求至分布式队列; 客户端 B 通过其对应的去重复代理服务 器发送获取消息请求至分布式队列; 客户端 C通过其对应的去重复代理服务 器发送获取消息请求至分布式队列, 从而构成对分布式队列的并发访问。  Referring to FIG. 6, FIG. 6 is a schematic diagram of a modularization of another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 6, the clients A, B, and C respectively access the distributed queue through their respective deduplication proxy servers, that is, the client A sends a message request to the distributed queue through its corresponding deduplication proxy server; End B sends a get message request to the distributed queue through its corresponding deduplication proxy server; client C sends a get message request to the distributed queue through its corresponding deduplication proxy server, thereby constituting concurrent access to the distributed queue.
假设客户端 A、 B、 C均需要读取分布式队列存储的消息 M, 则分布式队 列在接收到客户端 A、 B、 C通过各自对应的去重复代理服务器发送的获取消 息请求之后, 会对客户端 A、 B、 C发送的获取消息请求逐一进行处理。 例如, 息请求进行处理, 即分布式队列可以根据客户端 A发送的获取消息请求中携 带的指示信息(例如消息自身标识), 将与客户端 A发送的获取消息请求对应 的消息 M发送给客户端 A对应的去重复代理服务器;客户端 A对应的去重复 代理服务器接收到分布式队列发送的与客户端 A发送的获取消息请求对应的 消息 M后,可以提取该消息 M的内部标识 ID,并且判断分布式数据库中是否 存储有该内部标识 ID, 如果有, 则删除分布式数据库中存储的该消息 M携带 的内部标识 ID, 以及将该消息 M携带的内部标识 ID删除, 以及将删除了内 部标识 ID的消息发送给客户端 A。  Suppose that clients A, B, and C need to read the message M stored in the distributed queue, after the distributed queue receives the request for obtaining a message sent by the client A, B, and C through the corresponding deduplication proxy server, The get message requests sent by the clients A, B, and C are processed one by one. For example, the information request is processed, that is, the distributed queue may send the message M corresponding to the acquisition message request sent by the client A to the client according to the indication information (for example, the message self identifier) carried in the acquisition message request sent by the client A. The de-duplication proxy server corresponding to the terminal A; after receiving the message M corresponding to the request for obtaining the message sent by the client A, the de-duplication proxy server corresponding to the client A may extract the internal identifier ID of the message M, And determining whether the internal identifier ID is stored in the distributed database, and if yes, deleting the internal identifier ID carried by the message M stored in the distributed database, deleting the internal identifier ID carried by the message M, and deleting the The message of the internal identification ID is sent to client A.
其中, 分布式队列将与客户端 A发送的获取消息请求对应的消息 M发送 给客户端 A对应的去重复代理服务器之后, 分布式队列可以启动删除消息 M 的所有副本操作。由于分布式队列删除消息 M的所有副本是需要一段时间的, 而在这段时间内分布式队列还会继续对客户端 B、 C的获取消息请求进行处理, 因此在分布式队列删除完毕消息 M的所有副本之前, 分布式队列仍有可能将 消息 M的副本发送给客户端 B或客户端 C对应的去重复代理服务器。 进一步 地, 假设分布式队列将消息 M的副本发送给客户端 B对应的去重复代理服务 器, 那么客户端 B对应的去重复代理服务器接收到分布式队列发送的与客户 端 B发送的获取消息请求对应的 M消息(即副本)后, 可以提取该消息 M的 内部标识 ID, 并且判断分布式数据库中没有存储有该内部标识 ID (已被客户 端 A对应的去重复代理服务器删除 ),则客户端 B对应的去重复代理服务器发 送错误响应 null给客户端 B, 从而可以避免客户端 B从分布式队列中读取到 相同的消息 M进行重复处理。 端并发访问的情况下, 也可以避免客户端从分布式队列中读取到相同的消息, 降^ 消息重复处理的风险。 After the distributed queue sends the message M corresponding to the get message request sent by the client A to the deduplication proxy server corresponding to the client A, the distributed queue can start all the copy operations of deleting the message M. Since the distributed queue deletes all the copies of the message M, it takes a period of time, and during this time, the distributed queue will continue to process the request messages of the client B and C, so the message M is deleted in the distributed queue. Before all copies of the distributed queue, it is still possible for the distributed queue to send a copy of the message M to the client B or the deduplication proxy server corresponding to the client C. Further, assuming that the distributed queue sends a copy of the message M to the deduplication proxy server corresponding to the client B, the deduplication proxy server corresponding to the client B receives the acquisition message request sent by the distributed queue and sent by the client B. After the corresponding M message (ie, copy), the message M can be extracted. The internal ID is determined, and it is determined that the internal identification ID is not stored in the distributed database (deleted by the deduplication proxy server corresponding to the client A), and the deduplication proxy server corresponding to the client B sends an error response null to the client B. Therefore, it can be avoided that client B reads the same message M from the distributed queue for repeated processing. In the case of concurrent access, it is also possible to prevent the client from reading the same message from the distributed queue, reducing the risk of repeated processing of the message.
本发明实施例中,在不损失分布式优势的情况下,去重复代理服务器对客 户端是透明的,客户端还是像现有技术一样使用分布式队列, 分布式队列不需 要处理客户端读取重复的情况, 降低了客户端使用分布式队列的难度, 而且筒 请参阅图 7, 图 7为本发明实施例提供的一种分布式队列消息读取设备的 结构示意图。 如图 7所示, 该设备可以包括:  In the embodiment of the present invention, the deduplication proxy server is transparent to the client without losing the distributed advantage, and the client still uses the distributed queue as in the prior art, and the distributed queue does not need to process the client to read. The repetitive situation reduces the difficulty of the client using the distributed queue, and the CPU is shown in FIG. 7. FIG. 7 is a schematic structural diagram of a distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 7, the device may include:
接收单元 701 , 用于接收客户端发送的获取消息请求;  The receiving unit 701 is configured to receive a request for acquiring a message sent by the client.
获取单元 702, 用于从分布式队列中获取与上述获取消息请求对应的消 息, 该消息中携带有内部标识 ID;  The obtaining unit 702 is configured to obtain, from the distributed queue, a message corresponding to the foregoing get message request, where the message carries an internal identifier ID;
判断单元 703, 用于基于提取的内部标识 ID, 判断分布式行数据库 705 中是否存储有该内部标识 ID;  The determining unit 703 is configured to determine, according to the extracted internal identifier ID, whether the internal identifier ID is stored in the distributed row database 705;
控制单元 704, 用于在判断单元 703的判断结果为是时, 删除分布式数据 库 705 中存储的上述消息携带的内部标识 ID, 以及从获取的上述消息中删除 上述内部标识 ID, 并将删除了上述内部标识 ID的消息发送给客户端; 或者用 于在判断单元 703的判断结果为否时, 发送错误响应给客户端;  The control unit 704 is configured to: when the determination result of the determining unit 703 is YES, delete the internal identification ID carried in the message stored in the distributed database 705, and delete the internal identification ID from the obtained message, and delete the The message of the internal identifier ID is sent to the client; or when the judgment result of the determining unit 703 is negative, the error response is sent to the client;
分布式数据库 705, 用于存储上述消息的内部标识 ID;  a distributed database 705, configured to store an internal identifier ID of the foregoing message;
请参阅图 8, 图 8为本发明实施例提供的另一种分布式队列消息读取设备 的结构示意图。 如图 8所示, 该设备在图 7所示设备的基础上, 进一步还包括 生成单元 706、 存储单元 707。 在图 8所示的设备中, 接收单元 701还用于接 收客户端输入消息,相应地, 生成单元 706用于为客户端输入消息生成内部标 识 ID , 并加入客户端输入消息; 存储单元 707用于将加入内部标识 ID后的客 户端输入消息存储到分布式队列; 其中, 该分布式队列还存储至少一个加入内 部标识 ID后的客户端输入消息的副本; 以及将为客户端输入消息生成的内部 标识 ID存储到分布式数据库 705。 Referring to FIG. 8, FIG. 8 is a schematic structural diagram of another distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 8, the device further includes a generating unit 706 and a storage unit 707 on the basis of the device shown in FIG. 7. In the device shown in FIG. 8, the receiving unit 701 is further configured to receive a client input message, and correspondingly, the generating unit 706 is configured to generate an internal identifier ID for the client input message, and join the client input message; The client input message after the internal ID is added to the distributed queue; wherein the distributed queue further stores at least one join A copy of the client input message after the ID is identified; and an internal identification ID generated for the client input message is stored to the distributed database 705.
作为一个可选的实施方式,图 8所示的设备中生成单元 706具体用于采用 随机生成方式或哈希 HASH算法为客户端输入消息生成内部标识 ID, 并加入 客户端输入消息; 其中, 为每一个客户端输入消息生成的内部标识 ID互不相 同。  As an optional implementation manner, the generating unit 706 in the device shown in FIG. 8 is specifically configured to generate an internal identifier ID for the client input message by using a random generation manner or a hash HASH algorithm, and join the client input message; The internal identification ID generated by each client input message is different from each other.
作为一个可选的实施方式, 图 7、 图 8所示的设备中, 获取单元 702具体 用于将客户端发送的获取消息请求转发至分布式队列,以及接收分布式队列发 送的与上述获取消息请求对应的消息, 该消息中携带有内部标识 ID。  As an optional implementation, in the device shown in FIG. 7 and FIG. 8 , the obtaining unit 702 is specifically configured to forward the acquisition message request sent by the client to the distributed queue, and receive the acquired message sent by the distributed queue. The corresponding message is requested, and the message carries an internal identification ID.
一个实施例中,分布式队列发送与上述获取消息请求对应的消息给获取单 元 702之后, 分布式队列还用于该消息的所有副本。  In one embodiment, after the distributed queue sends a message corresponding to the above-mentioned acquisition message request to the acquisition unit 702, the distributed queue is also used for all copies of the message.
本发明实施例中, 分布式队列存储的消息中携带有内部标识 ID, 当接收 单元 701接收到客户端发送的获取消息请求后,获取单元 702可以从分布式队 列中获取与该获取消息请求对应的消息, 判断单元 703基于提取的内部标识 ID, 可以判断分布式数据库中是否存储有该内部标识 ID, 如果有, 则控制单 元 704删除分布式数据库 705中存储的上述消息携带的内部标识 ID, 以及将 上述消息携带的内部标识 ID删除,以及将删除了内部标识 ID的消息发送给客 户端。基于上述技术方案,即使分布式队列中存在相同的消息(即消息的副本), 也会因为分布式数据库中已删除了该消息携带的内部标识 ID, 而不会发送给 客户端进行处理,从而可以防止客户端从分布式队列中读取到相同的消息, 降 低消息重复处理的风险。  In the embodiment of the present invention, the message stored in the distributed queue carries the internal identifier ID. After the receiving unit 701 receives the request for obtaining the message sent by the client, the obtaining unit 702 may obtain the request corresponding to the obtained message from the distributed queue. The message determining unit 703 can determine whether the internal identifier ID is stored in the distributed database based on the extracted internal identifier ID. If yes, the control unit 704 deletes the internal identifier ID carried in the message stored in the distributed database 705. And deleting the internal identification ID carried by the message, and sending a message that deletes the internal identification ID to the client. Based on the foregoing technical solution, even if the same message (ie, a copy of the message) exists in the distributed queue, the internal identification ID carried by the message is deleted in the distributed database, and is not sent to the client for processing. It can prevent the client from reading the same message from the distributed queue, reducing the risk of message duplication.
请参阅图 9, 图 9为本发明实施例提供的一种分布式队列消息读取系统的 结构示意图。如图 9所示, 该系统可以包括客户端 901以及分布式队列消息读 取设备 902; 其中, 分布式队列消息读取设备 902的结构、 功能均与图 7或图 8所示的分布式队列消息读取设备相同, 本发明实施例不作复述。  Referring to FIG. 9, FIG. 9 is a schematic structural diagram of a distributed queue message reading system according to an embodiment of the present invention. As shown in FIG. 9, the system may include a client 901 and a distributed queue message reading device 902; wherein the structure and functions of the distributed queue message reading device 902 are the same as those of the distributed queue shown in FIG. 7 or 8. The message reading device is the same, and is not described in the embodiment of the present invention.
其中,客户端 901用于发送获取消息请求给分布式队列消息读取设备 902, 以及接收分布式队列消息读取设备 902发送的与获取消息请求对应的消息进 行业务处理。  The client 901 is configured to send a get message request to the distributed queue message reading device 902, and receive a message corresponding to the get message request sent by the distributed queue message reading device 902 for service processing.
本发明实施例提供的分布式队列消息读取系统可以避免客户端 901 从分 布式队列中读取到相同的消息, 降低消息重复处理的风险。 The distributed queue message reading system provided by the embodiment of the present invention can avoid the client 901 from dividing The same message is read in the layout queue, reducing the risk of message duplication.
在上述实施例描述的方法、设备和系统中, 为客户端输入消息生成的内部 标识 ID是存储在分布式数据库中的, 进而可以避免客户端从分布式队列中读 取到相同的消息, 降低消息重复处理的风险。 作为另一种可选的实施方式, 为 客户端输入消息生成的内部标识 ID也可以存储在分布式行级锁中, 同样可以 避免客户端从分布式队列中读取到相同的消息, 降低消息重复处理的风险。 以 下分别进行详细说明。  In the method, device, and system described in the foregoing embodiments, the internal identifier ID generated for the client input message is stored in the distributed database, thereby preventing the client from reading the same message from the distributed queue, thereby reducing The risk of repeated processing of messages. As another optional implementation manner, the internal identification ID generated for the client input message may also be stored in the distributed row level lock, which also prevents the client from reading the same message from the distributed queue and reducing the message. The risk of repeated processing. The details are described below.
请参阅图 10, 图 10为本发明实施例提供的另一种分布式队列消息读取方 法的流程示意图。 如图 10所示, 该方法可以包括以下步骤:  Referring to FIG. 10, FIG. 10 is a schematic flowchart diagram of another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 10, the method may include the following steps:
其中, 步骤 1001、 1002分别与上述实施例中的步骤 101、 102相同, 本发 明实施例此处不作复述。  The steps 1001 and 1002 are the same as the steps 101 and 102 in the foregoing embodiment, and the embodiments of the present invention are not repeated herein.
1003、 提取上述消息的内部标识 ID , 并才 据该内部标识 ID确定出对应的 分布式行级锁。  1003. Extract an internal identifier ID of the message, and determine a corresponding distributed row level lock according to the internal identifier ID.
本发明实施例中, 每一个分布式行级锁中均存储一个关键值 key-Value值 对, 如果某一个分布式行级锁中存储的关键值 key=上述内部标识 ID, 则可以 确定出对应的分布式行级锁。本发明实施例后续将对分布式行级锁进行详细介 绍。  In the embodiment of the present invention, a key value key-Value value pair is stored in each distributed row level lock. If the key value key stored in a distributed row level lock is the internal ID, the corresponding correspondence may be determined. Distributed row-level locks. The distributed row level lock will be described in detail later in the embodiment of the present invention.
1004、 判断确定出的分布式行级锁中存储的 Value值是否表示可读, 如果 是, 则执行步骤 1005; 如果否, 则执行步骤 1006。  1004. Determine whether the value of the value stored in the determined distributed row-level lock indicates that the value is readable. If yes, go to step 1005. If no, go to step 1006.
一个实施例中, Value值=上述内部标识 ID时, 可以表示可读, 而 Value 值为其他数值时表示不可读; 或者, Value值为非零值时表示可读, 而 Value 值为零时表示不可读, 本发明实施例不作限定。  In one embodiment, the value of Value = the internal ID of the above may be readable, and the value of Value is unreadable when other values are used; or, when the value is non-zero, the value is readable, and the value of Value is zero. The embodiment of the present invention is not limited.
一个实施例中, 去重复代理服务器提取上述消息的内部标识 ID之后, 可 以根据该内部标识 ID确定出对应的分布式行级锁, 如果发现分布式行级锁中 存储的 Value值表示可读, 则说明当前从分布式队列中获取的与上述获取消息 请求对应的消息还没有被客户端读取过, 进而可以执行步骤 1005; 反之, 如 果发现分布式行级锁中存储的 Value值表示不可读, 则说明当前从分布式队列 中获取的与上述获取消息请求对应的消息已经被客户端读取过,进而可以执行 步骤 1006。 1005、 将 Value值置为表示不可读, 以及从获取的上述消息中删除上述内 部标识 ID, 并将删除了上述内部标识 ID的消息发送给客户端。 In an embodiment, after the de-duplication proxy server extracts the internal identifier ID of the message, the corresponding distributed row-level lock may be determined according to the internal identifier ID, and if the value of the value stored in the distributed row-level lock is found to be readable, It is indicated that the message currently obtained from the distributed queue corresponding to the above obtained message request has not been read by the client, and then step 1005 may be performed; otherwise, if the value of the value stored in the distributed row level lock is found to be unreadable The message corresponding to the above-mentioned acquisition message request that has been obtained from the distributed queue has been read by the client, and then step 1006 can be performed. 1005. Set the Value value to indicate that it is unreadable, and delete the internal identifier ID from the obtained message, and send a message that deletes the internal identifier ID to the client.
一个实施例中, 如果发现分布式行级锁中存储的 Value值表示可读, 则说 明当前从分布式队列中获取的与上述获取消息请求对应的消息还没有被客户 端读取过, 此时去重复代理服务器可以将分布式行级锁中存储的 Value值置为 表示不可读, 这样即使分布式队列中还存在相同的消息 (即消息的副本), 也 会因为分布式行级锁中存储的 Value值表示不可读, 而不会发送给客户端进行 处理,从而可以避免客户端从分布式队列中读取到相同的消息, 降低消息重复 处理的风险。  In an embodiment, if the Value value stored in the distributed row-level lock is found to be readable, it indicates that the message currently obtained from the distributed queue corresponding to the above-mentioned acquisition message request has not been read by the client. The deduplication proxy server can set the Value value stored in the distributed row-level lock to indicate that it is unreadable, so that even if the same message (ie, a copy of the message) exists in the distributed queue, it will be stored in the distributed row-level lock. The Value value indicates that it is unreadable and will not be sent to the client for processing, thus avoiding the client reading the same message from the distributed queue and reducing the risk of message duplication.
另外, 去重复代理服务器将分布式行级锁中存储的 Value值设为表示不可 读之后, 可以删除上述消息携带的内部标识 ID, 并将已删除内部标识 ID的消 息发送给客户端, 使得客户端可以对该消息进行业务处理。  In addition, after the deduplication proxy server sets the value of the value stored in the distributed row-level lock to indicate that it is unreadable, the internal identifier ID carried by the message may be deleted, and the message of the deleted internal identifier ID is sent to the client, so that the client The terminal can perform business processing on the message.
1006、 发送错误响应给客户端。  1006. Send an error response to the client.
一个实施例中, 如果发现分布式行级锁中存储的 Value值表示不可读, 则 说明当前从分布式队列中获取的与上述获取消息请求对应的消息已经被客户 端读取过,去重复代理服务器可以发送错误响应 null给客户端,避免客户端从 分布式队列中读取到相同的消息进行重复处理。  In an embodiment, if the Value value stored in the distributed row-level lock is found to be unreadable, it indicates that the message currently obtained from the distributed queue corresponding to the above-mentioned acquisition message request has been read by the client, and the proxy is deduplicated. The server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
一个实施例中, 图 10所示的方法还可以包括以下步骤:  In one embodiment, the method shown in FIG. 10 may further include the following steps:
分布式队列发送与上述获取消息请求对应的消息给去重复代理服务器之 后, 分布式队列可以删除上述获取消息请求对应的消息的所有副本,从而可以 尽量地避免客户端从分布式队列中读取到相同的消息进行重复处理,也使得分 布式队列保持尽可能多的空闲空间, 用于存储其他的消息及其副本。  After the distributed queue sends the message corresponding to the above-mentioned acquisition message request to the deduplication proxy server, the distributed queue can delete all the copies of the message corresponding to the above-mentioned acquisition message request, thereby preventing the client from reading from the distributed queue as much as possible. Repeated processing of the same message also keeps the distributed queue as free as possible for storing other messages and their copies.
一个实施例中, 对应于上述读取过程, 图 10所示的方法在上述步骤 1001 之前还可以包括消息的存储过程, 该存储过程可以包括以下步骤:  In one embodiment, corresponding to the above reading process, the method shown in FIG. 10 may further include a storage process of the message before the step 1001, and the storing process may include the following steps:
A、 去重复代理服务器接收客户端的输入消息。  A. The deduplication proxy server receives the input message from the client.
B、去重复代理服务器为客户端输入消息生成内部标识 ID, 并将该内部标 识 ID加入客户端输入消息。  B. The deduplication proxy server generates an internal identification ID for the client input message, and adds the internal identification ID to the client input message.
一个实施例中, 去重复代理服务器可以采用随机生成方式或哈希 HASH 算法为客户端输入消息生成内部标识 ID, 其中, 去重复代理服务器为每一个 客户端输入消息生成的内部标识 ID互不相同。 In one embodiment, the deduplication proxy server may generate an internal identification ID for the client input message by using a random generation method or a hash HASH algorithm, where the deduplication proxy server is each The internal IDs generated by the client input messages are different from each other.
C、 去重复代理服务器将加入内部标识 ID后的消息存储到分布式队列; 其中, 分布式队列还存储至少一个加入内部标识 ID后的消息的副本。  C. The deduplication proxy server stores the message after joining the internal ID to the distributed queue; wherein the distributed queue also stores at least one copy of the message after joining the internal ID.
D、 将为客户端输入消息生成的内部标识 ID作为关键值 key存储到分布 式行级锁中, 该关键值 key与一个 Value值匹配(即分布式行级锁中存储一个 key- Value值对 ), Value值表示可读。  D. The internal identifier ID generated by the client input message is stored as a key value key in the distributed row level lock, and the key value key matches a Value value (ie, a key-value value pair is stored in the distributed row level lock) ), the Value value indicates readability.
其中, 通过上述步骤 A~B , 去重复代理服务器可以为客户端输入消息生 成内部标识 ID, 并加入客户端输入消息, 以及将加入内部标识 ID后的消息存 储到分布式队列, 以及将为客户端输入消息生成的内部标识 ID存储到分布式 行级锁, 使得去重复代理服务器可以根据图 10所示的方法进行分布式队列消 息读取,避免客户端从分布式队列中读取到相同的消息, 降低消息重复处理的 风险。  Through the above steps A~B, the deduplication proxy server can generate an internal identification ID for the client input message, join the client input message, and store the message after adding the internal identification ID to the distributed queue, and will be the client. The internal identification ID generated by the end input message is stored to the distributed row level lock, so that the deduplication proxy server can perform the distributed queue message reading according to the method shown in FIG. 10, so as to prevent the client from reading the same from the distributed queue. Messages, reducing the risk of message duplication.
其中, 上述步骤( 、 步骤 D之间的顺序可以调换, 或者上述步骤 C、 步骤 D可以同时进行, 本发明实施例不作限定。  The foregoing steps (the sequence between the steps D and the step D may be reversed, or the steps C and D may be performed at the same time, which are not limited in the embodiment of the present invention.
图 10所示的方法中, 当接收到客户端发送的获取消息请求后, 去重复代 理服务器可以从分布式队列中获取与该获取消息请求对应的消息并提取该消 息携带的内部标识 ID , 以及根据该消息携带的内部标识 ID确定出分布式行级 锁后, 识别分布式行级锁中存储的 Value值是否表示可读, 若可读, 则将该 Value值置为表示不可读, 以及将该消息携带的内部标识 ID删除, 以及将删除 内部标识 ID的消息发送给客户端。 基于该技术方案, 即使分布式队列中存在 相同的消息 (即消息的副本), 也会因为分布式行级锁中的 Value值表示不可 读, 而不会发送给客户端进行处理,从而可以避免客户端从分布式队列中读取 到相同的消息, 降^ 消息重复处理的风险。  In the method shown in FIG. 10, after receiving the request for obtaining a message sent by the client, the deduplication proxy server may obtain a message corresponding to the acquired message request from the distributed queue and extract an internal identification ID carried by the message, and After determining the distributed row level lock according to the internal identifier ID carried by the message, identifying whether the Value value stored in the distributed row level lock indicates readability, if readable, setting the Value value to indicate unreadable, and The internal ID ID carried in the message is deleted, and a message for deleting the internal ID is sent to the client. Based on this technical solution, even if the same message (ie, a copy of the message) exists in the distributed queue, the Value value in the distributed row-level lock is not readable, and is not sent to the client for processing, thereby avoiding The client reads the same message from the distributed queue, reducing the risk of repeated processing of the message.
请参阅图 11 , 图 11为图 10所示方法包含的分布式队列消息存储方法的 流程示意图。 如图 11所示, 该分布式队列消息存储方法包括以下步骤:  Referring to FIG. 11, FIG. 11 is a schematic flowchart of a distributed queue message storage method included in the method shown in FIG. As shown in FIG. 11, the distributed queue message storage method includes the following steps:
1101、 去重复代理服务器接收客户端输入的消息 M。  1101. The deduplication proxy server receives the message M input by the client.
1102、 去重复代理服务器采用 HASH算法为消息 M生成内部标识 ID, 并 将生成的内部标识 ID加入消息 M。  1102. The deduplication proxy server uses the HASH algorithm to generate an internal identification ID for the message M, and adds the generated internal identification ID to the message M.
1103、 去重复代理服务器将为消息 M生成的内部标识 ID, 将该内部标识 ID作为关键值 key存储到分布式行级锁中,该关键值 key与一个 Value值匹配 (即分布式行级锁中存储一个 key- Value值对), 该 Value值表示可读。 1103. Deduplicating the internal identification ID generated by the proxy server for the message M, the internal identifier The ID is stored as a key value key in a distributed row-level lock. The key value key matches a Value value (ie, a key-value value pair is stored in the distributed row-level lock), and the Value value indicates readability.
1104、 去重复代理服务器接收分布式行级锁返回的存储确认消息 OK。 1104. The deduplication proxy server receives the storage confirmation message returned by the distributed row level lock.
1105、去重复代理服务器将加入内部标识 ID后的消息 M存储到分布式队 歹l ; 其中, 分布式队列还存储至少一个加入内部标识 ID后的消息 M的副本。 1105. The deduplication proxy server stores the message M after adding the internal identifier ID to the distributed team ;l; wherein the distributed queue further stores at least one copy of the message M after joining the internal identifier ID.
在图 11所示方法中, 也可以先执行上述步骤 1105, 然后再执行步骤 1103 和步骤 1104, 本发明实施例不作限定。  In the method shown in FIG. 11, the foregoing step 1105 may be performed first, and then the step 1103 and the step 1104 are performed, which are not limited in the embodiment of the present invention.
在图 11所示方法的基础上,去重复代理服务器可以根据图 10所示的方法 进行分布式队列消息读取,避免客户端从分布式队列中读取到相同的消息, 降 低消息重复处理的风险。  On the basis of the method shown in FIG. 11, the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 10, so as to prevent the client from reading the same message from the distributed queue, and reducing the message repetitive processing. risk.
请参阅图 12, 图 12为图 11所示的分布式队列消息存储方法的模块化示 意图。 如图 12所示, 该分布式队列消息存储方法的过程如下:  Referring to FIG. 12, FIG. 12 is a modular schematic diagram of the distributed queue message storage method shown in FIG. As shown in FIG. 12, the process of the distributed queue message storage method is as follows:
( 1 )、 客户端 A发送消息给去重复代理服务器;  (1), client A sends a message to the deduplication proxy server;
( 2 )、 去重复代理服务器为客户端 A发送的消息生成一个内部标识 ID, 并将该内部标识 ID作为关键值 key存储到分布式行级锁中, 该关键值 key与 一个 Value值匹配(即分布式行级锁中存储一个 key- Value值对), Value值表 示可读;  (2) The deduplication proxy server generates an internal identification ID for the message sent by the client A, and stores the internal identification ID as a key value key in the distributed row level lock, and the key value key matches a Value value ( That is, a key-value pair is stored in the distributed row-level lock, and the Value value is readable;
( 3 )、去重复代理服务器将加入内部标识 ID后的客户端 A发送的消息发 送到分布式队列存储; 其中, 分布式队列还存储至少一个加入内部标识 ID后 的客户端 A发送的消息的副本。  (3) The deduplication proxy server sends the message sent by the client A after joining the internal identifier ID to the distributed queue storage; wherein, the distributed queue further stores at least one message sent by the client A after joining the internal identifier ID. A copy.
在图 12所示模块图的基础上,去重复代理服务器可以根据图 10所示的方 法进行分布式队列消息读取, 避免客户端从分布式队列中读取到相同的消息, 降^ 消息重复处理的风险。  Based on the block diagram shown in FIG. 12, the deduplication proxy server can perform distributed queue message reading according to the method shown in FIG. 10, so as to prevent the client from reading the same message from the distributed queue, and the message is repeated. The risk of processing.
请参阅图 13, 图 13为本发明实施例提供的另一种分布式队列消息读取方 法的流程示意图。 如图 13所示, 该分布式队列消息读取方法包括以下步骤: 1301、 去重复代理服务器接收客户端发送的获取消息请求 Get。  Referring to FIG. 13, FIG. 13 is a schematic flowchart diagram of another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 13, the distributed queue message reading method includes the following steps: 1301. The deduplication proxy server receives the Get message request Get sent by the client.
1302、去重复代理服务器将客户端发送的获取消息请求 Get转发至分布式 队列。  1302. The deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
1303、 去重复代理服务器接收从分布式队列中获取与上述获取消息请求 Get对应的消息 M , 其中, 该消息 Μ中携带有内部标识 ID。 1303. The deduplication proxy server receives the request for obtaining the message from the distributed queue. The message M corresponding to Get, wherein the message Μ carries an internal identification ID.
1304、 去重复代理服务器提取上述消息 M的内部标识 ID。  1304. The deduplication proxy server extracts the internal identifier ID of the message M.
1305、去重复代理服务器根据该内部标识 ID确定出对应的分布式行级锁, 以及判断出该分布式行级锁中存储的 Value值表示不可读;  1305. The deduplication proxy server determines a corresponding distributed row level lock according to the internal identifier ID, and determines that the value value stored in the distributed row level lock indicates that the value is unreadable;
1306、 去重复代理服务器发送错误响应 null给客户端。  1306. The deduplication proxy server sends an error response null to the client.
在图 13所示的方法中, 去重复代理服务器判断出该分布式行级锁中存储 的 Value值表示不可读时, 说明当前从分布式队列中获取的与上述获取消息请 求 Get对应的消息 M已经被客户端读取过, 去重复代理服务器可以发送错误 响应 null给客户端,避免客户端从分布式队列中读取到相同的消息进行重复处 理。  In the method shown in FIG. 13, when the deduplication proxy server determines that the Value value stored in the distributed row-level lock indicates that the value is unreadable, the message M corresponding to the acquired message request Get currently obtained from the distributed queue is indicated. It has been read by the client. The deduplication proxy server can send an error response null to the client, preventing the client from reading the same message from the distributed queue for repeated processing.
请参阅图 14, 图 14为本发明实施例提供的又一种分布式队列消息读取方 法的流程示意图。 如图 14所示, 该分布式队列消息读取方法包括以下步骤: 1401、 去重复代理服务器接收客户端发送的获取消息请求 Get。  Referring to FIG. 14, FIG. 14 is a schematic flowchart diagram of still another method for reading a distributed queue message according to an embodiment of the present invention. As shown in FIG. 14, the distributed queue message reading method includes the following steps: 1401. The deduplication proxy server receives the Get message request Get sent by the client.
1402、去重复代理服务器将客户端发送的获取消息请求 Get转发至分布式 队列。  1402. The deduplication proxy server forwards the Get message request Get sent by the client to the distributed queue.
1403、 去重复代理服务器接收分布式队列发送的与上述获取消息请求 Get 对应的消息 M , 其中, 该消息 M中携带有内部标识 ID。  1403. The de-duplication proxy server receives the message M corresponding to the foregoing get message request Get sent by the distributed queue, where the message M carries an internal identifier ID.
其中, 分布式队列将与上述获取消息请求 Get对应的消息 M发送给去重 复代理服务器之后, 可以删除分布式队列中存储的消息 M的所有副本。  The distributed queue may delete all the copies of the message M stored in the distributed queue after the message M corresponding to the above-mentioned acquisition message request Get is sent to the de-duplication proxy server.
1404、 去重复代理服务器提取上述消息 M的内部标识 ID。  1404. The deduplication proxy server extracts an internal identifier ID of the message M.
1405、去重复代理服务器根据该内部标识 ID确定出对应的分布式行级锁, 以及判断出该分布式行级锁中存储的 Value值表示可读。  1405. The deduplication proxy server determines a corresponding distributed row level lock according to the internal identifier ID, and determines that the value value stored in the distributed row level lock is readable.
1406、去重复代理服务器将该分布式行级锁中存储的 Value值置为表示不 可读。  1406. The deduplication proxy server sets the value of the value stored in the distributed row level lock to indicate that it is unreadable.
1407、 去重复代理服务器将上述消息携带的内部标识 ID删除, 以及将删 除内部标识 ID的消息发送给客户端。  1407. The deduplication proxy server deletes the internal identifier ID carried in the message, and sends a message that deletes the internal identifier ID to the client.
在图 14所示的方法中, 即使分布式队列中存在相同的消息 (即消息的副 本), 也会因为分布式行级锁中存储的 Value值表示不可读, 而不会发送给客 户端进行处理,从而可以避免客户端从分布式队列中读取到相同的消息, 降低 消息重复处理的风险。 问的情况下,也可以防止客户端从分布式队列中读取到相同的消息, 降低消息 重复处理的风险。 In the method shown in Figure 14, even if the same message (ie, a copy of the message) exists in the distributed queue, the Value value stored in the distributed row-level lock is unreadable and will not be sent to the client. Processing, thus avoiding the client reading the same message from the distributed queue, reducing The risk of repeated processing of messages. In the case of the request, the client can also prevent the client from reading the same message from the distributed queue, reducing the risk of message duplication.
本发明实施例中, 上述的分布式行级锁的设计思路可以如下:  In the embodiment of the present invention, the design idea of the above distributed row level lock may be as follows:
1、 由于客户端发送的消息携带有自身标识(属于现有技术), 因此, 可以 以消息携带的自身标识为基础, 并通过 Hash算法生成一个内部标识 ID (因为 Hash算法的原理, 不同的消息就会对应到不同的内部标识 ID )。  1. Since the message sent by the client carries its own identifier (belonging to the prior art), it can be based on the self-identity carried by the message, and generates an internal identifier ID through the hash algorithm (because of the principle of the hash algorithm, different messages) It will correspond to a different internal ID).
2、 将生成的内部标识 ID作为 Key存储到分布式行级锁中, 构成一个 key-Value值对, Value值可以为任意非空的数值(例如 Key=内部标识 ID, value= 内部标识 ID ), 表示可读。  2. The generated internal ID is stored as a Key in the distributed row-level lock to form a key-Value value pair. The Value value can be any non-null value (for example, Key=internal ID, value=internal ID) , means readable.
3、上述存储 key- Value值对的分布式行级锁可以看作是采用分布式哈希表 ( Distributed Hash Table, DHT )算法实现的一个 KV存储引擎。 其中, KV存 储引擎存放数据的原理是先把存放数据的空间固定并形成 0~2Λ32环形 (如图 15所示的 DHT原理图 ),然后将存放数据的主机标识通过 Hash算法生成一个 值, 这个值在数据空间上形成一个主机节点, 然后在存放 Key- Value值对时, KV存储引擎会将 Key通过 Hash算法得到一个 Hash值, 该 Hash值在存储空 间环上表示为一个值节点 ,如果该值节点没有落在一个主机节点上,那么 KV 存储引擎会沿着存储空间环顺时针找到第一个 (或者 N个,如果需要 N个备份) 主机节点即存储该键值对主机。 3. The distributed row-level lock storing the key-value pair may be regarded as a KV storage engine implemented by a distributed hash table (DHT) algorithm. The principle of storing data by the KV storage engine is to first fix the space for storing data and form a 0~2 Λ 32 ring (as shown in Figure 15), and then generate a value through the Hash algorithm. The value forms a host node in the data space, and then when the Key-Value value pair is stored, the KV storage engine obtains a hash value through the Hash algorithm, and the hash value is represented as a value node on the storage space ring. If the value node does not fall on a host node, the KV storage engine will find the first (or N if N backups are needed) along the storage space ring. The host node stores the key-value pair host.
4、当去重复代理服务器根据提取的内部标识 ID确定出对应的分布式行级 锁 (即 KV存储引擎 ) , 并判断确定出的分布式行级锁 (即 KV存储引擎 ) 中 存储的内部标识 ID (即 Key )对应的 Value值是否表示可读时, 这一过程又被 称为获取锁过程; 若 Value值表示可读, 则说明当前从分布式队列中获取的与 上述获取消息请求对应的消息还没有被客户端读取过,客户端可以读取。其中, 客户端能够读到消息就表示获取了锁。  4. When the deduplication proxy server determines the corresponding distributed row level lock (ie, the KV storage engine) according to the extracted internal identifier ID, and determines the internal identifier stored in the determined distributed row level lock (ie, the KV storage engine). When the value corresponding to the ID (ie Key) indicates that it is readable, this process is also called the acquisition lock process; if the Value value indicates readable, it indicates that the current acquisition from the distributed queue corresponds to the above-mentioned acquisition message request. The message has not been read by the client and can be read by the client. Among them, the client can read the message to indicate that the lock is acquired.
5、 当去代理服务器将上述消息携带的内部标识 ID删除并发送给客户端 后, 可以将分布式行级锁(即 KV存储引擎)存储的 Value值置为表示不可读 5. When the proxy server deletes and sends the internal ID ID carried by the above message to the client, the value of the value stored in the distributed row-level lock (that is, the KV storage engine) can be set to indicate that it is unreadable.
(例如 Value值置空, 或为零), 以使其他客户端无法再去读这个消息, 这一 过程又被称为加锁过程。 (eg value value is set to null, or zero), so that other clients can no longer read this message, this The process is also known as the locking process.
上述步骤 3描述了 KV存储引擎的 DHT实现原理,其中, Key- Value值对 会均勾的分布在某个主机(或某几个主机)上, 在整个分布式对外服务的过程 中,对分布式行级锁的访问也会均勾的分布到不同的主机上, 不会产生对一台 主机的海量访问, 避免分布式行级锁成为新的性能瓶颈。  Step 3 above describes the DHT implementation principle of the KV storage engine. The Key-Value value is uniformly distributed on a certain host (or a few hosts), and distributed throughout the distributed external service. The access of the row-level locks will also be distributed to different hosts, which will not generate massive access to one host, and avoid distributed row-level locks as a new performance bottleneck.
请参阅图 16, 图 16为本发明实施例提供的另一种分布式队列消息读取设 备的结构示意图。 如图 16所示, 该设备可以包括:  Referring to FIG. 16, FIG. 16 is a schematic structural diagram of another distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 16, the device may include:
第二接收单元 1601 , 用于接收客户端发送的获取消息请求;  The second receiving unit 1601 is configured to receive a request for acquiring a message sent by the client.
第二获取单元 1602, 用于从分布式队列中获取与上述获取消息请求对应 的消息, 该消息中携带有内部标识 ID;  The second obtaining unit 1602 is configured to obtain, from the distributed queue, a message corresponding to the foregoing acquiring message request, where the message carries an internal identifier ID;
提取单元 1603, 用于提取上述消息的内部标识 ID, 并 居该内部标识 ID 确定出对应的分布式行级锁 1606;  The extracting unit 1603 is configured to extract an internal identifier ID of the message, and determine a corresponding distributed row level lock 1606 according to the internal identifier ID;
识别单元 1604, 用于识别上述分布式行级锁 1606中存储的 Value值是否 表示可读;  The identifying unit 1604 is configured to identify whether the value stored in the distributed row level lock 1606 is readable;
第二控制单元 1605, 用于在上述分布式行级锁 1606中存储的 Value值表 示可读时, 将 Value值置为表示不可读, 以及从获取的上述消息中删除上述内 部标识 ID, 并将删除了上述内部标识 ID的消息发送给客户端。  a second control unit 1605, configured to: when the Value value representation stored in the distributed row level lock 1606 is readable, set the Value value to indicate unreadable, and delete the internal identification ID from the obtained message, and A message with the above internal ID is deleted and sent to the client.
请参阅图 17, 图 17为本发明实施例提供的另一种分布式队列消息读取设 备的结构示意图。 如图 17所示, 该设备在图 16所示设备的基础上, 还进一步 包括第二生成单元 1607、 第二存储单元 1608。 在图 17所示的设备中, 第二接 收单元 1601还用于接收客户端输入消息; 相应地, 第二生成单元 1607用于为 客户端输入消息生成内部标识 ID,并加入客户端输入消息;第二存储单元 1608 用于将加入内部标识 ID后的客户端输入消息存储到分布式队列; 其中, 该分 布式队列还存储至少一个加入内部标识 ID后的客户端输入消息的副本; 以及 第二存储单元 1608将为客户端输入消息生成的内部标识 ID作为关键值 key 存储到分布式行级锁 1606中, 该关键值 key与一个 Value值匹配, 该 Value 值表示可读。  Referring to FIG. 17, FIG. 17 is a schematic structural diagram of another distributed queue message reading device according to an embodiment of the present invention. As shown in FIG. 17, the device further includes a second generating unit 1607 and a second storage unit 1608 on the basis of the device shown in FIG. 16. In the device shown in FIG. 17, the second receiving unit 1601 is further configured to receive a client input message; correspondingly, the second generating unit 1607 is configured to generate an internal identifier ID for the client input message, and join the client input message; The second storage unit 1608 is configured to store the client input message after joining the internal identifier ID to the distributed queue; wherein the distributed queue further stores at least one copy of the client input message after joining the internal identifier ID; and the second The storage unit 1608 stores the internal identification ID generated for the client input message as a key value key into the distributed row level lock 1606, the key value key matching a Value value, the Value value being readable.
一个实施例中, 当提取单元 1603提取的分布式行级锁存储的关键值 key= 上述内部标识 ID时, 就可以确定出对应的分布式行级锁 1606。 请参阅图 18, 图 18为本发明实施例提供的一种分布式队列消息读取系统 的结构示意图。如图 18所示, 该系统可以包括客户端 1801以及分布式队列消 息读取设备 1802; 其中, 分布式队列消息读取设备 1802的结构、 功能均与图 16或图 17所示的分布式队列消息读取设备相同, 本发明实施例不作复述。 In one embodiment, when the key value key of the distributed row level lock stored by the extracting unit 1603 is the internal ID, the corresponding distributed row level lock 1606 can be determined. Referring to FIG. 18, FIG. 18 is a schematic structural diagram of a distributed queue message reading system according to an embodiment of the present invention. As shown in FIG. 18, the system may include a client 1801 and a distributed queue message reading device 1802; wherein the structure and functions of the distributed queue message reading device 1802 are the same as the distributed queue shown in FIG. 16 or FIG. The message reading device is the same, and is not described in the embodiment of the present invention.
其中, 客户端 1801 用于发送获取消息请求给分布式队列消息读取设备 The client 1801 is configured to send a get message request to the distributed queue message reading device.
1802, 以及接收分布式队列消息读取设备 1802发送的与获取消息请求对应的 消息进行业务处理。 1802. Receive a message corresponding to the request for obtaining a message sent by the distributed queue message reading device 1802 for performing service processing.
基于上述技术方案, 即使分布式队列中存在相同的消息(即消息的副本), 也会因为分布式行级锁中的 Value值表示不可读, 而不会发送给客户端进行处 理,从而可以避免客户端从分布式队列中读取到相同的消息, 降低消息重复处 理的风险。  Based on the above technical solution, even if the same message (ie, a copy of the message) exists in the distributed queue, the value of the value in the distributed row-level lock is unreadable, and is not sent to the client for processing, thereby avoiding The client reads the same message from the distributed queue, reducing the risk of message duplication.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可 以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存 储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述的存储 介质包括:只读存储器( Read-Only Memory, ROM )、随机存取存储器 ( Random Access Memory, RAM ), 磁碟或者光盘等各种可以存储程序代码的介质。  A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to the program instructions. The foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing storage medium includes: a Read-Only Memory (ROM), a Random Access Memory (RAM), a disk or an optical disk, and the like, which can store program codes. Medium.
以上对本发明实施例所提供的一种分布式队列消息读取方法及设备、系统 述, 以上实施例的说明只是用于帮助理解本发明的方法及其核心思想; 同时, 对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围 上均会有改变之处, 综上所述, 本说明书内容不应理解为对本发明的限制。  The foregoing description of the method, apparatus, and system for reading a distributed queue message provided by the embodiments of the present invention are merely used to help understand the method and core idea of the present invention. Meanwhile, general techniques in the art are provided. In view of the above, the description of the present invention is not limited to the scope of the present invention.

Claims

权 利 要 求 Rights request
1、 一种分布式队列消息读取方法, 其特征在于, 包括:  A method for reading a distributed queue message, comprising:
接收客户端发送的获取消息请求;  Receiving a request for obtaining a message sent by the client;
从分布式队列中获取与所述获取消息请求对应的消息,所述消息中携带有 内部标识 ID;  Obtaining, by the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
提取所述消息携带的内部标识 ID, 并且判断分布式数据库中是否存储有 所述内部标识 ID; 若是, 则删除所述分布式数据库中存储的所述消息携带的 内部标识 ID, 以及从获取的所述消息中删除所述内部标识 ID, 并将删除了所 述内部标识 ID的消息发送给所述客户端。  Extracting an internal identifier ID carried by the message, and determining whether the internal identifier ID is stored in the distributed database; if yes, deleting the internal identifier ID carried by the message stored in the distributed database, and obtaining the obtained The internal ID is deleted from the message, and a message that the internal ID is deleted is sent to the client.
2、 根据权利要求 1所述方法, 其特征在于, 所述方法还包括:  2. The method according to claim 1, wherein the method further comprises:
从分布式队列中获取与所述获取消息请求对应的消息后,所述分布式队列 中删除与所述获取消息请求对应的消息的所有副本。  After the message corresponding to the obtained message request is obtained from the distributed queue, all copies of the message corresponding to the acquired message request are deleted in the distributed queue.
3、 根据权利要求 1或 2所述方法, 其特征在于, 所述方法还包括: 接收客户端的输入消息;  The method according to claim 1 or 2, wherein the method further comprises: receiving an input message of the client;
为所述客户端输入消息生成内部标识 ID,并将所述内部标识 ID加入到所 述客户端输入消息中;  Generating an internal identification ID for the client input message, and adding the internal identification ID to the client input message;
将加入内部标识 ID后的所述客户端输入消息存储到所述分布式队列; 所 述分布式队列还存储至少一个所述加入内部标识 ID后的所述客户端输入消息 的副本;  And storing the client input message after adding the internal identifier ID to the distributed queue; the distributed queue further storing at least one copy of the client input message after adding the internal identifier ID;
将为所述客户端输入消息生成的内部标识 ID存储到所述分布式数据库。 The internal identification ID generated for the client input message is stored to the distributed database.
4、 根据权利要求 3所述方法, 其特征在于, 所述为所述客户端输入消息 生成内部标识 ID, 包括: The method according to claim 3, wherein the generating an internal identification ID for the client input message comprises:
采用随机生成方式或哈希 HASH算法为所述客户端输入消息生成内部标 识 ID, 其中, 为每一个客户端输入消息生成的内部标识 ID互不相同。  The internal identification ID is generated by using the random generation method or the hash HASH algorithm for the client input message, wherein the internal identification ID generated for each client input message is different from each other.
5、 根据权利要求 1~4任意一项所述方法, 其特征在于, 所述从分布式队 列中获取与所述获取消息请求对应的消息, 包括:  The method according to any one of claims 1 to 4, wherein the obtaining, by the distributed queue, a message corresponding to the request for obtaining a message comprises:
将所述客户端发送的获取消息请求转发至所述分布式队列;  Forwarding the get message request sent by the client to the distributed queue;
接收所述分布式队列发送的与所述获取消息请求对应的消息。  Receiving a message corresponding to the acquired message request sent by the distributed queue.
6、 一种分布式队列消息读取方法, 其特征在于, 包括: 接收客户端发送的获取消息请求; A method for reading a distributed queue message, comprising: Receiving a request for obtaining a message sent by the client;
从分布式队列中获取与所述获取消息请求对应的消息,所述消息中携带有 内部标识 ID;  Obtaining, by the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
提取所述消息的内部标识 ID,并 ^据所述内部标识 ID确定出对应的分布 式行级锁, 若所述分布式行级锁中存储的 Value值表示可读, 则将所述 Value 值置为表示不可读, 以及从获取的所述消息中删除所述内部标识 ID, 并将删 除了所述内部标识 ID的消息发送给所述客户端。  Extracting an internal identification ID of the message, and determining a corresponding distributed row-level lock according to the internal identification ID, and if the Value value stored in the distributed row-level lock indicates readable, the Value value is The indication is unreadable, and the internal identification ID is deleted from the obtained message, and a message that the internal identification ID is deleted is sent to the client.
7、 根据权利要求 6所述方法, 其特征在于, 所述方法还包括:  The method according to claim 6, wherein the method further comprises:
接收客户端的输入消息;  Receiving input messages from the client;
为所述客户端输入消息生成内部标识 ID, 并加入所述客户端输入消息; 将加入内部标识 ID后的所述客户端输入消息存储到所述分布式队列; 所 述分布式队列还存储至少一个所述加入内部标识 ID后的所述客户端输入消息 的副本;  Generating an internal identification ID for the client input message, and joining the client input message; storing the client input message after joining the internal identification ID to the distributed queue; the distributed queue further storing at least a copy of the client input message after the internal ID is added;
将为所述客户端输入消息生成的内部标识 ID作为关键值 key存储到所述 分布式行级锁中, 所述关键值 key与一个 Value值匹配, 所述 Value值表示可 读。  The internal identification ID generated for the client input message is stored as a key value key in the distributed row level lock, the key value key is matched with a Value value, and the Value value indicates readable.
8、根据权利要求 7所述方法, 其特征在于, 所述根据所述内部标识 ID确 定出对应的分布式行级锁包括:  The method according to claim 7, wherein the determining the corresponding distributed row level lock according to the internal identifier ID comprises:
根据所述内部标识 ID确定出对应的分布式行级锁, 所述对应的分布式行 级锁存储的关键值 key=所述内部标识 ID。  And determining, according to the internal identifier ID, a corresponding distributed row level lock, where the corresponding distributed row level lock stores a key value key=the internal identifier ID.
9、 一种分布式队列消息读取设备, 其特征在于, 包括:  A distributed queue message reading device, comprising:
接收单元, 用于接收客户端发送的获取消息请求;  a receiving unit, configured to receive a request for obtaining a message sent by the client;
获取单元, 用于从分布式队列中获取与所述获取消息请求对应的消息, 所 述消息中携带有内部标识 ID;  An obtaining unit, configured to obtain, from the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
判断单元, 用于提取所述消息的内部标识 ID, 并且判断分布式数据库中 是否存储有所述内部标识 ID;  a determining unit, configured to extract an internal identifier ID of the message, and determine whether the internal identifier ID is stored in the distributed database;
控制单元, 用于在所述判断单元的判断结果为是时,删除所述分布式数据 库中存储的所述消息携带的内部标识 ID, 以及从获取的所述消息中删除所述 内部标识 ID, 并将删除了所述内部标识 ID的消息发送给所述客户端; 所述分布式数据库, 用于存储所述消息的内部标识 ID。 a control unit, configured to delete an internal identifier ID carried by the message stored in the distributed database, and delete the internal identifier ID from the obtained message, when the judgment result of the determining unit is YES, And sending a message that deletes the internal identifier ID to the client; The distributed database is configured to store an internal identification ID of the message.
10、 根据权利要求 9所述设备, 其特征在于, 所述获取单元从分布式队列 中获取与所述获取消息请求对应的消息后,所述分布式队列删除与所述获取消 息请求对应的消息的所有副本。  The device according to claim 9, wherein after the obtaining unit acquires a message corresponding to the acquiring message request from the distributed queue, the distributed queue deletes the message corresponding to the acquiring message request All copies of it.
11、 根据权利要求 9或 10所述的设备, 其特征在于,  11. Apparatus according to claim 9 or 10, characterized in that
所述接收单元还用于接收客户端输入消息;  The receiving unit is further configured to receive a client input message;
所述设备还包括:  The device further includes:
生成单元, 用于为所述客户端输入消息生成内部标识 ID, 并加入所述客 户端输入消息;  a generating unit, configured to generate an internal identification ID for the client input message, and join the client input message;
存储单元, 用于将加入内部标识 ID后的所述客户端输入消息存储到所述 分布式队列; 所述分布式队列还存储至少一个所述加入内部标识 ID后的所述 客户端输入消息的副本; 以及将为所述客户端输入消息生成的内部标识 ID存 储到所述分布式数据库。  a storage unit, configured to store the client input message after adding the internal identifier ID to the distributed queue; the distributed queue further storing at least one of the client input messages after adding the internal identifier ID a copy; and an internal identification ID generated for the client input message is stored to the distributed database.
12、 根据权利要求 11所述的设备, 其特征在于, 所述生成单元具体用于 采用随机生成方式或哈希 HASH 算法为所述客户端输入消息生成内部标识 The device according to claim 11, wherein the generating unit is specifically configured to generate an internal identifier for the client input message by using a random generation manner or a hash HASH algorithm.
ID, 并加入所述客户端输入消息; 为每一个客户端输入消息生成的内部标识 ID互不相同。 ID, and join the client input message; the internal ID ID generated for each client input message is different from each other.
13、根据权利要求 90~12任意一项所述的设备, 其特征在于, 所述获取单 元具体用于将所述客户端发送的获取消息请求转发至所述分布式队列,接收所 述分布式队列发送的与所述获取消息请求对应的消息,所述消息中携带有内部 标识 ID。  The device according to any one of claims 90 to 12, wherein the acquiring unit is specifically configured to forward an acquisition message request sent by the client to the distributed queue, and receive the distributed A message sent by the queue corresponding to the obtained message request, where the message carries an internal identifier ID.
14、 一种分布式队列消息读取设备, 其特征在于, 包括:  14. A distributed queue message reading device, comprising:
第二接收单元, 用于接收客户端发送的获取消息请求;  a second receiving unit, configured to receive a request for acquiring a message sent by the client;
第二获取单元, 用于从分布式队列中获取与所述获取消息请求对应的消 息, 所述消息中携带有内部标识 ID;  a second obtaining unit, configured to obtain, from the distributed queue, a message corresponding to the obtained message request, where the message carries an internal identifier ID;
提取单元, 用于提取所述消息的内部标识 ID, 并根据所述内部标识 ID确 定出对应的分布式行级锁;  An extracting unit, configured to extract an internal identifier ID of the message, and determine a corresponding distributed row level lock according to the internal identifier ID;
识别单元, 用于识别所述分布式行级锁中存储的 Value值是否表示可读; 第二控制单元, 用于在所述分布式行级锁中存储的 Value值表示可读时, 将所述 Value值置为表示不可读, 以及从获取的所述消息中删除所述内部标识 ID, 并将删除了所述内部标识 ID的消息发送给所述客户端。 An identification unit, configured to identify whether the Value value stored in the distributed row level lock is readable; and a second control unit, configured to: when the Value value stored in the distributed row level lock is readable, Setting the Value value to indicate unreadable, and deleting the internal identification ID from the obtained message, and transmitting a message deleting the internal identification ID to the client.
15、 根据权利要求 14所述的设备, 其特征在于,  15. Apparatus according to claim 14 wherein:
所述第二接收单元还用于接收客户端输入消息;  The second receiving unit is further configured to receive a client input message;
所述设备还包括:  The device further includes:
第二生成单元, 用于为所述客户端输入消息生成内部标识 ID, 并加入所 述客户端输入消息;  a second generating unit, configured to generate an internal identification ID for the client input message, and join the client input message;
第二存储单元, 用于将加入内部标识 ID后的所述客户端输入消息存储到 所述分布式队列; 所述分布式队列还存储至少一个所述加入内部标识 ID后的 所述客户端输入消息的副本; 以及将为所述客户端输入消息生成的内部标识 ID作为关键值 key存储到所述分布式行级锁中, 所述关键值 key与一个 Value 值匹配, 所述 Value值表示可读。  a second storage unit, configured to store the client input message after adding the internal identifier ID to the distributed queue; the distributed queue further storing at least one of the client input after adding the internal identifier ID a copy of the message; and storing an internal identification ID generated for the client input message as a key value key into the distributed row level lock, the key value key matching a Value value, the Value value indicating read.
16、 根据权利要求 15所述的设备, 其特征在于, 所述提取单元提取的分 布式行级锁存储的关键值 key=所述内部标识 ID。  The device according to claim 15, wherein the key value of the distributed row-level lock stored by the extracting unit is key=the internal identifier ID.
17、 一种分布式队列消息读取系统, 其特征在于, 包括客户端以及上述权 利要求 9~13任意一项所述的分布式队列消息读取设备,或上述权利要求 14~16 任意一项所述的分布式队列消息读取设备;  A distributed queue message reading system, comprising: a client, and the distributed queue message reading device according to any one of claims 9 to 13, or any one of claims 14 to 16 The distributed queue message reading device;
所述客户端, 用于发送获取消息请求给所述分布式队列消息读取设备, 以 及接收所述分布式队列消息读取设备发送的与所述获取消息请求对应的消息 进行业务处理。  The client is configured to send a get message request to the distributed queue message reading device, and receive a message corresponding to the get message request sent by the distributed queue message reading device for service processing.
PCT/CN2011/079241 2011-09-01 2011-09-01 Distributed queue message reading method, device and system WO2012162969A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2011/079241 WO2012162969A1 (en) 2011-09-01 2011-09-01 Distributed queue message reading method, device and system
CN201180001873.9A CN103503388B (en) 2011-09-01 2011-09-01 A kind of distributed queue's message read method and equipment, system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/079241 WO2012162969A1 (en) 2011-09-01 2011-09-01 Distributed queue message reading method, device and system

Publications (1)

Publication Number Publication Date
WO2012162969A1 true WO2012162969A1 (en) 2012-12-06

Family

ID=47258305

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/079241 WO2012162969A1 (en) 2011-09-01 2011-09-01 Distributed queue message reading method, device and system

Country Status (2)

Country Link
CN (1) CN103503388B (en)
WO (1) WO2012162969A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108197222B (en) * 2017-12-28 2020-03-24 北京中关村科金技术有限公司 Method, system and related device for repairing abnormal stream data
CN110245028B (en) * 2019-05-13 2023-08-25 平安科技(深圳)有限公司 Message storage method, device, computer equipment and storage medium of IoT-MQ
CN113127217A (en) * 2019-12-30 2021-07-16 中移(成都)信息通信科技有限公司 Data distribution method, device, equipment and storage medium
CN113794998B (en) * 2021-08-20 2022-07-15 上海德吾信息科技有限公司 Information sending method and device based on distributed lock and storage medium
CN114253745B (en) * 2021-12-16 2023-06-20 北京金堤科技有限公司 Message deduplication processing method and device, storage medium and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101547212A (en) * 2008-03-29 2009-09-30 华为技术有限公司 Method and system for scheduling distributed objects
CN102023974A (en) * 2009-09-14 2011-04-20 中国移动通信集团公司 Method, device and system for processing message by message queue
US20110208796A1 (en) * 2009-06-23 2011-08-25 Microsoft Corporation Using distributed queues in an overlay network

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050271049A1 (en) * 2004-06-03 2005-12-08 International Business Machines Corporation DHCP cache method and apparatus
GB0619644D0 (en) * 2006-10-05 2006-11-15 Ibm Data processing system and method of handling requests

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101547212A (en) * 2008-03-29 2009-09-30 华为技术有限公司 Method and system for scheduling distributed objects
US20110208796A1 (en) * 2009-06-23 2011-08-25 Microsoft Corporation Using distributed queues in an overlay network
CN102023974A (en) * 2009-09-14 2011-04-20 中国移动通信集团公司 Method, device and system for processing message by message queue

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CAO, JINGHUA ET AL.: "Design and Implementation of Distributed Message Queuing", JOURNAL OF HENAN UNIVERSITY OF SCIENCE & TECHNOLOGY (NATURAL SCIENCE)., vol. 31, no. 5, August 2010 (2010-08-01), pages 35 - 38 *

Also Published As

Publication number Publication date
CN103503388A (en) 2014-01-08
CN103503388B (en) 2016-08-03

Similar Documents

Publication Publication Date Title
US9792306B1 (en) Data transfer between dissimilar deduplication systems
US10255343B2 (en) Initialization protocol for a peer-to-peer replication environment
US10949405B2 (en) Data deduplication device, data deduplication method, and data deduplication program
US8121993B2 (en) Data sharing and recovery within a network of untrusted storage devices using data object fingerprinting
US20180013856A1 (en) Automatic data request recovery after session failure
WO2017049764A1 (en) Method for reading and writing data and distributed storage system
WO2017088705A1 (en) Data processing method and device
WO2010015143A1 (en) Distributed file system and data block consistency managing method thereof
US11093446B2 (en) Duplicate request checking for file system interfaces
JP2014517420A (en) File processing method, system, and server clustering system for cloud storage
EP3014512B1 (en) Reverse replication to rollback corrupted files
EP3844937B1 (en) Synchronizing in-use source data and an unmodified migrated copy thereof
WO2012162969A1 (en) Distributed queue message reading method, device and system
WO2017215646A1 (en) Data transmission method and apparatus
KR20090062747A (en) File storage system and method for managing duplicated files in the file storage system
US11082494B2 (en) Cross storage protocol access response for object data stores
US20230142613A1 (en) Recovering infected snapshots in a snapshot chain
WO2016101759A1 (en) Data routing method, data management device and distributed storage system
US11902452B2 (en) Techniques for data retrieval using cryptographic signatures
US8489698B2 (en) Apparatus and method for accessing a metadata
EP3349416B1 (en) Relationship chain processing method and system, and storage medium
JP6697101B2 (en) Information processing system
KR20080060243A (en) Productivity suite to line of business synchronization mechanism
US20210271554A1 (en) Method and system for a cloud backup service leveraging peer-to-peer data recovery
Rai et al. Deduplication of Data in the Cloud-based Server for Chat/File Transfer Application

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

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

Country of ref document: EP

Kind code of ref document: A1