camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikhil <>
Subject How to create a dynamic route based on some properties
Date Wed, 22 Feb 2012 16:43:55 GMT
I am using camel 2.8.1
I am trying to create a route dynamically based on some properties in a
properties file which looks like this
Subscribers = s1,s2,s3   // A list of subscribers
// Following properties are repeated for each subscriber. I am posting only
one subscriber properties for brevity
S1.fromEndpoint=activemq:s1QueueName // The queue from which this route
would subscriber
S1.processor.bean = s1Processor // The processor that is invoked as step 1
S1.postProcess.steps=2 // The number of post process steps. This can be zero
or more
// The following properties are repeated for every post process step
S1.postprocess1.processor = s11Processor // Processor for step 1
S1.postprocess1.url = direct:s11URL // URL to which the processed request is
to be sent. Step 1
S1.postprocess2.processor = s1Processor (I can re-use an existing processor
if I want) // Step 2 of post processing. This processor would have access to
the result of Step3. Does more processing based on the result
S1.postprocess1.url = direct:s12URL // Step 2 of post processing. Send the
processed request to this url
I am creating routes dynamically by iterating through the list of
Subscribers.each { subscriber ->
*.processRef(subscriber.postprocess1.processor) // Step 1 processor
.to(subscriber.postprocess1.url) // Step 1 URL
.processRef(subscriber.postprocess2.processor) // Step 2 processor
.to(subscriber.postprocess2.url) // Step2 URL
I wish I could write a “for” loop and reproduce the “processRef” and “to”
combinations based on the number of steps specified in the properties file.
The “loop” construct in camel is capable of sending the exchange to the same
processor+url combination everytime
Is there a way to do something like this
Subscribers.each { subscriber ->
Int i = 1
.loop(subscriber. postProcess.steps)      // <------  Such looping the
missing piece in my scenario
I have tried to be as descriptive as possible. Please let me know if there
is any more information you need.

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

View raw message