jamesnetherton opened a new pull request, #31128: URL: https://github.com/apache/camel/pull/31128
# Description https://issues.apache.org/jira/browse/CAMEL-27777 The first event that reached an empty provisional history queue in `BacklogTracer.traceEvent` claimed it for its exchange, whatever kind of event it was. When routes run concurrently, that event can be the `last` event of an exchange already in flight. `head` is null at that point, so the exchange is never completed, and every other exchange's events are discarded. The latest message history then stays on that exchange forever. When a middle event claims the queue instead, the history is missing the start of the exchange. With this change, only the start of an exchange may begin a new history: the `first` event of the route the exchange came from, not the input of a sub-route. An event without a `fromRouteId` still counts as a start, which keeps the existing hand-built event tests working. Breadcrumb append mode is unchanged. `BacklogTracerMessageHistoryInterleavedTest` uses latches to reproduce the stall deterministically: - One exchange holds the history. - A second exchange waits at the end of the route. - The first exchange completes, then the second's `last` event arrives at the empty queue. - A third exchange must then become the latest history. Without the fix the history stays on the first exchange. All `BacklogTracer*` tests in `camel-management` pass. This also covers part of a stall listed in CAMEL-25056, which its commit did not change: when `tracePattern` or `traceFilter` excludes a route's first event, a later event can no longer claim the queue and freeze it. The other half, a filter excluding the last event, is not addressed here. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). # Apache Camel coding standards and style - [x] 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. The formatter and import sort were run on `camel-base-engine` and `camel-management` with no further changes. The change touches no generated sources, so a full build from the root was not run. # AI-assisted contributions - [x] 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. The fix and test were written with Claude Code (Claude Opus 5.5). 🤖 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]
