Sure, RouteBuilders are just Java objects and can be configured in Java -
Camel DSL is just Java and loops are available ;)

But you have to distinguish when you get your path-list: during startup time
or during runtime?

Startup time:
Use a DB connection / EntityManager for loading the infos from the database
and loop over the datasets and create the routes as usual.

Runtime:
- You have to react on an event (incoming exchange ...) (new)
- load the data (as before, maybe getting from the exchange)
- create the RouteBuilder (as before)
- add to the camel context (new, implicitly done before)

Or am I wrong here?


Jan     

> -----Ursprüngliche Nachricht-----
> Von: kraythe . [mailto:kray...@gmail.com]
> Gesendet: Mittwoch, 2. Oktober 2013 07:42
> An: Camel Users List
> Betreff: Re: Creating routes dynamically like a for()
> 
> Just put the for outside. I do this all the time.
> 
> for (final String path : paths) {
>   from("file://" + path +"?readlock=changed").to(...) ...
> }
> 
> This will create four identical routes other than the file paths. if
> there are four elements in paths.
> 
> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of:
> Hardcore Java (2003) and Maintainable Java (2012)*
> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
> 
> 
> On Tue, Oct 1, 2013 at 4:20 PM, Jan Matèrne (jhm) <apa...@materne.de>
> wrote:
> 
> > What you could do is generating a xml file with the new route
> > definitions and load that.
> > http://camel.apache.org/loading-routes-from-xml-files.html
> >
> > from("sql ...")
> >     .process( generateRoutesXmlProcessor )
> >     .doTypeConversionFromXmlToInputStream
> >     .process( loadRoutesProcessor )
> >
> > Jan
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: mamouros [mailto:csst0...@yahoo.gr]
> > > Gesendet: Dienstag, 1. Oktober 2013 17:58
> > > An: users@camel.apache.org
> > > Betreff: Creating routes dynamically like a for()
> > >
> > > I would like to create a route for every query my sql route
> returns.
> > > From this:
> > >
> > > from("sql:" + fromUri + "?dataSource=dataSource")
> > > .to("bean:SmsReceiver?method=creatingRoutes");
> > >
> > > I want to make something hypothetically like this:
> > >
> > > for( from("sql:" + fromUri + "?dataSource=dataSource") )  {
> > >
> > >      .to("bean:SmsReceiver?method=creatingRoutes");
> > >
> > > }
> > >
> > > so if I have 3 entries in my table, I would create 3 routes.
> > >
> > > How is that possible. Is there any EIP that does that?
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > > http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-
> a
> > > -
> > > for-tp5740703.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >

Reply via email to