Skip to content

Commit

Permalink
Fix batching time in perf producer to allow to disable batching (apac…
Browse files Browse the repository at this point in the history
…he#2244)

### Motivation

Allow to disable batching in perf producer or to configure a grouping time < 1 millis.
  • Loading branch information
merlimat authored and sijie committed Jul 27, 2018
1 parent 5b9dc23 commit 46e6ea8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static class Arguments {
public String payloadFilename = null;
@Parameter(names = { "-b",
"--batch-time-window" }, description = "Batch messages in 'x' ms window (Default: 1ms)")
public long batchTime = 1;
public double batchTimeMillis = 1.0;

@Parameter(names = { "-time",
"--test-duration" }, description = "Test duration in secs. If 0, it will keep publishing")
Expand Down Expand Up @@ -272,8 +272,12 @@ public EncryptionKeyInfo getPrivateKey(String keyName, Map<String, String> keyMe
// enable round robin message routing if it is a partitioned topic
.messageRoutingMode(MessageRoutingMode.RoundRobinPartition);

if (arguments.batchTime > 0) {
producerBuilder.batchingMaxPublishDelay(arguments.batchTime, TimeUnit.MILLISECONDS).enableBatching(true);
if (arguments.batchTimeMillis == 0.0) {
producerBuilder.enableBatching(false);
} else {
long batchTimeUsec = (long) (arguments.batchTimeMillis * 1000);
producerBuilder.batchingMaxPublishDelay(batchTimeUsec, TimeUnit.MICROSECONDS)
.enableBatching(true);
}

// Block if queue is full else we will start seeing errors in sendAsync
Expand Down

0 comments on commit 46e6ea8

Please sign in to comment.