davsclaus commented on code in PR #29935:
URL: https://github.com/apache/camel/pull/29935#discussion_r4575038681
##########
core/camel-console/src/main/java/org/apache/camel/impl/console/SendDevConsole.java:
##########
@@ -84,7 +90,7 @@ public record Response(
javaType = "java.lang.Boolean")
public static final String POLL = "poll";
- @Metadata(label = "query", description = "Timeout when using poll mode",
+ @Metadata(label = "query", description = "Timeout of the send, or of the
poll in poll mode, in millis",
javaType = "java.lang.Integer", defaultValue = "20000")
public static final String POLL_TIMEOUT = "pollTimeout";
Review Comment:
Kept as is: `pollTimeout` is the option key of the send console that the CLI
(`camel cmd send --timeout`), the TUI and the MCP tools pass, and
`POLL_TIMEOUT` is its constant. Renaming it changes that contract for every
caller in one release; the description now says it is the timeout of the send,
or of the poll in poll mode.
_Claude Code on behalf of davsclaus_
##########
core/camel-console/src/test/java/org/apache/camel/impl/console/SendDevConsoleTest.java:
##########
@@ -72,6 +75,62 @@ public void testSendConsoleBasic() {
assertNotNull(jsonOut.getString("endpoint"));
}
+ @Test
+ public void testSendIsBoundedByTheTimeout() {
+ // the timeout was for --poll only: the send waited as long as the
route took (CAMEL-26929)
+ DevConsole console = startedSendConsole();
+
+ Map<String, Object> options = createOptions("direct:slow", "Hello");
+ options.put(SendDevConsole.POLL_TIMEOUT, "200");
+ JsonObject out = callJson(console, options);
+
+ assertEquals("timeout", out.getString("status"), out.toJson());
+ assertTrue(out.getLong("elapsed") < 1500, "answered at the timeout: "
+ out.toJson());
Review Comment:
Done in 1cfceac445df: the slow route takes 5 s and the bound is 4 s (20x the
200 ms timeout); the `timeout` status proves the send timed out anyway. The
direct-without-consumer bound is 10 s, against the 30 s direct waits.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendActionResultTest.java:
##########
@@ -58,14 +58,26 @@ void sendsTheMessage() throws Exception {
assertThat(action.getString("endpoint")).isEqualTo("direct:start");
assertThat(action.getString("body")).isEqualTo("hello");
assertThat(action.getString("exchangePattern")).isEqualTo("InOnly");
- // the timeout is at least 5 seconds
- assertThat(action.getLong("pollTimeout")).isEqualTo(5000L);
+ // the timeout as given: it was raised to 5 seconds without a word,
and the integration bounds the send by it
+ // (CAMEL-26929)
+ assertThat(action.getLong("pollTimeout")).isEqualTo(100L);
JsonArray headers = action.getCollection("headers");
JsonObject header = headers.getMap(0);
assertThat(header.getString("key")).isEqualTo("id");
assertThat(header.getString("value")).isEqualTo("1");
}
+ @Test
+ void aTimeoutOfZeroIsAUsageError() throws Exception {
+ writeStatusFile(TEST_PID, "orders");
+
+ assertThatThrownBy(() -> callWithResponse(command("orders",
"--endpoint=direct:start", "--timeout=0"),
+ answer("success")))
+ .isInstanceOfSatisfying(CliException.class,
+ e ->
assertThat(e.getExitCode()).isEqualTo(CliExitCode.USAGE))
+ .hasMessage("--timeout must be more than 0, was: 0");
Review Comment:
Done in 1cfceac445df: `--timeout=-1` is a usage error too, in the same test.
_Claude Code on behalf of davsclaus_
--
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]