codelipenghui commented on code in PR #16032:
URL: https://github.com/apache/pulsar/pull/16032#discussion_r895601353
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -997,4 +997,55 @@ public void testConsistencyOfTransactionStatsAtEndTxn()
throws Exception {
transaction.commit().get();
}
+
+ @Test
+ public void testPendingAckBatchMessageCommit() throws Exception {
+ String topic = NAMESPACE1 + "/testPendingAckBatchMessageCommit";
+
+ // enable batch index ack
+ conf.setAcknowledgmentAtBatchIndexLevelEnabled(true);
+
+ @Cleanup
+ Producer<byte[]> producer = pulsarClient
+ .newProducer(Schema.BYTES)
+ .topic(topic)
+ .enableBatching(true)
+ // ensure that batch message is sent
+ .batchingMaxPublishDelay(3, TimeUnit.SECONDS)
+ .sendTimeout(0, TimeUnit.SECONDS)
+ .create();
+
+ @Cleanup
+ Consumer<byte[]> consumer = pulsarClient
+ .newConsumer()
+ .subscriptionType(SubscriptionType.Shared)
+ .topic(topic)
+ .subscriptionName("sub")
+ .subscribe();
+
+ // send batch message, the size is 5
+ for (int i = 0; i < 5; i++) {
+ producer.sendAsync(("test" + i).getBytes());
+ }
+
Review Comment:
add producer.flush() here to avoid always waiting for 3 seconds
--
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]