See if this helps you ...

//Calling to create a router - or loop this 

AppsRouteBuilder.getInstance().addRouter(camelContext, "{add router id}",
true,
                                "{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
id.

//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){
                try{
                        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);
                                        if(multiCast){
                                                        
routeDefinition.multicast().to(currentTo);
                                                }else{
                                                        
routeDefinition.to(currentTo);
                                                }
                                }
                            }
                        };
                        routeBuilder.addRoutesToCamelContext(camelContext);
                }catch(Exception e){
                        e.printStackTrace();
                }
        }

-------------------
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: 
http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-a-for-tp5740703p5740908.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to