davsclaus opened a new pull request, #29921:
URL: https://github.com/apache/camel/pull/29921

   Item 3 of [CAMEL-26930](https://issues.apache.org/jira/browse/CAMEL-26930).
   
   ## Problem
   
   `--jvm-debug`, `--jvm-args` and `--open-telemetry-agent` make `camel run` 
start the integration in a new JVM. `Run` does that with `jbang ... 
camel@apache/camel run ...` (`isDebugMode()` -> `runCamelVersion` -> 
`createCamelVersionCommand`), also under the Camel launcher:
   
   - Without jbang these options cannot work.
   - With jbang the run uses another Camel build (a remote SNAPSHOT, or 
Kamelets 4.22.0 when 4.23.0 was asked for) on jbang's JDK.
   
   `--camel-version` is refused under the launcher with a clear message; these 
options were not. On the launcher from main, with jbang not on `PATH`:
   
   ```
   $ camel run hello.yaml --jvm-args=-Dcamel26930.marker=yes --max-seconds=3
   ... java.io.IOException: Cannot run program "jbang" ...       # exit 70, 
stack trace
   ```
   
   ## Change
   
   - **Under the launcher**, and without `--camel-version`, `--jvm-debug` and 
`--jvm-args` run the integration in a new JVM of the launcher: the command of 
`LauncherHelper.getCamelCommand()` (java, its `-D`/`-X` options, `-jar` and the 
launcher JAR), with the JVM options added before `-jar`, and the run options 
without them.
     - `--jvm-debug=<port>` adds 
`-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:<port>`.
 The JVM waits for the debugger, as `jbang --debug` does.
     - `--background` and the JMX debugger suspend property work as with jbang. 
The new JVM is marked as spawned (CAMEL-26930 item 1), so it does not start 
another one.
   - **`--open-telemetry-agent` under the launcher** exits 2 with a message 
saying it needs the Camel CLI installed via JBang, as `--camel-version` does. 
The agent is a Maven artifact that jbang downloads.
   - **With jbang** (not the launcher), nothing changes.
   - **Docs:** "Java debugging" in `camel-jbang-debugging.adoc` describes both.
   
   After, on the launcher built from this branch:
   
   ```
   $ camel run hello.yaml --jvm-args=-Dcamel26930.marker=yes --background
   Running Camel Main: hello in background with PID: 38365 (waiting to startup)
   Camel Main: hello (state: Running)
   $ ps -o command= -p 38365     # java ... -Dcamel26930.marker=yes -jar 
.../lib/camel-launcher-4.24.0-SNAPSHOT.jar run hello.yaml
   $ camel run hello.yaml --jvm-debug=5099
   Listening for transport dt_socket at address: 5099
   ```
   
   ## Tests
   
   - `RunLauncherJvmCommandTest`: the JVM command for `--jvm-debug` (the jdwp 
agent before `-jar`, no `--jvm-debug` in the run options, no jbang), for 
`--jvm-args`, and with `--background`.
   - End to end with the launcher built from this branch, as above.
   - camel-jbang-run: 303 tests pass. camel-jbang-core: 3005 + 259 pass 
(`DependencyUpdateTest` failed once and passed on the rerun, as on other 
branches).
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to