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

 ##########
 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);
 
 Review comment:
   @jiazhai I think you misunderstood my comment. 
   
   I think a better solution is in `ConsumerBase`, we maintain two variables, 
one is `topicName`, the other is `topicPartitionName`. so when we construct 
`TopicMessageIdImpl`, it will use the strings constructed in `ConsumerBase`. 
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to