You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Syed <ss...@qatarairways.com.qa> on 2013/01/20 12:27:32 UTC

Dynamic Route Creation.

Hi 

I am trying to create the routes dynamically in
*addRoutesToCamelContext(CamelContext context)*  method, instead of
configuring the routes in the configure() method.  Reason is, I have to
fetch the routes from the database instead of static configuration.

the below similar example of Java DSL, I created using RouteDefinition and
added the route definition into the camel context.

Java DSL
-----------

from("jms:queue:eix.sorter.queue")
             .process(new com.qr.eix.processor.SorterProcessor())
             .process(new com.qr.eix.processor.SorterProcessor1()).choice()
	.when()
                .simple("${body.msgType} == 'FFR'")
	 .to("jms:queue:eix.ffr.queue")
                 .when()
	 .simple("${body.msgType} == 'FFM'")
	 .to("jms:queue:eix.ffm.queue")
                .otherwise()
	 .to("jms:queue:eix.parser.queue");

Similar Dynamic Routes
----------------------------

RouteDefinition rDefintion = new RouteDefinition();
rDefintion.from(from);
rDefintion.process(new com.qr.eix.processor.SorterProcessor());
rDefintion.process(new com.qr.eix.processor.SorterProcessor1());
rDefintion.choice().when().simple(buildFFRString);
rDefintion. to(ffrto)
rDefintion.choice().when().simple(buildFFMString);
rDefintion.to(ffmto)
rDefintion.choice().otherwise();
rDefintion.to(generalTo)

With the above CBR is not working and i am not getting the print statements
inserted inthe processor class..let me know where i am wrong...

Thanks 
Jawahar





--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-Route-Creation-tp5725835.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic Route Creation.

Posted by Henryk Konsek <he...@gmail.com>.
Hi Jawahar,

> I am trying to create the routes dynamically
...
> Reason is, I have to
> fetch the routes from the database instead of static configuration.

Have you consider using RecipentList [1] or DynamicRouter [2] for this
purpose? It's definitely easier to use and far more maintainable than
creating new routes.

[1] http://camel.apache.org/recipient-list.html
[2] http://camel.apache.org/dynamic-router.html

--
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Dynamic Route Creation.

Posted by Henryk Konsek <he...@gmail.com>.
> Thanks, I am able to configure as you said...

Good to hear that. Better stick to the EIP (Dynamic Router, Recipient
List, etc) than to low-level Camel API.

> let me know whether i can use context.addRouteDefinitions(routeList).
> addRouteDefintions method shows as deprecated..

All you need to do is use ModelCamelContext interface instead of CamelContext.

ModelCamelContext context = new DefaultCamelContext();
context.addRouteDefinition(...);

Route definition API has been moved to more specialized interface, as
not every CamelContext implementation need to support route
manipulation (although DefaultCamelContext does so).

Laters.

--
Henryk Konsek
http://henryk-konsek.blogspot.com

Re: Dynamic Route Creation.

Posted by Syed <ss...@qatarairways.com.qa>.
Thanks, I am able to configure as you said...

let me know whether i can use context.addRouteDefinitions(routeList). 
addRouteDefintions method shows as deprecated..

Regards
Jawahar



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-Route-Creation-tp5725835p5725984.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic Route Creation.

Posted by sekaijin <je...@sap.aphp.fr>.
I define my routes in accordance with information read from a database.

I do not understand why spas you can not do in configue.

I read the startup route definition in the database (init routebuilder)
then I give the hand to "configure" which according to the definition read
built the road.

Must be attentive to your classes of objects.

you can not use the object as it 

I do not know all classes but your Ide can help you

you must also pay attention to optinals end() (on choise when pipeline etc.)


java DSL is a fluent API.
But each method returns a different object and different class. 
for exemple .choice() return a ChoiceDefinition


it is necessary to retrieve the returned object to chain the following
method.

A + JYT



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-Route-Creation-tp5725835p5725838.html
Sent from the Camel - Users mailing list archive at Nabble.com.