camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sumit Teke <sumit_t...@omniscient.co.in>
Subject Re: Modifying route using adviceWith showing inconsistent behaviour
Date Tue, 08 Feb 2011 04:50:42 GMT
  Hi Ashwin,

Sorry i think, i was not clear in last post.

I understand that stopping camel context will stop all the routes. What 
i did was

*Test 1: *Tried stopping camel context and then modified routes and 
again started the context
/CamelContext camelContext = (CamelContext) 
context.getBean(CamelContext.class);
camelContext.stop();
addErrorHandler(camelContext);
addStartIntercepter(camelContext);
addEndIntercepter(camelContext);
camelContext.start();

/but when i run this code it throws NPE while advicing route for start 
intercepter

Exception in thread "main" java.lang.NullPointerException
     at 
org.apache.camel.impl.DefaultCamelContext.stopRouteService(DefaultCamelContext.java:1564)
     at 
org.apache.camel.impl.DefaultCamelContext.stopRoute(DefaultCamelContext.java:651)
     at 
org.apache.camel.impl.DefaultCamelContext.removeRouteDefinition(DefaultCamelContext.java:596)
     at 
org.apache.camel.model.RouteDefinition.adviceWith(RouteDefinition.java:221)
     at CamelContextLoader.addStartIntercepter(CamelContextLoader.java:54)
     at CamelContextLoader.load(CamelContextLoader.java:21)
     at CamelContextLoader.main(CamelContextLoader.java:105)

*Test 2: *Tried stopping routes before advicing and starting the new 
modified route, but as advice adds new modified route to context and 
starts it, so it throws the multiple consumer exception.

camelContext.stopRoute(route);
route = route.adviceWith(camelContext, new RouteBuilder() {
     public void configure() throws Exception {
         System.out.println(">>>>>>>>>> adding error handler
on route " 
+ routeId);
         onException(Exception.class).handled(true).process(ERROR_HANDLER);
     }
});
camelContext.startRoute(route);
/

/
Thanks,
Sumit Teke
Omniscient Software Pvt Ltd
T. +91-20-26680814, Ext. 217
F. +91-20-26680815, Ext. 212
M. +91-9975709032
E. sumit_teke@omniscient.co.in

On Tuesday 08 February 2011 01:57 AM, Ashwin Karpe wrote:
> Hi,
>
> If you stop the CamelContext all the routes are automatically stopped.
> Alternatively, you can stop the routes and make changes without stopping the
> context and then start the routes individually.
>
> As for the second error, it is quite clear... Looks like you are starting
> two routes with the same from(...) endpoint or you have two routes with the
> same consumer.
>
> Cheers,
>
> Ashwin...
>
> -----
> ---------------------------------------------------------
> Ashwin Karpe
> Apache Camel Committer&  Sr Principal Consultant
> FUSESource (a Progress Software Corporation subsidiary)
> http://fusesource.com http://fusesource.com
>
> Blog: http://opensourceknowledge.blogspot.com
> http://opensourceknowledge.blogspot.com
> ---------------------------------------------------------

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message