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/24 03:15:06 UTC

[GitHub] [pulsar] gaoran10 commented on a diff in pull request #15729: [improve][txn] Support ack message list for transaction

gaoran10 commented on code in PR #15729:
URL: https://github.com/apache/pulsar/pull/15729#discussion_r880019671


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -997,4 +998,47 @@ public void testConsistencyOfTransactionStatsAtEndTxn() throws Exception {
 
         transaction.commit().get();
     }
+
+    @Test
+    public void testTransactionAckMessageList() throws Exception {
+        String topic = "persistent://" + NAMESPACE1 +"/test";
+        String subName = "testSub";
+
+        Producer<byte[]> producer = pulsarClient.newProducer()

Review Comment:
   Please add the annotation `@Cleanup` for the producer.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -997,4 +998,47 @@ public void testConsistencyOfTransactionStatsAtEndTxn() throws Exception {
 
         transaction.commit().get();
     }
+
+    @Test
+    public void testTransactionAckMessageList() throws Exception {
+        String topic = "persistent://" + NAMESPACE1 +"/test";
+        String subName = "testSub";
+
+        Producer<byte[]> producer = pulsarClient.newProducer()
+                .topic(topic)
+                .sendTimeout(5, TimeUnit.SECONDS)
+                .create();
+        Consumer<byte[]> consumer = pulsarClient.newConsumer()
+                .topic(topic)
+                .subscriptionName(subName)
+                .subscribe();
+
+        for (int i = 0; i < 5; i++) {
+            producer.newMessage().send();
+        }
+        List<MessageId> messages = new ArrayList<>();
+        for (int i = 0; i < 4; i++) {
+            Message<byte[]> message = consumer.receive();
+            messages.add(message.getMessageId());
+        }
+        Transaction transaction = pulsarClient
+                .newTransaction()
+                .withTransactionTimeout(5, TimeUnit.MINUTES)
+                .build()
+                .get();
+
+        consumer.acknowledgeAsync(messages, transaction);
+        transaction.commit().get();
+
+        consumer.close();
+        consumer = pulsarClient.newConsumer()

Review Comment:
   Please close the consumer finally.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -997,4 +998,47 @@ public void testConsistencyOfTransactionStatsAtEndTxn() throws Exception {
 
         transaction.commit().get();
     }
+
+    @Test

Review Comment:
   Please add a timeout param for the test.



-- 
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