You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/01/12 03:48:54 UTC

[GitHub] [rocketmq] tianliuliu commented on a change in pull request #3694: [RIP-28] light message queue(LMQ)

tianliuliu commented on a change in pull request #3694:
URL: https://github.com/apache/rocketmq/pull/3694#discussion_r782689625



##########
File path: docs/cn/Example_LMQ.md
##########
@@ -0,0 +1,75 @@
+# Light message queue (LMQ)
+
+
+## 一、broker启动配置
+
+
+broker.conf文件需要增加以下的配置项,开启LMQ开关,这样就可以识别LMQ相关属性的消息,进行原子分发消息到LMQ队列
+```properties
+enableLmq = true
+enableMultiDispatch = true
+```
+## 二、发送消息
+发送消息的时候通过设置 INNER_MULTI_DISPATCH 属性,LMQ queue使用逗号分割,queue前缀必须是 %LMQ%,这样broker就可以识别LMQ queue.
+```java
+DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
+producer.setNamesrvAddr("name-server1-ip:9876;name-server2-ip:9876");
+producer.start();
+
+
+/*
+* Create a message instance, specifying topic, tag and message body.
+*/
+Message msg = new Message("TopicTest" /* Topic */,
+                          "TagA" /* Tag */,
+                          ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */
+                         );
+/*
+* INNER_MULTI_DISPATCH property and PREFIX must start as "%LMQ%",
+* If it is multiple LMQ, need to use “,” split
+*/
+message.putUserProperty("INNER_MULTI_DISPATCH", "%LMQ%123,%LMQ%456");
+/*
+* Call send message to deliver message to one of brokers.
+*/
+SendResult sendResult = producer.send(msg);
+```
+## 三、拉取消息
+LMQ queue在每个broker上只有一个queue,也即queueId为0, 指明轻量级的MessageQueue,就可以拉取消息进行消费。
+```java
+DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer();
+defaultMQPullConsumer.setNamesrvAddr("name-server1-ip:9876;name-server2-ip:9876");
+defaultMQPullConsumer.setVipChannelEnabled(false);
+defaultMQPullConsumer.setConsumerGroup("CID_RMQ_SYS_LMQ_TEST");
+defaultMQPullConsumer.setInstanceName("CID_RMQ_SYS_LMQ_TEST");
+defaultMQPullConsumer.setRegisterTopics(new HashSet<>(Arrays.asList("TopicTest")));
+defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(2000);
+defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(3000);
+defaultMQPullConsumer.start();
+
+String brokerName = "set broker Name";
+MessageQueue mq = new MessageQueue("%LMQ%123", brokerName, 0);
+
+Long offset = defaultMQPullConsumer.maxOffset(mq);
+
+defaultMQPullConsumer.pullBlockIfNotFound(

Review comment:
       1. request queueId[3] is illegal, TopicConfig [topicName=TopicTest, readQueueNums=1, writeQueueNums=1, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false] Producer: 172.18.40.26:50188 BROKER: 172.18.40.26:10911
   For more information, please visit the url, http://rocketmq.apache.org/docs/faq/
   
   TopicTest 多创建几个队列就可以了 这个只有一个队列 所以队列queueId 3拿不到
   2. broker-a 不存在问题 就是你部署的mq集群中,没有这个broke




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org