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/04/18 05:46:12 UTC

[GitHub] [rocketmq] aaron-ai commented on a diff in pull request #4019: [RIP-37] Add new APIs for consumer

aaron-ai commented on code in PR #4019:
URL: https://github.com/apache/rocketmq/pull/4019#discussion_r851893605


##########
apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.util.Collection;
+import org.apache.rocketmq.apis.message.MessageView;
+
+/**
+ * MessageListener is used only for push consumer to process message consumption synchronously.
+ *
+ * <p> Refer to {@link PushConsumer}, push consumer will get message from server
+ * and dispatch the message to backend thread pool which control by parameter threadCount to consumer message concurrently.
+ */
+public interface MessageListener {
+    /**
+     * The callback interface for consume message. Your should process the collection of messageViews
+     * and put committed messageViews to committedList. Push consumer will commit the committedList to server.
+     * If consume message throw unexpected exception, Push consumer also commit the committedList.
+     * @param messageViews are batch of messages which need consume. this message in the collection may come from different topics and the collection size control by setBatchSize(int batchSize) in {@link PushConsumerBuilder}
+     * @param ackList are collection of messages which already consume success and need ack to server.
+     */
+    void consume(Collection<MessageView> messageViews, Collection<MessageView> ackList);

Review Comment:
   > Do we consider replacing `ackList` with `failedList`? The code will look cleaner if all messages succeed.
   
   How do we define this behavior that exception is thrown during the invocation of `MessageListener`? Agree with your opinion to some degree, I feel anxious about user forget to put message into the `ackList` explicitly, which may cause a bulk of retry-messages.



-- 
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