RobertIndie commented on a change in pull request #8801:
URL: https://github.com/apache/pulsar/pull/8801#discussion_r534841423



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ReaderTest.java
##########
@@ -397,4 +396,32 @@ public void testKeyHashRangeReader() throws IOException {
         }
 
     }
+
+    @Test
+    public void testReaderSubName() throws Exception {
+        final String topic = 
"persistent://my-property/my-ns/testReaderSubName";
+        final String subName = "my-sub-name";
+
+        Reader<String> reader = pulsarClient.newReader(Schema.STRING)
+                .subscriptionName(subName)
+                .topic(topic)
+                .startMessageId(MessageId.earliest)
+                .create();
+        ReaderImpl<String> readerImpl = (ReaderImpl<String>) reader;
+        assertEquals(readerImpl.getConsumer().getSubscription(), subName);
+        reader.close();
+
+        final String topic2 = 
"persistent://my-property/my-ns/testReaderSubName2";
+        admin.topics().createPartitionedTopic(topic2, 3);
+
+        reader = pulsarClient.newReader(Schema.STRING)
+                .subscriptionName(subName)
+                .topic(topic2)
+                .startMessageId(MessageId.earliest)
+                .create();
+        MultiTopicsReaderImpl<String> multiTopicsReader = 
(MultiTopicsReaderImpl<String>) reader;
+        multiTopicsReader.getMultiTopicsConsumer().getConsumers()
+                .forEach(consumerImpl -> 
assertEquals(consumerImpl.getSubscription(), subName));
+        multiTopicsReader.close();
+    }

Review comment:
       It would be better if we could add this test case: when creating two 
readers with the same `subscriptionName` at the same time, the second one 
should fail.
   
   




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


Reply via email to