Claus Ibsen created CAMEL-25141:
-----------------------------------

             Summary: camel-core - interceptSendToEndpoint: only intercept the 
sends of the routes the interceptor is defined for
                 Key: CAMEL-25141
                 URL: https://issues.apache.org/jira/browse/CAMEL-25141
             Project: Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Claus Ibsen


The docs describe interceptors as scoped: an interceptor in a RouteBuilder 
applies to the routes of that RouteBuilder, and one in a route configuration 
applies to the routes that use that configuration. intercept() and 
interceptFrom() work like that, as they are woven into the routes.

interceptSendToEndpoint does not. It works by wrapping the endpoint, so every 
send to the endpoint is intercepted, whoever sends:
* routes from other RouteBuilders that send to the same endpoint (and have no 
interceptor of their own for it)
* a ProducerTemplate / FluentProducerTemplate
* dynamic sends (toD, recipientList, routingSlip, enrich) from any route

With CAMEL-25140 each route registers its own interceptor on the wrapped 
endpoint, and a send uses the interceptor of the sending route. When the 
sending route has none (or the send is not from a route), the interceptor of 
the first route that registered one is used. This keeps the behaviour of today, 
where the one interceptor that wrapped the endpoint applied to all sends.

h3. Proposal
Only intercept the sends of the routes the interceptor is defined for, which 
matches the docs and the other interceptors. A send from another route or from 
a ProducerTemplate would then go to the endpoint as-is.

h3. Things to decide
* This is a behaviour change for users that rely on the global effect (such as 
intercepting sends from a ProducerTemplate in tests, or from routes in another 
RouteBuilder). Options: change the default and document it in the upgrade 
guide, or make it an option (such as a global/scope setting on 
interceptSendToEndpoint) with the current behaviour as the default for a while.
* Sends from within the interceptor itself, and from onException / onCompletion 
of the route, should count as the route.
* How it relates to mockEndpoints / adviceWith, which are meant to be global 
(they are not route interceptors and are not affected).
* Kamelets and route templates: the routes created from them get the 
interceptors of their RouteBuilder or route configuration as today.

Depends on CAMEL-25140, which makes the interceptors per route.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to