Skip to content

CAMEL-25873: camel-milo - the reconnectTimeout option sets the delay between connection attempts - #28219

Merged
davsclaus merged 2 commits into
apache:mainfrom
etzel-mes:fix/CAMEL-25873-milo-reconnect-timeout
Oct 21, 2026
Merged

davsclaus merged 2 commits into
apache:mainfrom
etzel-mes:fix/CAMEL-25873-milo-reconnect-timeout

Conversation

@etzel-mes

Copy link
Copy Markdown
Contributor

Description

MiloClientComponent.setReconnectTimeout and MiloBrowseComponent.setReconnectTimeout set the request timeout of every service call (since the first version of each component), and the delay between two connection attempts was the literal 10000 ms in MiloClientConnection. Setting camel.component.milo-client.reconnectTimeout=2000 to retry faster therefore kept the 10 s delay and made every request time out after 2 s: a request that takes longer, such as a method call, failed with Bad_Timeout, the connection was rebuilt, and every consumer of the connection reported Bad_NoCommunication.

This adds a reconnectTimeout option to MiloClientConfiguration (label client, default 10000 ms, the previous delay), on both endpoints and through the component configuration, and both component setters now set it. It is the delay before Camel tries again to connect after an attempt failed, at startup or while Camel rebuilds a failed connection. The Milo client still recovers a lost session on its own, with its own timing. A value of 0 or less is rejected, because the client would then retry without pause while the server refuses the connection. setRequestTimeout names its parameter requestTimeout now.

Tests: ReconnectTimeoutConfigurationTest (default, endpoint option, both component setters, the request timeout left unset, a value that is not positive) and CommunicationLossTest#consumerStartedWithoutTheServerConnectsAfterTheConfiguredReconnectTimeout, which fails with the hard-coded delay. Also run against a real OPC UA server (node-opcua) that starts listening 35 s after the client starts, with a method that answers after 5 s:

attempts every method call
main, component property reconnectTimeout=2000 10 s Bad_Timeout after 2 s, connection rebuilt
this PR, component property reconnectTimeout=2000 2 s answered after 5 s
this PR, endpoint option reconnectTimeout=2000 2 s answered after 5 s
this PR, no option 10 s answered after 5 s

Without the new check, the endpoint option reconnectTimeout=0 made 54,272 connection attempts, each logged as a WARN, in the 21.5 s before the server listened; with it, the endpoint is rejected at startup with reconnectTimeout must be > 0, got: 0.

When the server was killed for 40 s after the client had connected, the option made no difference: in both runs the Milo client reconnected on its own back-off, about 16 s after the server listened again, and Camel then rebuilt the connection at once, because the restarted server no longer had the subscription.

Docs: the option (generated), the sentence of the component page on retrying after a certificate failure, and the 4.24 upgrade note. #28212 (CAMEL-25692) retries refused monitored items at this interval too; whichever of the two is merged second will also update its "every 10 seconds" sentences and the description of this option.

Fixes CAMEL-25873.

@davsclaus @oscerd

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

AI-assisted contributions

  • If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., Co-authored-by trailers) and the PR description identifies the AI tool used.

Claude Code on behalf of etzel-mes

…between connection attempts

The reconnectTimeout setter of the milo-client and milo-browse components set the request timeout of every
service call, and the delay between two connection attempts stayed fixed at 10 seconds. The new reconnectTimeout
option of the client configuration sets that delay, as an endpoint option and through the component configuration,
and both component setters now set it. Its default of 10000 milliseconds keeps the previous delay. A value of 0 or
less is rejected, because the client would try to connect again without pause.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Serdar for the careful analysis, and for testing against a real OPC UA server too. The bug is clear: both components' setReconnectTimeout called setRequestTimeout, and the delay between connection attempts was the literal 10_000 passed to SubscriptionManager. The new reconnectTimeout option on MiloClientConfiguration (default 10000, the previous delay) goes through the copy constructor, so endpoints inherit the component default, and MiloClientConnection hands it to SubscriptionManager, whose only use is the delay before it schedules connect. Rejecting values of 0 or less is a sensible guard against a tight retry loop.

