You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/04/12 08:16:54 UTC

[GitHub] [pulsar] wangjialing218 commented on a change in pull request #10129: fix the default retry letter and dead letter topic name

wangjialing218 commented on a change in pull request #10129:
URL: https://github.com/apache/pulsar/pull/10129#discussion_r611418959



##########
File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerBuilderImpl.java
##########
@@ -121,8 +117,29 @@ public ConsumerBuilderImpl(PulsarClientImpl client, Schema<T> schema) {
         }
         if(conf.isRetryEnable() && conf.getTopicNames().size() > 0 ) {
             TopicName topicFirst = TopicName.get(conf.getTopicNames().iterator().next());
-            String retryLetterTopic = topicFirst.getNamespace() + "/" + conf.getSubscriptionName() + RetryMessageUtil.RETRY_GROUP_TOPIC_SUFFIX;
-            String deadLetterTopic = topicFirst.getNamespace() + "/" + conf.getSubscriptionName() + RetryMessageUtil.DLQ_GROUP_TOPIC_SUFFIX;
+            String retryLetterTopic = topicFirst + "-" + conf.getSubscriptionName() + RetryMessageUtil.RETRY_GROUP_TOPIC_SUFFIX;
+            String deadLetterTopic = topicFirst + "-" + conf.getSubscriptionName() + RetryMessageUtil.DLQ_GROUP_TOPIC_SUFFIX;
+
+            //Issue 9327: do compatibility check in case of the default retry and dead letter topic name changed
+            String oldRetryLetterTopic = topicFirst.getNamespace() + "/" + conf.getSubscriptionName() + RetryMessageUtil.RETRY_GROUP_TOPIC_SUFFIX;
+            String oldDeadLetterTopic = topicFirst.getNamespace() + "/" + conf.getSubscriptionName() + RetryMessageUtil.DLQ_GROUP_TOPIC_SUFFIX;
+            try {
+                PartitionedTopicMetadata partitionedTopicMetadata = client.getLookup().getPartitionedTopicMetadata(TopicName.get(oldRetryLetterTopic)).get();
+                if (partitionedTopicMetadata.partitions > 0) {
+                    retryLetterTopic = oldRetryLetterTopic;
+                }
+            } catch (Exception e) {
+                // oldRetryLetterTopic not exist, do nothing

Review comment:
       change lookup method so that it could have a retry in case of  retriable error




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org