You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by du...@apache.org on 2022/01/08 13:42:23 UTC
[rocketmq] branch develop updated: [ISSUE #3728] docs: Make the 'Uses of keys' entry in the document 'Best practices' more complete. (#3729)
This is an automated email from the ASF dual-hosted git repository.
duhengforever 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 1ef1af6 [ISSUE #3728] docs: Make the 'Uses of keys' entry in the document 'Best practices' more complete. (#3729)
1ef1af6 is described below
commit 1ef1af6a995ce61d434af52e2f498c9f3559e7d0
Author: 彭小漪 <64...@qq.com>
AuthorDate: Sat Jan 8 21:42:03 2022 +0800
[ISSUE #3728] docs: Make the 'Uses of keys' entry in the document 'Best practices' more complete. (#3729)
---
docs/en/best_practice.md | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/docs/en/best_practice.md b/docs/en/best_practice.md
index c50c5df..e9d0ee4 100755
--- a/docs/en/best_practice.md
+++ b/docs/en/best_practice.md
@@ -17,6 +17,19 @@ Since it is a hash index, make sure that the key is as unique as possible to avo
String orderId = "20034568923546";
message.setKeys(orderId);
```
+If you have multiple keys for a message, please concatenate them with 'KEY_SEPARATOR' char, as shown below:
+```java
+ // order id
+ String orderId = "20034568923546";
+ String otherKey = "19101121210831";
+ String keys = new StringBuilder(orderId)
+ .append(org.apache.rocketmq.common.message.MessageConst.KEY_SEPARATOR)
+ .append(otherKey).toString();
+ message.setKeys(keys);
+```
+And if you want to query the message, please use `orderId` and `otherKey` to query respectively instead of `keys`,
+because the server will unwrap `keys` with `KEY_SEPARATOR` and create corresponding index.
+In the above example, the server will create two indexes, one for `orderId` and one for `otherKey`.
#### 3 Log print
Print the message log when send success or failed, make sure to print the SendResult and key fields.
Send messages is successful as long as it does not throw exception. Send successful will have multiple states defined in sendResult.