summeriiii commented on code in PR #23305:
URL: https://github.com/apache/pulsar/pull/23305#discussion_r1766252524


##########
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:
   done



-- 
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-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to