Skip to content

Add connectionStartupTimeout for resilience against Siri ET MQTT broker unavailability #7489

Merged
jessicaKoehnke merged 2 commits intoopentripplanner:dev-2.xfrom
HBTGmbH:mqtt-connection-resilience
Apr 10, 2026
Merged

Add connectionStartupTimeout for resilience against Siri ET MQTT broker unavailability #7489
jessicaKoehnke merged 2 commits intoopentripplanner:dev-2.xfrom
HBTGmbH:mqtt-connection-resilience

Conversation

@jessicaKoehnke
Copy link
Copy Markdown
Contributor

Summary

Adds a connectionStartupTimeout configuration parameter to the SIRI MQTT updater so that OTP can start routing without real-time data when the MQTT broker is unavailable at startup, instead of blocking indefinitely. The MQTT client continues retrying in the background and resumes processing live messages once the broker becomes available.

Issue

No related issue.

Motivation

Previously, if the MQTT broker was unreachable when OTP started, the blocking .join() call in connectAndSubscribeToClient() would hang OTP startup indefinitely with no fallback.

How the code works

The HiveMQ client connection is now initiated non-blocking. At startup, OTP waits up to connectionStartupTimeout (default: 30s) for the broker to connect. If the broker connects in time, normal priming proceeds (retained messages are processed before routing is enabled). If not, OTP logs a warning and marks the updater as primed immediately, allowing routing to start without real-time data. Subscription setup is moved into the onConnect callback so it is correctly re-established on every reconnect, including after a broker restart.

New optional parameter in router-config.json:

{
  "type": "siri-et-mqtt",
  "connectionStartupTimeout": "PT30S"
}

Unit tests

No unit tests were added. The change is primarily a resilience/configuration improvement to the MQTT connection lifecycle. Manual verification was done to confirm OTP starts correctly both when the broker is available and when it is not.

Documentation

  • The connectionStartupTimeout parameter is documented inline in SiriETMqttUpdaterConfig.java using OTP's config framework, and the auto-generated SiriMqttUpdater.md table and parameter details section have been updated accordingly.
  • The class-level Javadoc on MqttEstimatedTimetableSource was updated to describe the new startup timeout behavior.
  • A new OtpVersion.V2_10 enum entry was added to mark the parameter's introduction version.

@jessicaKoehnke jessicaKoehnke requested a review from a team as a code owner March 31, 2026 15:08
@jessicaKoehnke jessicaKoehnke force-pushed the mqtt-connection-resilience branch from ab6fc6e to 6515c00 Compare March 31, 2026 15:51
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 20.93023% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.01%. Comparing base (630a126) to head (d17bb6c).
⚠️ Report is 89 commits behind head on dev-2.x.

Files with missing lines Patch % Lines
...iri/updater/mqtt/MqttEstimatedTimetableSource.java 0.00% 31 Missing ⚠️
...rip/gtfs/updater/mqtt/MqttGtfsRealtimeUpdater.java 0.00% 2 Missing ⚠️
...siri/updater/mqtt/MqttSiriETUpdaterParameters.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #7489      +/-   ##
=============================================
- Coverage      71.39%   71.01%   -0.38%     
+ Complexity     21112    21004     -108     
=============================================
  Files           2344     2352       +8     
  Lines          87167    87294     +127     
  Branches        8633     8637       +4     
=============================================
- Hits           62231    61994     -237     
- Misses         21936    22312     +376     
+ Partials        3000     2988      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@MaxGosau MaxGosau left a comment

Choose a reason for hiding this comment

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

MqttEstimatedTimetableSource could be seperated into multiple classes (e.g. Clientfactory, MetricsConfiguration, Orchestration) but we should do that in a seperate PR, therefore approved.

@habrahamsson-skanetrafiken habrahamsson-skanetrafiken added +Sandbox This will be implemented as a Sandbox feature +Skip Changelog This is not a relevant change for a product owner since last release. labels Apr 9, 2026
@jessicaKoehnke jessicaKoehnke added this pull request to the merge queue Apr 10, 2026
Merged via the queue into opentripplanner:dev-2.x with commit e995d37 Apr 10, 2026
10 checks passed
@jessicaKoehnke jessicaKoehnke deleted the mqtt-connection-resilience branch April 10, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

+Sandbox This will be implemented as a Sandbox feature +Skip Changelog This is not a relevant change for a product owner since last release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants