lordcheng10 commented on code in PR #18633:
URL: https://github.com/apache/pulsar/pull/18633#discussion_r1035448678
##########
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) {
+ String errorLog = e.getMessage();
+ assertTrue(errorLog != null && errorLog.contains("Exclusive
consumer is already connected"));
+ }
Review Comment:
After all execution, I will close consumer1
--
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]