You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by chaituu <ya...@gmail.com> on 2014/10/31 11:21:20 UTC

route information is not coming with camelContext.getRoute("route1")


<bean id="camelRouteManager" class="com.multiplecamel.CamelRouteManager" >
	<property name="camelContext" ref="camelContext-local"></property>
	</bean>
	
		<camelContext id="camelContext-local"
xmlns="http://camel.apache.org/schema/spring">
		
			<routeBuilder ref="camelRouteManager" /> 
		
			 <route id="route1" autoStartup="false">
	            <from uri="timer://testJob?fixedRate=true&amp;period=5000" />           
	            <to uri="bean:test?method=sendTrap" />
    	    </route>
    	     
 		</camelContext>

above is the spring dsl file defined in camel-confif.xml in web
application.it will be loaded during startup.

I try to get the route id information in CamelRouteManager using
camelContext.getRoute("route1") but its coming as null.if I use
getRouteDefinition then route definition is coming.  
		
public class CamelRouteManager extends RouteBuilder  {
	
	protected CamelContext camelContext;

	public CamelContext getCamelContext() {
	 return camelContext;
	}
	public void setCamelContext(CamelContext camelContext) {
	 this.camelContext = camelContext;

	}

	@Override
	public void configure() throws Exception {
		System.out.println(camelContext.getName()+"  
auotstartup:::::"+camelContext.isAutoStartup());
		System.out.println(camelContext.getRouteDefinition("route1")+" ... 
routes::::"+camelContext.getRoute("route1"));
		
		
	}
	
	

}



--
View this message in context: http://camel.465427.n5.nabble.com/route-information-is-not-coming-with-camelContext-getRoute-route1-tp5758371.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: route information is not coming with camelContext.getRoute("route1")

Posted by chaituu <ya...@gmail.com>.
How do i get application context to do ac.getBean("camel");



--
View this message in context: http://camel.465427.n5.nabble.com/route-information-is-not-coming-with-camelContext-getRoute-route1-tp5758371p5758502.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: route information is not coming with camelContext.getRoute("route1")

Posted by bharadwaj <bh...@gmail.com>.
The old option shouldStartContext have been removed and replaced with this
new autoStartup option instead. What it allows is to configure Camel to not
auto start when Spring starts.

So how do you start Camel then?
The autoStartup option on the <camelContext> is only used once, so you can
manually start Camel later by invoking its start method as shown below:
ApplicationContext ac = ...
SpringCamelContext camel = (SpringCamelContext) ac.getBean("myCamel");
 
// now start Camel manually
camel.start();

once you camel context is active running then only you can get route
definition.




--
View this message in context: http://camel.465427.n5.nabble.com/route-information-is-not-coming-with-camelContext-getRoute-route1-tp5758371p5758444.html
Sent from the Camel - Users mailing list archive at Nabble.com.