merlimat commented on a change in pull request #2346: Issue #2330: change 
getTopicName in MultiTopicsConsumer
URL: https://github.com/apache/incubator-pulsar/pull/2346#discussion_r209462044
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/TopicMessageIdImpl.java
 ##########
 @@ -18,20 +18,45 @@
  */
 package org.apache.pulsar.client.impl;
 
+import static com.google.common.base.Preconditions.checkState;
+import static 
org.apache.pulsar.common.naming.TopicName.PARTITIONED_TOPIC_SUFFIX;
+
 import java.util.Objects;
 import org.apache.pulsar.client.api.MessageId;
 
 public class TopicMessageIdImpl implements MessageId {
+
+    /** This topicPartitionName is get from ConsumerImpl, it contains 
partition part. */
+    private final String topicPartitionName;
     private final String topicName;
     private final MessageId messageId;
 
-    TopicMessageIdImpl(String topicName, MessageId messageId) {
-        this.topicName = topicName;
+    TopicMessageIdImpl(String topicPartitionName, MessageId messageId) {
         this.messageId = messageId;
+        this.topicPartitionName = topicPartitionName;
+
+        int position = 
topicPartitionName.lastIndexOf(PARTITIONED_TOPIC_SUFFIX);
+        if (position != -1) {
+            this.topicName = topicPartitionName.substring(0, position);
+        } else {
+            this.topicName = topicPartitionName;
+        }
 
 Review comment:
   This will potentially create strings for each received message

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to