From ddb07ab13c70292b7e63ef895da0bdf1c11f3eda Mon Sep 17 00:00:00 2001 From: Heng Du Date: Wed, 14 Aug 2019 17:27:31 +0800 Subject: [PATCH] Deprecated the DefaulteMQPull consumer (#1387) --- .../rocketmq/client/consumer/DefaultMQPullConsumer.java | 5 ++++- .../client/consumer/MQPullConsumerScheduleService.java | 4 +++- .../client/impl/consumer/DefaultLitePullConsumerImpl.java | 2 +- .../{LitePullConsumerTest.java => LitePullConsumer.java} | 6 +++--- 4 files changed, 11 insertions(+), 6 deletions(-) rename example/src/main/java/org/apache/rocketmq/example/simple/{LitePullConsumerTest.java => LitePullConsumer.java} (94%) diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java index 3fa3af24..e6d3f704 100644 --- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java +++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java @@ -35,8 +35,11 @@ import org.apache.rocketmq.remoting.RPCHook; import org.apache.rocketmq.remoting.exception.RemotingException; /** - * Default pulling consumer + * Default pulling consumer. + * This Consumer will be removed in 2022, and a better implementation {@link DefaultLitePullConsumer} is recommend to use + * in the scenario of actively pulling messages. */ +@Deprecated public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer { protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl; diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java index 685f4c8d..4dcc24b1 100644 --- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java +++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java @@ -31,7 +31,9 @@ import org.apache.rocketmq.common.message.MessageQueue; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; /** - * Schedule service for pull consumer + * Schedule service for pull consumer. + * This Consumer will be removed in 2022, and a better implementation {@link + * DefaultLitePullConsumer} is recommend to use in the scenario of actively pulling messages. */ public class MQPullConsumerScheduleService { private final InternalLogger log = ClientLogger.getLog(); diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java index e17aae65..8ff2b39c 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java @@ -758,7 +758,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner { if (subscriptionType == SubscriptionType.SUBSCRIBE) { String topic = this.messageQueue.getTopic(); subscriptionData = rebalanceImpl.getSubscriptionInner().get(topic); - } else{ + } else { String topic = this.messageQueue.getTopic(); subscriptionData = FilterAPI.buildSubscriptionData(defaultLitePullConsumer.getConsumerGroup(), topic, SubscriptionData.SUB_ALL); diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/LitePullConsumerTest.java b/example/src/main/java/org/apache/rocketmq/example/simple/LitePullConsumer.java similarity index 94% rename from example/src/main/java/org/apache/rocketmq/example/simple/LitePullConsumerTest.java rename to example/src/main/java/org/apache/rocketmq/example/simple/LitePullConsumer.java index 0430465c..b0a2b596 100644 --- a/example/src/main/java/org/apache/rocketmq/example/simple/LitePullConsumerTest.java +++ b/example/src/main/java/org/apache/rocketmq/example/simple/LitePullConsumer.java @@ -24,12 +24,12 @@ import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer; import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageQueue; -public class LitePullConsumerTest { +public class LitePullConsumer { public static void main(String[] args) throws Exception { - DefaultLitePullConsumer litePullConsumer = new DefaultLitePullConsumer("test"); + DefaultLitePullConsumer litePullConsumer = new DefaultLitePullConsumer("please_rename_unique_group_name"); litePullConsumer.setAutoCommit(false); litePullConsumer.start(); - Collection mqSet = litePullConsumer.fetchMessageQueues("test400"); + Collection mqSet = litePullConsumer.fetchMessageQueues("TopicTest"); List list = new ArrayList<>(mqSet); Collection assginMq = Collections.singletonList(list.get(0)); litePullConsumer.assign(assginMq); -- GitLab