camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gudiseashok <>
Subject Re: Creating routes dynamically like a for()
Date Sat, 05 Oct 2013 03:54:45 GMT
See if this helps you ...

//Calling to create a router - or loop this 

AppsRouteBuilder.getInstance().addRouter(camelContext, "{add router id}",
				"{add your "*from*" string here}",	new String[] {"***One or ***","more
"To" strings here"});

Note#// You can loop above one, if you have control/can maintain routeIDs,
because you need that incase you want to stop or delete a particuar route by

//Dynamic RouteBuilder to add Routers at run-time (method)
public void addRouter(CamelContext camelContext, final String routeId,final
boolean multiCast, 
				final String from, final String[] to){
			if(camelContext == null){
				camelContext = new DefaultCamelContext();
			RouteBuilder routeBuilder = new RouteBuilder() {
				public void configure() {
					RouteDefinition routeDefinition = from(from).routeId(routeId);
			    	for(String currentTo:to){
			    		log.debug("Added To "+currentTo);
		}catch(Exception e){

Hope this works for you, or my apologies if I mis-guided you because I am
also a co-learner :-)

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message