zhouxinyu commented on a change in pull request #4019:
URL: https://github.com/apache/rocketmq/pull/4019#discussion_r834911426



##########
File path: 
apis/src/main/java/org/apache/rocketmq/apis/consumer/PullConsumerBuilder.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.apis.consumer;
+
+import org.apache.rocketmq.apis.ClientConfiguration;
+import org.apache.rocketmq.apis.exception.ClientException;
+
+import java.time.Duration;
+
+public interface PullConsumerBuilder {
+    /**
+     * Set the client configuration for pull consumer.
+     *
+     * @param clientConfiguration client's configuration.
+     * @return the pull consumer builder instance.
+     */
+    PullConsumerBuilder setClientConfiguration(ClientConfiguration 
clientConfiguration);
+
+    /**
+     * Set the load balancing group for consumer.
+     *
+     * @param consumerGroup consumer load balancing group.
+     * @return the consumer builder instance.
+     */
+    PullConsumerBuilder setConsumerGroup(String consumerGroup);
+
+    /**
+     * Enable manual messageQueue assignment consumption mode.
+     * <p> The default mode is subscription mode which manage the rebalance 
operation triggered when group membership or cluster and topic metadata change.
+     * When pull consumer manual queue assignment mode, must invoke assign 
method before pull message.
+     * @return the consumer builder instance.
+     */
+    PushConsumerBuilder enableManualAssignment();

Review comment:
       Return PullConsumerBuilder

##########
File path: 
apis/src/main/java/org/apache/rocketmq/apis/consumer/PullConsumerBuilder.java
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.apis.consumer;
+
+import org.apache.rocketmq.apis.ClientConfiguration;
+import org.apache.rocketmq.apis.exception.ClientException;
+
+import java.time.Duration;
+
+public interface PullConsumerBuilder {
+    /**
+     * Set the client configuration for pull consumer.
+     *
+     * @param clientConfiguration client's configuration.
+     * @return the pull consumer builder instance.
+     */
+    PullConsumerBuilder setClientConfiguration(ClientConfiguration 
clientConfiguration);
+
+    /**
+     * Set the load balancing group for consumer.
+     *
+     * @param consumerGroup consumer load balancing group.
+     * @return the consumer builder instance.
+     */
+    PullConsumerBuilder setConsumerGroup(String consumerGroup);
+
+    /**
+     * Enable manual messageQueue assignment consumption mode.
+     * <p> The default mode is subscription mode which manage the rebalance 
operation triggered when group membership or cluster and topic metadata change.
+     * When pull consumer manual queue assignment mode, must invoke assign 
method before pull message.
+     * @return the consumer builder instance.
+     */
+    PushConsumerBuilder enableManualAssignment();
+
+    /**
+     * Set the max await time when receive message from server.
+     * <p> The simple consumer will hold this long-polling receive requests 
until  a message is returned or a timeout occurs.
+     * @param awaitDuration The maximum time to block when no message 
available.
+     * @return the consumer builder instance.
+     */
+    PushConsumerBuilder setAwaitDuration(Duration awaitDuration);

Review comment:
       Return PullConsumerBuilder

##########
File path: 
apis/src/main/java/org/apache/rocketmq/apis/consumer/SimpleConsumer.java
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.apis.consumer;
+
+import java.io.Closeable;
+import java.time.Duration;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import org.apache.rocketmq.apis.exception.*;
+import org.apache.rocketmq.apis.message.MessageView;
+
+/**
+ * SimpleConsumer is a thread-safe rocketmq client which is used to consume 
message by group.
+ *
+ * <p>Simple consumer is lightweight consumer , if you want fully control the 
message consumption operation by yourself,
+ * simple consumer should be your first consideration.
+ *
+ * <p>Consumers belong to the same consumer group share messages from server,
+ * so consumer in the same group must have the same {@link 
SubscriptionExpression}s, otherwise the behavior is
+ * undefined. If a new consumer group's consumer is started first time, it 
consumes from the latest position. Once
+ * consumer is started, server records its consumption progress and derives it 
in subsequent startup.
+ *
+ * <p>You may intend to maintain different consumption progress for different 
consumer, different consumer group
+ * should be set in this case.
+ *
+ * <p> Simple consumer divide message consumption to 3 parts.
+ * Firstly, call receive api get messages from server; Then process message by 
yourself; At last, your must call Ack api to commit this message.
+ * If there is error when process message ,your can reconsume the message 
later which control by the invisibleDuration parameter.
+ * Also, you can change the invisibleDuration by call changeInvisibleDuration 
api.
+ */
+public interface SimpleConsumer extends Closeable {
+    /**
+     * Get the load balancing group for simple consumer.
+     *
+     * @return consumer load balancing group.
+     */
+    String getConsumerGroup();
+
+    /**
+     * Add subscription expression dynamically.
+     *
+     * <p>If first {@link SubscriptionExpression} that contains topicA and 
tag1 is exists already in consumer, then
+     * second {@link SubscriptionExpression} which contains topicA and tag2, 
<strong>the result is that the second one
+     * replaces the first one instead of integrating them</strong>.
+     *
+     * @param subscriptionExpression new subscription expression to add.
+     * @return simple consumer instance.
+     */
+    SimpleConsumer subscribe(SubscriptionExpression subscriptionExpression) 
throws ClientException;

Review comment:
       Each consumer has subscription management and consumer group, consider 
abstract a super interface type?

##########
File path: 
apis/src/main/java/org/apache/rocketmq/apis/consumer/PullConsumer.java
##########
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.apis.consumer;
+
+import java.io.Closeable;
+import java.time.Duration;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import org.apache.rocketmq.apis.MessageQueue;
+import org.apache.rocketmq.apis.exception.*;
+import org.apache.rocketmq.apis.message.MessageView;
+
+/**
+ * <p>PullConsumer is a thread-safe rocketmq client which is used to consume 
message by queue.
+ * Unlike push consumer and simple consumer, pull consumer implement load 
balance based on queue granularity.
+ *
+ * <p>Pull consumer is lightweight consumer that better suited to streaming 
scenarios.
+ * If you want fully control the message consumption operation by yourself 
like scan by offset or reconsume repeatedly,
+ * pull consumer should be your first consideration.
+ *
+ * <p>Pull consumer support two load balance mode. First is subscription mode, 
which full manage the rebalance

Review comment:
       two load balance modes.

##########
File path: 
apis/src/main/java/org/apache/rocketmq/apis/consumer/SimpleConsumer.java
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.rocketmq.apis.consumer;
+
+import java.io.Closeable;
+import java.time.Duration;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+import org.apache.rocketmq.apis.exception.*;
+import org.apache.rocketmq.apis.message.MessageView;
+
+/**
+ * SimpleConsumer is a thread-safe rocketmq client which is used to consume 
message by group.
+ *
+ * <p>Simple consumer is lightweight consumer , if you want fully control the 
message consumption operation by yourself,
+ * simple consumer should be your first consideration.

Review comment:
       Consider adding the difference between SimpleConsumer and PullConsumer.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to