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_r208814557
 
 

 ##########
 File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/TopicMessageImpl.java
 ##########
 @@ -40,10 +44,20 @@
     }
 
     /**
-     * Get the topic name of this message.
+     * Get the topic name without partition part of this message.
      * @return the name of the topic on which this message was published
      */
     public String getTopicName() {
+        int position = topicName.lastIndexOf(PARTITIONED_TOPIC_SUFFIX);
+        checkState(position != -1, "Topic Name not contains partition part. " 
+ topicName);
+        return topicName.substring(0, position);
 
 Review comment:
   Actually I think this is a bit expensive, if people calls getTopicName, it 
has to do `substring` on every call. Can we pass in `topicName` and 
`topicPartitionName` on constructing TopicMessageImpl?

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