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

   ## What
   
   CAMEL-26945. While an exchange is at a node, its `elapsed` (the time it has 
been at that node) was garbage: about the uptime of the machine in nanoseconds. 
Here is a dev mode integration whose route waits at a `delay`, as `camel get 
inflight`, the inflight dev console and the TUI show it:
   
   ```
   
{"exchangeId":"...","fromRouteId":"slow","atRouteId":"slow","nodeId":"delay1","nodeSource":"app.camel.yaml:15","elapsed":1417238100396303,"duration":3632}
   ```
   
   The JMX browse of the inflight repository shows the same value.
   
   While the node is not done, the inflight repository computes the value with 
`MessageHistory.getElapsedSinceCreated()`. Its default method subtracted the 
creation time of the history entry (`getTime()`, wall clock millis) from 
`System.nanoTime()`.
   
   ## Fix
   
   - `DefaultMessageHistory`, which every message history factory of Camel 
creates (some as a subclass), measures it on its monotonic clock. That is the 
clock that measures the time the node took, once it is done.
   - The default method of `MessageHistory`, for other implementations, 
subtracts the creation time from the current time in millis. It reads the time 
from `TimeSource`, so a simulation test runs it in virtual time.
   - The inflight dev console had the descriptions of `elapsed` and `duration` 
swapped: `elapsed` is the time at the current node, and `duration` is the time 
since the exchange started. `inflight.json` and its catalog copies are 
regenerated.
   
   ## Tests
   
   - `InflightRepositoryElapsedTest` (camel-core):
     - An exchange waits at a node. Its `elapsed` grows to 100 ms, and it is 
never longer than the exchange is old (`duration`).
     - A message history that only has the time it was created, which tests the 
default method.
     - Both fail without the fix: "Elapsed 1419483321396674 ms at the node of 
an exchange that is 104 ms old", and "Elapsed 1419483194227370 ms since created 
250 ms ago".
   - The inflight and message history tests of camel-core (19), camel-console 
(4) and camel-management (8) pass.
   
   ## Backport
   
   To camel-4.22.x and camel-4.18.x, which have the same code (the PRs follow).
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


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