lordcheng10 commented on code in PR #18633:
URL: https://github.com/apache/pulsar/pull/18633#discussion_r1035452413
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/TopicsConsumerImplTest.java:
##########
@@ -539,6 +540,38 @@ public void testTopicNameValid() throws Exception{
}).get();
}
+ @Test
+ public void testExclusiveSubscribe() throws Exception {
+ final String topicName =
"persistent://prop/use/ns-abc/testTopicNameValid";
+ TenantInfoImpl tenantInfo = createDefaultTenantInfo();
+ admin.tenants().createTenant("prop", tenantInfo);
+ admin.topics().createPartitionedTopic(topicName, 3);
+ List<Integer> partitions = new ArrayList<>();
+ for (int i = 0; i < 3; i++) {
+ partitions.add(i);
+ }
+ List<String> realTopics = partitions.stream()
+ .map(idx -> topicName + "-partition-" + idx)
+ .collect(Collectors.toList());
+ Consumer<byte[]> consumer1 = pulsarClient.newConsumer()
+ .topics(realTopics)
+ .subscriptionName("subscriptionName")
+ .subscriptionType(SubscriptionType.Exclusive)
+ .subscribeAsync().get(10, TimeUnit.SECONDS);
+
+
+ try {
+ Consumer<byte[]> consumer2 = pulsarClient.newConsumer()
+ .topics(realTopics)
+ .subscriptionName("subscriptionName")
+ .subscriptionType(SubscriptionType.Exclusive)
+ .subscribeAsync().get(10, TimeUnit.SECONDS);
+ } catch (Exception e) {
Review Comment:
After using the subscribe() interface instead of subscribeAsync().get(10,
TimeUnit.SECONDS), there will be no TimeoutException.
There will only be PulsarClientException, so I use PulsarClientException
instead
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]