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 2022/05/31 11:41:24 UTC
[GitHub] [pulsar] eolivelli commented on a diff in pull request #15852: [fix][client] `ZeroQueueConsumer` may not increase the permit after unloading the topic.
eolivelli commented on code in PR #15852:
URL: https://github.com/apache/pulsar/pull/15852#discussion_r885530079
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ZeroQueueSizeTest.java:
##########
@@ -546,4 +550,53 @@ public void testPauseAndResumeNoReconnection() throws Exception {
assertEquals(receivedMessages.get(i).intValue(), i);
}
}
+
+ @Test(timeOut = 10000)
+ public void testReceiveAsyncWhenUnloadTopic() throws PulsarClientException, ExecutionException, InterruptedException {
+ final String topicName = "persistent://prop/cluster/namespace/topic-" + UUID.randomUUID();
+ int messageNumber = 500;
+ List<MessageId> messages = Collections.synchronizedList(new ArrayList<>());
+ @Cleanup
+ Consumer<byte[]> subscribe = pulsarClient.newConsumer()
+ .topic(topicName)
+ .subscriptionName("sub-11")
+ .subscriptionType(SubscriptionType.Shared)
+ .receiverQueueSize(0)
+ .consumerName("con-11")
+ .subscribe();
+
+ @Cleanup
+ Producer<byte[]> producer = pulsarClient.newProducer()
+ .enableBatching(false)
+ .messageRoutingMode(MessageRoutingMode.RoundRobinPartition)
+ .topic(topicName).create();
+ for (int i = 0; i < messageNumber; i++) {
+ MessageId msgId = producer.newMessage()
+ .value(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8))
+ .send();
+ messages.add(msgId);
+ }
+
+ @Cleanup("shutdown")
+ ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
+ executorService.scheduleWithFixedDelay(()-> {
Review Comment:
why are you using 'scheduleWithFixedDelay'?
are you trying to execute `unload` in parallel with `receiveAsync` ?
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org