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:49:44 UTC
[GitHub] [pulsar] RobertIndie commented on a change in pull request #8801: Add setter for the reader subscription name
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:
users@infra.apache.org