-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cli] Enable CLI to publish non-batched messages #12641
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -107,6 +107,9 @@ public class CmdProduce { | |||
description = "Rate (in msg/sec) at which to produce," + | ||||
" value 0 means to produce messages as fast as possible.") | ||||
private double publishRate = 0; | ||||
|
||||
@Parameter(names = { "-db", "--disable-batching" }, description = "Disable batch sending of messages") | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It better to named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, boolean type options do not require a value, so the default value should be false. # By default batching is enabled
$ ./bin/pulsar-client produce -m hello persistent://public/default/t1
# Batching is enabled in this case as well
$ ./bin/pulsar-client produce -m hello --batch-enabled persistent://public/default/t1 We can set the default value to true by specifying # Batching is enabled
$ ./bin/pulsar-client produce -m hello --batch-enabled true persistent://public/default/t1
# Batching is disabled
$ ./bin/pulsar-client produce -m hello --batch-enabled false persistent://public/default/t1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that makes sense. How about keeping the same configurations with the perf producer?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the pulsar/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java Line 297 in 3c770a1
So, unlike the perf producer, I don't think such fine-grained settings are useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no particular benefit to enabling batching for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that make sense. |
||||
private boolean disableBatching = false; | ||||
|
||||
@Parameter(names = { "-c", | ||||
"--chunking" }, description = "Should split the message and publish in chunks if message size is larger than allowed max size") | ||||
|
@@ -247,6 +250,8 @@ private int publish(String topic) { | |||
if (this.chunkingAllowed) { | ||||
producerBuilder.enableChunking(true); | ||||
producerBuilder.enableBatching(false); | ||||
} else if (this.disableBatching) { | ||||
producerBuilder.enableBatching(false); | ||||
} | ||||
if (isNotBlank(this.encKeyName) && isNotBlank(this.encKeyValue)) { | ||||
producerBuilder.addEncryptionKey(this.encKeyName); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that you have not checked if the message is from a batch message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check not enough? Is there any other good way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, my mistake. It's good.