camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hadrian Zbarcea <>
Subject Re: Dynamic generation of Camel routes
Date Thu, 19 Jul 2012 03:23:13 GMT
The routing slip is a dynamic router that allows one to determine at 
runtime to what endpoints messages should be sent. It got nothing to do 
with the process of creating routes.

The 2 choices are to either hardcode the logic described or the more 
elegant solution imo of defining a small dsl for that. I am going on a 
limb here and guess that there is some reason for generating the many 
routes. That reason I suspect could probably be expressed in a concise 
way, which would make a dsl appropriate.

The requirements were quite vague but I hope my guesses are not way off. 
A bit more details may get you some sample code to get you started. Here 
are a few pointers:

1. To define a number of routes you would implement a RouteBuilder and 
its configure method.
2. Although virtually all examples show that you need to call 
from(x).to(y).blah()..., there is nothing that prevents you from 
implementing a method:
   protected void foo() {
and call it within configure(), it'd have the same effect.
3. Next imagine that your method foo() actually takes some parameters, 
that would allow you to parameterize the route (you may have more than 
one such method).
4. Another thought is that you could actually use a Camel route (active 
only during startup) to extract the data from your store. Useful for 
unit testing and other goodies.
5. Bonus points for realizing that actually you can use a Camel 
Expression to evaluate the result of querying the data store and produce 
the value Object to parameterize the route.
6. An Expression may be useful to determine how many parameterized 
routes you need.
7. Add some syntactic sugar and you got your dsl.

All of the above may sound complicated or advanced, but it's actually 
quite simple to implement.

I hope this helps,

On 07/18/2012 06:55 PM, ychawla wrote:
> Would a routing slip work for you?  You can dynamically configure where your
> message is going, not necessarily what your input is.  However, depending on
> your requirements, this could suffice:
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

View raw message