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 2020/12/03 07:03:44 UTC

[GitHub] [pulsar] zymap commented on a change in pull request #8801: Add setter for the reader subscription name

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



##########
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:
       Overall looks good. I found if both the `subscriptionRolePrefix` and `subscriptionName` are specified, it will take the `subscriptionName`. Could you please also add a test case for this?




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