You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2019/02/27 15:04:37 UTC

[rocketmq] branch develop updated: [RIP-9] Add English document to Design_Query(#901)

This is an automated email from the ASF dual-hosted git repository.

dinglei pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4cce9b6  [RIP-9] Add English document to Design_Query(#901)
4cce9b6 is described below

commit 4cce9b6c769a9f419c39b6d7eae9cfd37e5d5b4c
Author: olderwei <ol...@163.com>
AuthorDate: Wed Feb 27 23:04:31 2019 +0800

    [RIP-9] Add English document to Design_Query(#901)
    
    [RIP-9] Add English document to Design_Query
---
 docs/en/Design_Query.md                          |  17 +++++++++++++++++
 docs/en/images/rocketmq_design_message_query.png | Bin 0 -> 26148 bytes
 2 files changed, 17 insertions(+)

diff --git a/docs/en/Design_Query.md b/docs/en/Design_Query.md
new file mode 100644
index 0000000..6988948
--- /dev/null
+++ b/docs/en/Design_Query.md
@@ -0,0 +1,17 @@
+# Message Queries
+
+RocketMQ supports message queries by two dimensions, which are "Query Message by Message Id" and "Query Message by Message Key".
+
+## 1. Query Message by Message Id
+The MessageId in RocketMQ has a total length of 16 bytes, including the broker address (IP address and port) and CommitLog offset. In RocketMQ, the specific approach is that the Client resolves the Broker's address (IP address and port) and the CommitLog's offset address from the MessageId. Then both of them are encapsulated into an RPC request, and finally it will be sent through the communication layer (business request code: VIEW_MESSAGE_BY_ID). The Broker reads a message by using the [...]
+
+## 2. Query Message by Message Id
+"Query Messages by Message Key" is mainly based on RocketMQ's IndexFile. The logical structure of the IndexFile is similar to the implementation of HashMap in JDK. The specific structure of the IndexFile is as follows:
+
+![](images/rocketmq_design_message_query.png)
+
+The IndexFile provides the user with the querying service by “Querying Messages by Message Key”. The IndexFile is stored in $HOME\store\index${fileName}, and the file name is named after the timestamp at the time of creation. The file size is fixed, which is 420,000,040 bytes (40+5million\*4+20million\*20). If the UNIQ_KEY is set in the properties of the message, then the "topic + ‘#’ + UNIQ_KEY" will be used as the index. Likewise, if the KEYS is set in the properties of the message (mu [...]
+
+The index data contains four fields, Key Hash, CommitLog offset, Timestamp and NextIndex offset, for a total of 20 Bytes. The NextIndex offset of the index data will point to the previous index data if the Key Hash of the index data is the same as that of the previous index data. If a hash conflict occurs, then the NextIndex offset can be used as the field to string all conflicting indexes in a linked list. What the Timestamp records is the time difference between two storeTimestamps, in [...]
+
+The specific method of "Query Message by Message Key" is that the topic and message key are used to find the record in the IndexFile, and then read the message from the file of CommitLog according to the CommitLog offset in this record.
\ No newline at end of file
diff --git a/docs/en/images/rocketmq_design_message_query.png b/docs/en/images/rocketmq_design_message_query.png
new file mode 100644
index 0000000..f5ca945
Binary files /dev/null and b/docs/en/images/rocketmq_design_message_query.png differ