Technoboy- commented on code in PR #23305:
URL: https://github.com/apache/pulsar/pull/23305#discussion_r1766047227
##########
pulsar-broker/src/test/java/org/apache/pulsar/client/api/NonDurableSubscriptionTest.java:
##########
@@ -256,6 +256,57 @@ public void
testNonDurableSubscriptionRecovery(SubscriptionType subscriptionType
}
+ @Test
+ public void testNonDurableSubscriptionBackLogAfterTopicUnload() throws
Exception {
+ String topicName =
"persistent://my-property/my-ns/nonDurable-sub-test";
+ String subName = "test-sub";
+
+ admin.topics().createNonPartitionedTopic(topicName);
+ Producer<byte[]> producer =
pulsarClient.newProducer().topic(topicName).create();
+
+ Consumer<byte[]> consumer = pulsarClient.newConsumer()
+ .topic(topicName)
+ .subscriptionName(subName)
+ .subscriptionMode(SubscriptionMode.NonDurable).subscribe();
+
+ // 1. send message
+ for (int i = 0; i < 10; i++) {
+ String message = "my-message-" + i;
+ producer.send(message.getBytes());
+ }
+ producer.close();
+
+
assertEquals(admin.topics().getStats(topicName).getSubscriptions().get(subName).getMsgBacklog(),
10);
+
+ // 2. receive the message
+ Thread t = new Thread(() -> {
+ while (true) {
+ Message<byte[]> msg;
+ try {
+ msg = consumer.receive();
+ consumer.acknowledge(msg);
+ } catch (PulsarClientException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ t.start();
Review Comment:
we don't need this thread, just consume it directly.
--
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]