diff --git a/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java b/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java index 2042b96e4d..a2aa963657 100644 --- a/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java +++ b/apis/src/main/java/org/apache/rocketmq/apis/consumer/MessageListener.java @@ -28,6 +28,11 @@ import org.apache.rocketmq.apis.message.MessageView; * desirable processing concurrency. * *
Refer to {@link PushConsumer} for more further specs. + * + *
+ * Thread Safety + * This class may be called concurrently by multiple threads. Implementation should be thread safe. + *
*/ public interface MessageListener { @@ -43,9 +48,9 @@ public interface MessageListener { * were raised, it will negatively acknowledgemessage, which
* would potentially get re-delivered after the configured back off period.
*
- * @param message Message to process.
+ * @param message The message passed to the listener.
* @return {@link ConsumeResult#SUCCESS} if message is properly processed; {@link ConsumeResult#FAILURE}
* otherwise.
*/
- ConsumeResult consume(MessageView message);
+ ConsumeResult onMessage(MessageView message);
}
diff --git a/apis/src/main/java/org/apache/rocketmq/apis/consumer/PushConsumer.java b/apis/src/main/java/org/apache/rocketmq/apis/consumer/PushConsumer.java
index cb89ff4e64..dc59ff69b8 100644
--- a/apis/src/main/java/org/apache/rocketmq/apis/consumer/PushConsumer.java
+++ b/apis/src/main/java/org/apache/rocketmq/apis/consumer/PushConsumer.java
@@ -24,25 +24,24 @@ import java.util.Map;
/**
- * PushConsumer is a thread-safe rocketmq client which is used to consume message by group.
+ * PushConsumer is a managed client which delivers messages to application through {@link MessageListener}.
*
- * Push consumer is fully-managed consumer, if you are confused to choose your consumer, push consumer should be - * your first consideration. + *
Consumers of the same group are designed to share messages from broker servers. As a result, consumers of the same + * group must have exactly identical subscription expressions, otherwise the behavior is undefined. * - *
Consumers belong to the same consumer group share messages from server, - * so consumer in the same group must have the same subscriptionExpressions, 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. + *
For a brand-new group, consumers consume messages from head of underlying queues, ignoring existing messages + * completely. In addition to delivering messages to clients, broker servers also maintain progress in perspective of + * group. Thus, consumers can safely restart and resume their progress automatically.
* - *You may intend to maintain different consumption progress for different consumer, different consumer group - * should be set in this case. + *
There are scenarios where fan-out is preferred, + * recommended solution is to use dedicated group of each client. * - *
To accelerate the message consumption, push consumer applies - * reactive streams - * . Messages received from server is cached locally before consumption, + *
To mitigate latency, PushConsumer adopts + * reactive streams pattern. Namely, + * messages received from broker servers are first cached locally, amount of which is controlled by * {@link PushConsumerBuilder#setMaxCacheMessageCount(int)} and - * {@link PushConsumerBuilder#setMaxCacheMessageSizeInBytes(int)} could be used to set the cache threshold in - * different dimension. + * {@link PushConsumerBuilder#setMaxCacheMessageSizeInBytes(int)}, and then dispatched to thread pool to achieve + * desirable concurrency. */ public interface PushConsumer extends Closeable { /**