Croway opened a new pull request, #2013: URL: https://github.com/apache/camel-spring-boot/pull/2013
_Claude Code on behalf of Croway_ Spring Boot side of [CAMEL-25197](https://issues.apache.org/jira/browse/CAMEL-25197): the websocket transport of the Camel CLI connector uses Spring's WebSocket client when the application has it, and the JDK client otherwise, without adding any dependency to the application. **Depends on** apache/camel#27210 (the `CliWebSocketClient` SPI) and apache/camel#27214 (the application exits after the `stop` action). CI fails to compile until #27210 is merged and published as a snapshot. ## Changes - `SpringCliWebSocketClient`, a `CliWebSocketClient` on Spring's `StandardWebSocketClient` (Jakarta WebSocket, for example Tomcat's `tomcat-embed-websocket`): - sends through the asynchronous Jakarta remote endpoint, so the transport's send timeout can abort a hanging send; - reassembles partial messages itself, with the 16 MB cap of the SPI (the connection is aborted above it). Raising the Jakarta text buffer instead would allocate it for every connection: Tomcat allocates `maxTextMessageBufferSize` up front (`WsFrameBase`); - reports the HTTP status of a rejected handshake as a `CliWebSocketHandshakeException`: Jakarta WebSocket has no API for it, Tomcat puts it in the `DeploymentException` message (`[401]`); - Tomcat client options: 10 s connect timeout (as the JDK client), 10 s blocking send timeout (pings, close frames); - created lazily, so an application without a Jakarta WebSocket implementation still starts. - `CliConnectorAutoConfiguration`: registers it when `StandardWebSocketClient` and `jakarta.websocket.ContainerProvider` are on the classpath and there is no `CliWebSocketClient` bean. `spring-websocket` and `jakarta.websocket-client-api` are `<optional>`. A plain web application (`spring-boot-starter-web`) has Tomcat's Jakarta WebSocket but not `spring-websocket`, so it keeps the JDK client. `camel.cli.websocket.client=jdk` forces the JDK client (Camel option). - `camel.cli.websocket.ssl-bundle`: a Spring SSL bundle for `wss://` (`StandardWebSocketClient.setSslContext`, passed to `ClientEndpointConfig.getSSLContext()`, which Tomcat uses in `WsWebSocketContainer.createSSLEngine`). - `CliConnectorConfiguration`: `camel.cli.transport` and the `camel.cli.websocket.*` options, for configuration metadata (IDE completion). Camel reads them from the Spring environment. The starter now runs `spring-boot-configuration-processor` (it had no metadata). - `SpringLocalCliConnector`: the `stop` action (and `camel stop`) closes the application context instead of only stopping it, so the application exits (a stopped web application kept the JVM running). With apache/camel#27214, Spring Boot applications exit about 1 s after the `stop` action. - Docs: new starter page `starters/cli-connector.adoc` (generated from `src/main/doc`), and `cli-connector.json` regenerated. ## Tests - `CliConnectorAutoConfigurationTest` (`ApplicationContextRunner`): Spring client with `spring-websocket`; no bean without `StandardWebSocketClient` or without `jakarta.websocket` (`FilteredClassLoader`), so Camel uses the JDK client; an application bean wins; SSL bundle. - `SpringCliWebSocketClientTest`, against an embedded Tomcat WebSocket server: handshake headers, a 2 MB message (received in parts), ping/pong, close, abort, a message over 16 MB, a rejected handshake (HTTP 401). - `CliConnectorWebSocketSpringClientTest` / `CliConnectorWebSocketJdkClientTest`: a Spring Boot application with `camel.cli.transport=websocket` connects to the in-test tool, says `hello` with `transport` `spring` (or `jdk` with `camel.cli.websocket.client=jdk`), and executes an action. - `CliConnectorStopActionTest`: the `stop` action closes the application context. - `mvn install` in `dsl-starter/camel-cli-connector-starter`: 14 tests, 0 failures (against apache/camel#27210). - Soak (240 s, a tool server with a chaos proxy: the tool closes every connection, a network blackhole, the tool down, the token rejected), 6 applications: 2 Camel Main, 2 Spring Boot web applications (JDK client), 2 Spring Boot applications with `spring-boot-starter-websocket` (Spring client). Every application used the expected client, recovered from every disruption, reported the rejected token as HTTP 401, logged no unexpected error, and, with apache/camel#27214, exited about 1 s after the `stop` action. -- 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]
