Hi

That is because you use toD with http that camel optimizes under the
hood to use a base endpoint and using headers with the dynamic
context-path part.
The interceptor can then not match that pattern.

You can turn this off in toD
Or you can check the header (CamelHttpPath is the name I think) in
<when> to see if it matches that part of your context-path.

On Tue, May 18, 2021 at 7:58 PM Yasser Zamani <yasserzam...@apache.org> wrote:
>
> Thanks for the quick reply!
>
> (please see in-line)
>
> On 2021/05/18 15:59:34, Claus Ibsen <claus.ib...@gmail.com> wrote:
> > Hi
> >
> > What Camel version do you use?
>
> I use Camel 3.7.3.
>
> >
> > Also mind about matching by exact uri, then the order of the query
> > parameters also matter. So if that is not really what you need, then
>
> Matching by exact uri isn't possible in my case. But to test I'd also tested 
> an absolute uri 
> "http://localhost:8080/camel/external_mock/PropertyFoo?bridgeEndpoint=true"; 
> which didn't work. The problem isn't order of query parameters. As I said the 
> problem is I don't know why but my break point showed me that Camel is trying 
> to test 
> "http://localhost:8080/camel/external_mock/PropertyFoo?bridgeEndpoint=true".matches("http://localhost:8080?bridgeEndpoint=true";);
>  which doesn't match because the "/camel/external_mock/" is missing in the 
> intercepted uri, provided it is present in the exact uri or wildcard uri 
> expression.
>
> My best guess is that's because of my dynamic .toD where I have 
> ${headers.serviceType} included in the http url. For example I guess 
> following simplified XML DSL won't work as well:
>
>     <interceptSendToEndpoint uri="http://localhost:8080/*";>
>       <to uri="log:worked"/>
>     </interceptSendToEndpoint>
>     <route>
>       <from uri="direct:sample"/>
>       <toD 
> uri="http://localhost:8080/Sample${headers.foo}?bridgeEndpoint=true"/>
>
> BTW any idea about issues #2 and #3?
>
> Regards.
>
> > use a * to match with wildcard
> >
> > On Tue, May 18, 2021 at 5:17 PM Yasser Zamani <yasserzam...@apache.org> 
> > wrote:
> > >
> > > Hi there,
> > >
> > > Assume following XML DSL:
> > >
> > >     <route id="dispatch">
> > >       <from uri="direct:dispatch"/>
> > >       <interceptSendToEndpoint uri="http:*"
> > > afterUri="direct:after_dispatch">
> > >                 <when>
> > >                         <simple>${headers.messageType} != null &&
> > > ${headers.serviceType} != null</simple>
> > >                 </when>
> > >         <to uri="direct:req_out"/>
> > >       </interceptSendToEndpoint>
> > >       <choice id="dispatch-choice">
> > >         <when>
> > >           <simple>${headers.messageType} == 'Property'</simple>
> > >           <toD
> > > uri="{{ext.url}}/Property${headers.serviceType}?bridgeEndpoint=true"/>
> > >         </when>
> > > .
> > > .
> > > .
> > >
> > > I found several issues listed below ordered by bug likelihood:
> > >
> > > 1. When I change uri="http:*" to uri="{{ext.url}}/*" it doesn't match as
> > > I expect. I debugged and saw that Camel tries to match
> > > "http://localhost:8080?bridgeEndpoint=true"; with "{{ext.url}}/*" i.e.
> > > "http://localhost:8080/camel/external_mock/*"; (because ext.url is set to
> > > http://localhost:8080/camel/external_mock) and it doesn't match, Camel
> > > is right but why it's removed "/Property${headers.serviceType}" from the
> > > interceptedUri?! because it has dynamics? it doesn't match because it's
> > > removed this portion. I expect Camel to match
> > > "http://localhost:8080/camel/external_mock/PropertyFoo?bridgeEndpoint=true";,
> > > not "http://localhost:8080?bridgeEndpoint=true";.
> > >
> > > 2. As you see I've defined it at route level but I see all of my other
> > > "http:*" endpoints will be intercepted! Is this expected?!
> > >
> > > 3. As per Camel docs, when `when` condition evaluates to false then the
> > > interception shouldn't being triggered, but I see yes, it doesn't go to
> > > the "direct:req_out" but always go to the afterUri i.e.
> > > "direct:after_dispatch" regardless of `when`! Is this expected?
> > >
> > > Thanks in advance!
> > >
> > > Regards.
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to