davsclaus commented on code in PR #29459:
URL: https://github.com/apache/camel/pull/29459#discussion_r4511856229
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java:
##########
@@ -166,6 +186,18 @@ public Integer doCall() throws Exception {
if (timeout < 5000) {
timeout = 5000;
}
+ if (repeat < 0 || repeat > MAX_MESSAGES) {
+ throw CliException.usage("--repeat must be between 1 and " +
MAX_MESSAGES + ", was: " + repeat);
Review Comment:
For whole numbers `repeat != 0 && (repeat < 1 || repeat > MAX)` is the same
condition as `repeat < 0 || repeat > MAX`: 0 is the unset default (send once)
and passes both, -1 fails both with the same message. So I left it as it is.
_Claude Code on behalf of Claus Ibsen_
##########
dsl/camel-cli-connector/src/main/java/org/apache/camel/cli/connector/RepeatedSend.java:
##########
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.cli.connector;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.console.DevConsole;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * The send action with a repeat or a folder of messages ({@code camel cmd
send --repeat=50 --interval=200ms}, and
+ * {@code --body=file:<folder>/}): it sends the messages through the send dev
console one after another, with a pause
+ * between them, and answers with a summary when done (CAMEL-26767). It runs
on a thread of its own, so the status and
+ * the other actions of the connector go on meanwhile, and it stops when the
client gives up the request.
+ * <p/>
+ * The messages of a folder are its files in name order, one message per file,
leaving out hidden files and the
+ * {@code .properties} files: {@code 001.properties} has the headers of {@code
001.json}. The folder is read by the
+ * integration, relative to its working directory, as the file of a single
body is.
+ */
+final class RepeatedSend {
+
+ static final int MAX_MESSAGES = 10000;
+ static final long MAX_INTERVAL = 60000;
Review Comment:
Done: camel-jbang-core depends on camel-cli-connector, so
`RepeatedSend.MAX_MESSAGES` and `MAX_INTERVAL` are now public and
`CamelSendAction` uses them, one definition for both.
_Claude Code on behalf of Claus Ibsen_
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]