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/09/29 03:40:44 UTC

[rocketmq-site] branch new-official-website updated: Pull Consumer (#200)

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

duhengforever pushed a commit to branch new-official-website
in repository https://gitbox.apache.org/repos/asf/rocketmq-site.git


The following commit(s) were added to refs/heads/new-official-website by this push:
     new a2c402ea  Pull Consumer (#200)
a2c402ea is described below

commit a2c402ea15833eed5725acc91a3b7d34d216c5d8
Author: RockChuLee <62...@users.noreply.github.com>
AuthorDate: Wed Sep 28 23:40:39 2022 -0400

     Pull Consumer (#200)
    
    * finally submit
    
    * change loci to offset.
    
    * update loci to offset
    
    * update loci to offset
    
    Co-authored-by: dinglei <li...@163.com>
---
 .../13pull.md"                                      | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/03-\346\266\210\350\264\271\350\200\205/13pull.md" "b/i18n/en/docusaurus-plugin-content-docs/current/03-\346\266\210\350\264\271\350\200\205/13pull.md"
index 1c0e53cd..05208c7b 100644
--- "a/i18n/en/docusaurus-plugin-content-docs/current/03-\346\266\210\350\264\271\350\200\205/13pull.md"
+++ "b/i18n/en/docusaurus-plugin-content-docs/current/03-\346\266\210\350\264\271\350\200\205/13pull.md"
@@ -1,10 +1,10 @@
-# Pull消费
+# Pull Consume
 
-在RocketMQ中有两种Pull方式,一种是比较原始`Pull Consumer`,它不提供相关的订阅方法,需要调用pull方法时指定队列进行拉取,并需要自己更新位点。另一种是`Lite Pull Consumer`,它提供了Subscribe和Assign两种方式,使用起来更加方便。
+There are two kinds of Pull methods in RocketMQ. `Pull Consumer` is the more primitive one, which does not provide related subscription methods, The queue should be specified to pull while calling the pull method, and it needs to update the offset itself. The other one is the `Lite Pull Consumer`, which provides Subscribe and Assign mode, making it more convenient to use.
 
 ## Pull Consumer
 
-Pull Consumer示例如下
+The Pull Consumer example is as follows:
 
 ```javascript
 public class PullConsumerTest {
@@ -31,13 +31,13 @@ public class PullConsumerTest {
 }
 ```
 
-首先需要初始化`DefaultMQPullConsumer`并启动,然后构造需要拉取的队列`MessageQueue`,除了构造外也可以如下所示调用`fetchSubscribeMessageQueues`方法获取某个Topic的所有队列,然后挑选队列进行拉取。
+First, the `DefaultMQPullConsumer` should be initialized and started, then constructs the queue `MessageQueue` to be pulled. Besides constructing it, `fetchSubscribeMessageQueues` method can also be called as shown below to get all the queues of a certain Topic and pull from the selected queue.
 
 ```java
 Set<MessageQueue> queueSet =  consumer.fetchSubscribeMessageQueues("TopicTest");
 ```
 
-找到或者构造完队列之后,调用pull方法就可以进行拉取,需要传入拉取的队列,过滤表达式,拉取的位点,最大拉取消息条数等参数。拉取完成后会返回拉取结果`PullResult`,PullResult中的PullStatus表示结果状态,如下所示
+After finding or constructing the queue, call the pull method to start pulling. The parameters such as the queue to be pulled, the filter expression, the offset to be pulled, and the maximum number of messages to be pulled should be passed in it. The `PullResult` will be returned after the operation is completed, and the PullStatus in the PullResult indicates the result status, as shown below:
 
 ```javascript
 public enum PullStatus {
@@ -60,11 +60,11 @@ public enum PullStatus {
 }
 ```
 
-FOUND表示拉取到消息,NO_NEW_MSG表示没有发现新消息,NO_MATCHED_MSG表示没有匹配的消息,OFFSET_ILLEGAL表示传入的拉取位点是非法的,有可能偏大或偏小。如果拉取状态是FOUND,我们可以通过`pullResult`的`getMsgFoundList`方法获取拉取到的消息列表。最后,如果消费完成,通过`updateConsumeOffset`方法更新消费位点。
+FOUND means the message was pulled, NO_NEW_MSG means no new message was found, NO_MATCHED_MSG means no matching message, OFFSET_ILLEGAL means the incoming pull offset are illegal and may be large or small. If the pull status is FOUND, we can get the list of pulled messages via the `getMsgFoundList` method of `PullResult`. Finally, if the consumption is complete, the consumption offset are updated via the `updateConsumeOffset` method.
 
 ## Lite Pull Consumer
 
-Lite Pull Consumer是RocketMQ 4.6.0推出的Pull Consumer,相比于原始的Pull Consumer更加简单易用,它提供了Subscribe和Assign两种模式,Subscribe模式示例如下
+Lite Pull Consumer is a Pull Consumer introduced in RocketMQ 4.6.0, which is simpler to use than the original Pull Consumer and provides two modes, Subscribe and Assign. The Subscribe mode example is as follows:
 
 ```javascript
 public class LitePullConsumerSubscribe {
@@ -86,9 +86,10 @@ public class LitePullConsumerSubscribe {
 }
 ```
 
-首先还是初始化`DefaultLitePullConsumer`并设置`ConsumerGroupName`,调用subscribe方法订阅topic并启动。与Push Consumer不同的是,`LitePullConsumer`拉取消息调用的是轮询poll接口,如果能拉取到消息则返回对应的消息列表,否则返回null。通过`setPullBatchSize`可以设置每一次拉取的最大消息数量,此外如果不额外设置,`LitePullConsumer`默认是自动提交位点。在subscribe模式下,同一个消费组下的多个`LitePullConsumer`会负载均衡消费,与PushConsumer一致。
+First of all, initialize `DefaultLitePullConsumer` and set `ConsumerGroupName`. Call the subscribe method afterward to subscribe to a topic and start it. Unlike the Push Consumer, `LitePullConsumer` pulls messages by the poll interface and returns the corresponding message list if it can pull the message, otherwise, it returns null. The maximum number of messages per pull can be set with `setPullBatchSize`, and the `LitePullConsumer` will automatically commits the offset by default. In t [...]
+
+The following is an example of the Assign mode:
 
-如下是Assign模式的示例
 ```javascript
 public class LitePullConsumerAssign {
     public static volatile boolean running = true;
@@ -117,4 +118,4 @@ public class LitePullConsumerAssign {
 }
 ```
 
-Assign模式一开始仍然是初始化`DefaultLitePullConsumer`,这里我们采用手动提交位点的方式,因此设置AutoCommit为false,然后启动consumer。与Subscribe模式不同的是,Assign模式下没有自动的负载均衡机制,需要用户自行指定需要拉取的队列,因此在例子中,先用fetchMessageQueues获取了Topic下的队列,再取前面的一半队列进行拉取,示例中还调用了seek方法,将第一个队列拉取的位点设置从10开始。紧接着进入循环不停地调用poll方法拉取消息,拉取到消息后调用commitSync方法手动提交位点。
\ No newline at end of file
+Assign mode still initializes `DefaultLitePullConsumer` at the beginning, here we use manual submission of offset, so set AutoCommit to false and then start the consumer. Unlike Subscribe mode, Assign mode does not have an automatic load balancing mechanism and requires the user to specify the queue to be pulled. Therefore, in the example, the queue under Topic is first fetched with fetchMessageQueues, and then half of the previous queue is fetched. The example also calls the seek method [...]