Tests: ReconnectTimeoutConfigurationTest covers the default, the endpoint option, both component setters and the rejected values, and the new CommunicationLossTest case fails with the hard-coded delay. Both use JUnit assertions like the rest of the module, and timed MockEndpoint assertions rather than sleeps. The generated configurers, JSON, catalog and DSL files are included, and the behaviour change has a 4.24 upgrade-guide entry.

Non-blocking note:

  • The upgrade-guide entry tells users to call setRequestTimeout instead, but neither MiloClientComponent nor MiloBrowseComponent has such a method. There is an inline hint with a wording that points to the requestTimeout option.

Conventions check: the commit, branch and JIRA linkage (CAMEL-25873) follow the project guidelines. CI was still running when I looked.

This review covers project rules and conventions only. It does not replace CodeRabbit, Sourcery or SonarCloud.

Claude Code on behalf of Claus Ibsen

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

…ut option

The components have no setRequestTimeout method; the request timeout is the requestTimeout option of the configuration.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
@etzel-mes
etzel-mes force-pushed the fix/CAMEL-25873-milo-reconnect-timeout branch from a5957af to e3716c0 Compare October 21, 2026 10:39
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Serdar. The upgrade-guide sentence now points to the requestTimeout option, which both components expose, so my earlier point is addressed. Nothing else changed since my last review.

LGTM, once CI is green.

This review was generated by an AI agent (Claude Code on behalf of davsclaus) and may contain inaccuracies. Please verify all suggestions before applying.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-milo
  • docs
  • dsl/camel-componentdsl
  • dsl/camel-endpointdsl

🔁 1 test passed only after a retry on JDK 21 (1 retried attempt)

Recovered flaky tests on JDK 21 (1)
Module Test Failed attempts First failure
dsl/camel-jbang/camel-jbang-plugin-tui LaunchManagerOutcomeTest.startedWhenTheStatusFileSaysSo 1 expected: null but was: LaunchOutcome[ok=false, log=null]

ℹ️ These tests did not fail the build. Surefire retried them and they passed.
Retries are enabled project-wide by surefire.rerunFailingTestsCount in parent/pom.xml.


🔬 Scalpel shadow comparison — Scalpel: 8 of 707 tested, 23 compile-only — current: 8 all tested

Maveniverse Scalpel detected 8 affected modules (current approach: 8).

Skip-tests mode would test 8 modules (5 direct + 7 downstream), skip tests for 23 (generated code, meta-modules)

Modules Scalpel would test (8)
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-yaml-dsl-validator
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
  • camel-milo ← components/camel-milo/src/generated/java/org/apache/camel/component/milo/browse/MiloBrowseComponentConfigurer.java, components/camel-milo/src/generated/java/org/apache/camel/component/milo/browse/MiloBrowseEndpointConfigurer.java, components/camel-milo/src/generated/java/org/apache/camel/component/milo/browse/MiloBrowseEndpointUriFactory.java, components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientComponentConfigurer.java, components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientEndpointConfigurer.java, components/camel-milo/src/generated/java/org/apache/camel/component/milo/client/MiloClientEndpointUriFactory.java, components/camel-milo/src/generated/resources/META-INF/org/apache/camel/component/milo/browse/milo-browse.json, components/camel-milo/src/generated/resources/META-INF/org/apache/camel/component/milo/client/milo-client.json, components/camel-milo/src/main/docs/milo-client-component.adoc, components/camel-milo/src/main/java/org/apache/camel/component/milo/browse/MiloBrowseComponent.java, components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientComponent.java, components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConfiguration.java, components/camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java, components/camel-milo/src/test/java/org/apache/camel/component/milo/CommunicationLossTest.java, components/camel-milo/src/test/java/org/apache/camel/component/milo/ReconnectTimeoutConfigurationTest.java
  • camel-yaml-dsl-validator ← downstream of org.apache.camel:camel-catalog
  • camel-yaml-dsl-validator-maven-plugin ← downstream of org.apache.camel:camel-yaml-dsl-validator
