Claus Ibsen created CAMEL-26781:
-----------------------------------

             Summary: camel-core - Runtime endpoint registry may count the 
reply of an InOut consumer more than once behind a circuit breaker or with 
sub-exchanges
                 Key: CAMEL-26781
                 URL: https://issues.apache.org/jira/browse/CAMEL-26781
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Follow-up of CAMEL-26780 (the input hits of the runtime endpoint registry).

For an InOut consumer, the runtime endpoint registry (extended statistics mode) 
counts the reply as an "out" hit of the consumer's endpoint on 
ExchangeCompletedEvent / ExchangeFailedEvent, keyed by the exchange's from 
route and from endpoint (DefaultRuntimeEndpointRegistry#notify).

Those events also fire for exchanges that are no reply of the consumer, as 
ExchangeCreatedEvent did for the inputs:

* A circuit breaker (resilience4j; fault tolerance likely the same) runs a 
correlated copy with its own unit of work and completes it with 
UnitOfWorkHelper.doneUow(uow, copy), which fires ExchangeCompletedEvent (or 
ExchangeFailedEvent) for the copy. The copy keeps the pattern, from route and 
from endpoint, so an InOut route with a circuit breaker likely counts two 
replies per message.
* Split, Multicast and Recipient List sub-exchanges with their own unit of work 
are likely counted as replies too.

This is from reading the code, not yet reproduced with a test.

A fix could count the reply where CAMEL-26780 counts the input: when the 
exchange is done in the route it entered through its consumer 
(RoutePolicy.onExchangeDone of the same route policy), for an out-capable 
exchange. Tests like ManagedEndpointInputHitsTest / ResilienceInputHitsTest 
with an InOut consumer (e.g. a seda InOut or platform-http route) would show it.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to