You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Karthz <sk...@gmail.com> on 2010/12/07 23:19:47 UTC

InterceptSendToEndpoint - Http Component

Hi,

I'm using Camel 2.5. And, this is an outline of what I'm trying to do,

        <camel:interceptSendToEndpoint uri="{{custom.url}}"
inheritErrorHandler="true">
            <camel:doTry>
                <camel:to uri="bean:xyz?method=throwException" />
                <camel:doCatch>
                   
<camel:exception>java.lang.IllegalArgumentException</camel:exception>
                    <camel:log message="Message Failure" />
                    <camel:stop />
                </camel:doCatch>
            </camel:doTry>
        </camel:interceptSendToEndpoint>

        <camel:route id="route1">
            <camel:from uri="direct:something" />
            <camel:to uri="bean:xyz?method=doNothing" />
            <camel:to uri="{{custom.url}}" />
            <camel:log message="Message Success" />
        </camel:route>

Looks like there's an issue while intercepting messages sent to a Http
Component. It gets intercepted correctly, and "Message Failure" gets printed
in the logs correctly too.  However, the message still gets sent to the Http
component anyway. [Note: the  "Message Success", however, doesn't get
printed in the logs.]

This behavior remains even if I use
               <camel:interceptSendToEndpoint uri="http*"
inheritErrorHandler="true">
AND/OR the actual http url, instead of the placeholder
               <camel:to uri="http://localhost:8080/test" />

But if I intercept something else, and not the http component, then it works
fine. In the above route, this change
               <camel:interceptSendToEndpoint
uri="bean:xyz?method=doNothing" inheritErrorHandler="true">
does exactly what I want it to do. It intercepts before the method, and the
method never gets executed in case of an exception.


So, what's the correct way to intercept something that's being sent to a
Http Component?

Thanks.


-----
- Karthz
-- 
View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p3296620.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: InterceptSendToEndpoint - Http Component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Possible use wildcards in the interceptSendToEndpoint to match the
http url. As if you have parameters then that's tricky.
See details about wildcards at: http://camel.apache.org/intercept

On Tue, Apr 16, 2013 at 3:24 PM, dss.light <ds...@gmail.com> wrote:
> Hi, tried to use this feature for testing - excellently like advised - it
> still did not skip intercepted endpoint.
>
> Camel 2.10.4
>
> What I am doing wrong? The first endpoint changed and worked;
> In the log I see trying to post message to localhost.
> And test fell down with exception.
> I simply want to replace last endpoint to the other one.
>
> code
>
>         context.getRouteDefinitions().get(0).adviceWith(context, new
> AdviceWithRouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 replaceFromWith("direct:start");
>                 interceptSendToEndpoint(ReceiverBridge.TO_ENDPOINT)
>                 .skipSendToOriginalEndpoint()
>                 .to("mock:result");
>             }
>         });
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p5730970.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: InterceptSendToEndpoint - Http Component

Posted by "dss.light" <ds...@gmail.com>.
Hi, tried to use this feature for testing - excellently like advised - it
still did not skip intercepted endpoint.

Camel 2.10.4

What I am doing wrong? The first endpoint changed and worked;
In the log I see trying to post message to localhost.
And test fell down with exception.
I simply want to replace last endpoint to the other one.

code 

        context.getRouteDefinitions().get(0).adviceWith(context, new
AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {               
                replaceFromWith("direct:start");
                interceptSendToEndpoint(ReceiverBridge.TO_ENDPOINT)
                .skipSendToOriginalEndpoint()
                .to("mock:result");
            }
        });



--
View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p5730970.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: InterceptSendToEndpoint - Http Component

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Dec 8, 2010 at 9:14 AM, Karthz <sk...@gmail.com> wrote:
>
> Great, thank you.
>
> Just curious - in which class is this fix needed?
>

The commit log is here
http://svn.apache.org/viewvc?rev=1043330&view=rev




> -----
> - Karthz
> --
> View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p3297052.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: InterceptSendToEndpoint - Http Component

Posted by Karthz <sk...@gmail.com>.
Great, thank you.

Just curious - in which class is this fix needed?

-----
- Karthz
-- 
View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p3297052.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: InterceptSendToEndpoint - Http Component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I had a look and there was an issue in Camel when using sto() which
the interceptSendToEndpoint didn't check.
I will get this fixed in the source code.

On Wed, Dec 8, 2010 at 7:10 AM, Karthz <sk...@gmail.com> wrote:
>
> Thanks, Claus.
>
> But, I want the original route skipped only when there's an exception.
> Otherwise, it should send the message as normal. Should I still set
> skipSendToOriginalEndpoint?
>
> Thanks.
>
> -----
> - Karthz
> --
> View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p3296960.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: InterceptSendToEndpoint - Http Component

Posted by Karthz <sk...@gmail.com>.
Thanks, Claus.

But, I want the original route skipped only when there's an exception.
Otherwise, it should send the message as normal. Should I still set
skipSendToOriginalEndpoint?

Thanks.

-----
- Karthz
-- 
View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p3296960.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: InterceptSendToEndpoint - Http Component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

There is an attribute on the <interceptSendToEndpoint>
skipSendToOriginalEndpoint which you should set to true if you dont
want to send the message that was intercepted.

BTW: You IDE may assist you and show code completion etc. when editing
the XML files as its a good idea to see which attributes and whatnot
the XSD schema provides out of the box.


On Tue, Dec 7, 2010 at 11:19 PM, Karthz <sk...@gmail.com> wrote:
>
> Hi,
>
> I'm using Camel 2.5. And, this is an outline of what I'm trying to do,
>
>        <camel:interceptSendToEndpoint uri="{{custom.url}}"
> inheritErrorHandler="true">
>            <camel:doTry>
>                <camel:to uri="bean:xyz?method=throwException" />
>                <camel:doCatch>
>
> <camel:exception>java.lang.IllegalArgumentException</camel:exception>
>                    <camel:log message="Message Failure" />
>                    <camel:stop />
>                </camel:doCatch>
>            </camel:doTry>
>        </camel:interceptSendToEndpoint>
>
>        <camel:route id="route1">
>            <camel:from uri="direct:something" />
>            <camel:to uri="bean:xyz?method=doNothing" />
>            <camel:to uri="{{custom.url}}" />
>            <camel:log message="Message Success" />
>        </camel:route>
>
> Looks like there's an issue while intercepting messages sent to a Http
> Component. It gets intercepted correctly, and "Message Failure" gets printed
> in the logs correctly too.  However, the message still gets sent to the Http
> component anyway. [Note: the  "Message Success", however, doesn't get
> printed in the logs.]
>
> This behavior remains even if I use
>               <camel:interceptSendToEndpoint uri="http*"
> inheritErrorHandler="true">
> AND/OR the actual http url, instead of the placeholder
>               <camel:to uri="http://localhost:8080/test" />
>
> But if I intercept something else, and not the http component, then it works
> fine. In the above route, this change
>               <camel:interceptSendToEndpoint
> uri="bean:xyz?method=doNothing" inheritErrorHandler="true">
> does exactly what I want it to do. It intercepts before the method, and the
> method never gets executed in case of an exception.
>
>
> So, what's the correct way to intercept something that's being sent to a
> Http Component?
>
> Thanks.
>
>
> -----
> - Karthz
> --
> View this message in context: http://camel.465427.n5.nabble.com/InterceptSendToEndpoint-Http-Component-tp3296620p3296620.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/