pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] sijie closed pull request #2629: [tests] improve BatchMessageTest#testSimpleBatchProducerConsumer
Date Sat, 22 Sep 2018 18:56:08 GMT
sijie closed pull request #2629: [tests] improve BatchMessageTest#testSimpleBatchProducerConsumer
URL: https://github.com/apache/pulsar/pull/2629
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java
index 5be8b150ae..1db8ed8922 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java
@@ -41,7 +41,6 @@
 import org.apache.pulsar.client.api.CompressionType;
 import org.apache.pulsar.client.api.Consumer;
 import org.apache.pulsar.client.api.Message;
-import org.apache.pulsar.client.api.MessageBuilder;
 import org.apache.pulsar.client.api.MessageId;
 import org.apache.pulsar.client.api.MessageRoutingMode;
 import org.apache.pulsar.client.api.Producer;
@@ -249,14 +248,24 @@ public void testSimpleBatchProducerConsumer(CompressionType compressionType)
thr
                 .subscribe();
         consumer.close();
 
-        Producer<byte[]> producer = pulsarClient.newProducer().topic(topicName).compressionType(compressionType)
-                .batchingMaxPublishDelay(5, TimeUnit.SECONDS).batchingMaxMessages(numMsgsInBatch).enableBatching(true)
-                .create();
+        Producer<byte[]> producer = pulsarClient.newProducer().topic(topicName)
+            .compressionType(compressionType)
+            .messageRoutingMode(MessageRoutingMode.SinglePartition)
+            // disabled time based batch by setting delay to a large enough value
+            .batchingMaxPublishDelay(60, TimeUnit.HOURS)
+            // disabled size based batch
+            .batchingMaxMessages(2 * numMsgs)
+            .enableBatching(true)
+            .create();
 
         List<CompletableFuture<MessageId>> sendFutureList = Lists.newArrayList();
         for (int i = 0; i < numMsgs; i++) {
             byte[] message = ("msg-" + i).getBytes();
             sendFutureList.add(producer.sendAsync(message));
+            if ((i + 1) % numMsgsInBatch == 0) {
+                producer.flush();
+                LOG.info("Flush {} messages", (i + 1));
+            }
         }
         FutureUtil.waitForAll(sendFutureList).get();
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message