Modules with tests skipped (23)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (35 modules, 5m 20s total)

Total reactor time: 5m 20s

Module Duration Status
Camel :: Launcher 47.6s SUCCESS
Camel :: JBang :: MCP 39.8s SUCCESS
Camel :: JBang :: Plugin :: Validate 29.1s SUCCESS
Camel :: Component DSL 27.8s SUCCESS
Camel :: Catalog :: Camel Catalog 23.2s SUCCESS
Camel :: YAML DSL 22.3s SUCCESS
Camel :: YAML DSL :: Validator 19.6s SUCCESS
Camel :: Kamelet Main 16.1s SUCCESS
Camel :: Docs 14.1s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 12.1s SUCCESS
Camel :: JBang :: Plugin :: Testing 10.9s SUCCESS
Camel :: YAML DSL :: Deserializers 8.5s SUCCESS
Camel :: Catalog :: Camel Route Parser 8.5s SUCCESS
Camel :: Catalog :: Camel Report Maven Plugin 7.3s SUCCESS
Camel :: All Components Sync point 4.8s SUCCESS
Camel :: YAML DSL :: Validator Maven Plugin 4.0s SUCCESS
Camel :: Assembly 3.6s SUCCESS
Camel :: YAML DSL :: Maven Plugins 3.1s SUCCESS
Camel :: Catalog :: Maven 3.0s SUCCESS
Camel :: Catalog :: Suggest (deprecated) 2.7s SUCCESS
Camel :: Coverage 1.6s SUCCESS
Camel :: JBang :: Plugin :: Edit 1.4s SUCCESS
Camel :: JBang :: Integration tests 1.4s SUCCESS
Camel :: JBang :: Plugin :: Generate 1.2s SUCCESS
Camel :: Catalog :: Dummy Component 1.1s SUCCESS
Camel :: Catalog :: Console 1.1s SUCCESS
Camel :: JBang :: Plugin :: MCP 0.9s SUCCESS
Camel :: JBang :: Main 0.9s SUCCESS
Camel :: Endpoint DSL :: Support 0.8s SUCCESS
Camel :: Launcher :: Container 0.8s SUCCESS
Camel :: Endpoint DSL n/a
Camel :: Integration Tests n/a
Camel :: JBang :: Core n/a
Camel :: JBang :: Plugin :: TUI n/a
Camel :: Milo n/a

Top 20 slowest modules:

  • Camel :: Launcher (47.6s)
  • Camel :: JBang :: MCP (39.8s)
  • Camel :: JBang :: Plugin :: Validate (29.1s)
  • Camel :: Component DSL (27.8s)
  • Camel :: Catalog :: Camel Catalog (23.2s)
  • Camel :: YAML DSL (22.3s)
  • Camel :: YAML DSL :: Validator (19.6s)
  • Camel :: Kamelet Main (16.1s)
  • Camel :: Docs (14.1s)
  • Camel :: JBang :: Plugin :: Kubernetes (12.1s)
  • Camel :: JBang :: Plugin :: Testing (10.9s)
  • Camel :: YAML DSL :: Deserializers (8.5s)
  • Camel :: Catalog :: Camel Route Parser (8.5s)
  • Camel :: Catalog :: Camel Report Maven Plugin (7.3s)
  • Camel :: All Components Sync point (4.8s)
  • Camel :: YAML DSL :: Validator Maven Plugin (4.0s)
  • Camel :: Assembly (3.6s)
  • Camel :: YAML DSL :: Maven Plugins (3.1s)
  • Camel :: Catalog :: Maven (3.0s)
  • Camel :: Catalog :: Suggest (deprecated) (2.7s)

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.24.0 milestone Oct 21, 2026
@davsclaus davsclaus added the bug Something isn't working label Oct 21, 2026
@davsclaus
davsclaus merged commit d2eff64 into apache:main Oct 21, 2026
7 checks passed
@etzel-mes
etzel-mes deleted the fix/CAMEL-25873-milo-reconnect-timeout branch October 23, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants