The interceptor must be in the same RouteBuilder.

On Fri, Apr 25, 2014 at 4:12 AM, shreyas <[email protected]> wrote:
> Hello,
>
> I have modified the camel console example to use interceptor. The interceptor 
> is not working when I put the code that uses interceptSendToEndpoint in 
> InterceptorRoute.configure method, but works when I put the same in  
> TestInterceptorBuilder.configure method. I am not sure why this does not work 
> and how to make it work such that the interceptSendToEndpoint is outside the 
> RouteBuilder that builds the real route. The code is very small hence I have 
> put the snippets here. If it is difficult to read I apologize. I have also 
> attached the project zip.
>
> My camel context has:
>
> <bean id="interceptorRouteBuilder" class="routes.TestInterceptorBuilder" />
> <bean id="interceptorRoute" class="routes.InterceptorRoute"/>
> <camelContext xmlns="http://camel.apache.org/schema/spring";>
>       <routeBuilder ref="interceptorRouteBuilder" />
>       <routeBuilder ref="interceptorRoute" />
> </camelContext>
>
> The TestInterceptorBuilder class has the below code:
>
> public class TestInterceptorBuilder extends RouteBuilder {
>
>     @Override
>     public void configure() throws Exception {
>         from("stream:in?promptMessage=Enter something: ")
>             .to("mock:bar")
>             .to("mock:foo")
>             .to("mock:result")
>         .to("stream:out");
>     }
> }
>
> The InterceptorRoute has the below code:
>
> public class InterceptorRoute extends RouteBuilder {
>     @Override
>     public void configure() throws Exception {
>         interceptSendToEndpoint("mock:foo")
>                     .to("mock:detour").transform(constant("Bye World"));
>     }
> }
>
> Thanks a lot of any help or pointers to solve this problem.
>
> -Shreyas Purohit



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to