apache/pulsar · error · IllegalArgumentException
Attempting to send ${totalMessages} messages. Please do not
Error message
Attempting to send ${totalMessages} messages. Please do not send more than ${MAX_MESSAGES} messages What it means
CmdProduce guards against accidental message floods: total messages = (inline messages + files) * numTimesProduce. If the total exceeds the CLI's MAX_MESSAGES cap, IllegalArgumentException is thrown before any client is created, protecting the broker from an accidental bulk publish.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java:273
if (messages.size() == 0 && messageFileNames.size() == 0) {
throw new CommandLine.ParameterException(commandSpec.commandLine(),
"Please supply message content with either --messages or --files");
}
if (keyValueEncodingType == null) {
keyValueEncodingType = KEY_VALUE_ENCODING_TYPE_NOT_SET;
} else if (!KEY_VALUE_ENCODING_TYPE_NOT_SET.equals(keyValueEncodingType)) {
// KeyValue schemas are not yet supported by the V5-based pulsar-client.
throw new IllegalArgumentException("KeyValue schemas (--key-value-encoding-type) are not "
+ "supported by this version of pulsar-client; produce with a plain value schema "
+ "(-vs bytes|string|avro:<def>|json:<def>) instead.");
}
int totalMessages = (messages.size() + messageFileNames.size()) * numTimesProduce;
if (totalMessages > MAX_MESSAGES) {
String msg = "Attempting to send " + totalMessages + " messages. Please do not send more than "
+ MAX_MESSAGES + " messages";
throw new IllegalArgumentException(msg);
}
if (this.serviceURL.startsWith("ws")) {
return publishToWebSocket(topic);
} else {
return publish(topic);
}
}
private int publish(String topic) {
int numMessagesSent = 0;
int returnCode = 0;
if (this.disableReplication) {
log.warn("--disable-replication has no effect on this version of pulsar-client and is ignored.");
}
try (PulsarClient client = clientBuilder.build()) {View on GitHub (pinned to 820761864e)
Solutions
- Lower --num-times-produce (-n) so totalMessages stays within the cap.
- Reduce the number of --messages/--files entries in a single invocation and loop the command instead.
- If you need bulk loads, use the official perf tool (pulsar-perf produce) rather than the CLI.
Example fix
// before pulsar-client produce t -m 'a' -m 'b' -n 100000 // 200000 > MAX_MESSAGES // after pulsar-client produce t -m 'a' -m 'b' -n 100 // 200 <= MAX_MESSAGES
Defensive patterns
Strategy: validation
Validate before calling
// compute the total first
TOTAL=$(( $(printf '%s\n' "$MSGS" | wc -l) * N )); [ "$TOTAL" -le 1000 ] || { echo "too many messages: $TOTAL"; exit 1; } Prevention
- Keep -n (num-times-produce) small; the CLI is not a load generator.
- Use pulsar-perf produce for bulk/stress publishing.
- Compute (messages + files) * n before running and cap it.
When it happens
Trigger: Passing many -m values or -f files combined with a large --num-times-produce (-n) so the product exceeds MAX_MESSAGES (e.g. -n 100000 with 10 messages).
Common situations: Stress-testing scripts that reuse a CLI designed for spot checks; mistyping -n (e.g. -n 1000000 instead of 1000); looping with a high multiplier to 'warm up' a topic.
Related errors
- ${paramName} cannot be bigger than <${maxValue}>!
- ${paramName} cannot be less than or equal to <0>!
- The value of ${paramName} can't be empty
- ${name} cannot be less than <${min}>!
- byte string cannot be empty
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/6d2258cf14d06c24.
Report an issue: GitHub.