You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by serega <se...@sybase.com> on 2010/10/14 19:52:25 UTC

Custom Router

Camel documentation shows how to implement 
http://camel.apache.org/message-router.html Message Router pattern .  In my
case the given examples are not sufficient. I have tens, and may be hundreds
of out endpoints, and complicated routing logic that is dynamic and can
change at runtime. The Processor interface seems like the natural way of
processing messages, but how do I specify the out endpoint in the Processor?
Can someone give me the direction  how to solve this problem with Camel?

Thanks,
Sergey
-- 
View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3212534.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Custom Router

Posted by Stan Lewis <sl...@fusesource.com>.
An option is to use a ProducerTemplate from your processor, have a
look here - http://camel.apache.org/producertemplate.html

On Thu, Oct 14, 2010 at 1:52 PM, serega <se...@sybase.com> wrote:
>
> Camel documentation shows how to implement
> http://camel.apache.org/message-router.html Message Router pattern .  In my
> case the given examples are not sufficient. I have tens, and may be hundreds
> of out endpoints, and complicated routing logic that is dynamic and can
> change at runtime. The Processor interface seems like the natural way of
> processing messages, but how do I specify the out endpoint in the Processor?
> Can someone give me the direction  how to solve this problem with Camel?
>
> Thanks,
> Sergey
> --
> View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3212534.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Custom Router

Posted by Tarjei Huse <ta...@scanmine.com>.
 Hi, take a look at the routing slip pattern[1] or the dynamic router. I
think you need the dynamic router.
   
On 10/14/2010 07:52 PM, serega wrote:
> Camel documentation shows how to implement 
> http://camel.apache.org/message-router.html Message Router pattern .  In my
> case the given examples are not sufficient. I have tens, and may be hundreds
> of out endpoints, and complicated routing logic that is dynamic and can
> change at runtime. The Processor interface seems like the natural way of
> processing messages, but how do I specify the out endpoint in the Processor?
> Can someone give me the direction  how to solve this problem with Camel?

1. http://camel.apache.org/routing-slip.html
2. http://camel.apache.org/dynamic-router.html

Regards,
Tarjei
> Thanks,
> Sergey


-- 
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413


Thanks

Posted by serega <se...@sybase.com>.
Hi,
thanks for the quick replies.
The Dynamic Router is exactly what I need.

Sergey.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3212586.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Custom Router

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Oct 15, 2010 at 8:59 PM, serega <se...@sybase.com> wrote:
>
> Is the dynamic router available only on camel 2.5?
>

Yes if you mean the .dynamicRouter as its documented on the web page
http://camel.apache.org/dynamic-router.html


> Sergey.
>
>
> Hadrian Zbarcea wrote:
>>
>> Hi Sergey,
>>
>> Messages flow along a route that can be statically or dynamically
>> configured. If I understand you correctly there are 2 things you could
>> look at. One is the dynamic router [1] (and related routing slip [2]) that
>> allows you to make decisions at runtime about how your messages flow. The
>> second is to split your complex route into multiple smaller routes using
>> direct [3] or seda [4] endpoints that would simplify management of your
>> routes (probably).
>>
>> I hope this helps,
>> Hadrian
>>
>> [1] http://camel.apache.org/dynamic-router.html
>> [2] http://camel.apache.org/routing-slip.html
>> [3] http://camel.apache.org/direct.html
>> [4] http://camel.apache.org/seda.html
>>
>> On Oct 14, 2010, at 1:52 PM, serega wrote:
>>
>>>
>>> Camel documentation shows how to implement
>>> http://camel.apache.org/message-router.html Message Router pattern .  In
>>> my
>>> case the given examples are not sufficient. I have tens, and may be
>>> hundreds
>>> of out endpoints, and complicated routing logic that is dynamic and can
>>> change at runtime. The Processor interface seems like the natural way of
>>> processing messages, but how do I specify the out endpoint in the
>>> Processor?
>>> Can someone give me the direction  how to solve this problem with Camel?
>>>
>>> Thanks,
>>> Sergey
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3212534.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3214333.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Custom Router

Posted by serega <se...@sybase.com>.
Is the dynamic router available only on camel 2.5?

Sergey.


Hadrian Zbarcea wrote:
> 
> Hi Sergey, 
> 
> Messages flow along a route that can be statically or dynamically
> configured. If I understand you correctly there are 2 things you could
> look at. One is the dynamic router [1] (and related routing slip [2]) that
> allows you to make decisions at runtime about how your messages flow. The
> second is to split your complex route into multiple smaller routes using
> direct [3] or seda [4] endpoints that would simplify management of your
> routes (probably).
> 
> I hope this helps,
> Hadrian
> 
> [1] http://camel.apache.org/dynamic-router.html
> [2] http://camel.apache.org/routing-slip.html
> [3] http://camel.apache.org/direct.html
> [4] http://camel.apache.org/seda.html
> 
> On Oct 14, 2010, at 1:52 PM, serega wrote:
> 
>> 
>> Camel documentation shows how to implement 
>> http://camel.apache.org/message-router.html Message Router pattern .  In
>> my
>> case the given examples are not sufficient. I have tens, and may be
>> hundreds
>> of out endpoints, and complicated routing logic that is dynamic and can
>> change at runtime. The Processor interface seems like the natural way of
>> processing messages, but how do I specify the out endpoint in the
>> Processor?
>> Can someone give me the direction  how to solve this problem with Camel?
>> 
>> Thanks,
>> Sergey
>> -- 
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3212534.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
-- 
View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3214333.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Custom Router

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Oct 22, 2010 at 3:58 PM, serega <se...@sybase.com> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> On Fri, Oct 22, 2010 at 3:42 PM, serega <se...@sybase.com>
>> wrote:
>>>
>>> So, how does exactly Dynamic Router work and why does it have "to return
>>> null
>>> to indicate the end"?
>>> Suppose my Dynamic Router returns "file://some_directory". What happens
>>> with
>>> the message after the call returns?
>>>
>>
>> It goes back to the route until it returns null.
>>
>
> Then, perhaps the Dynamic Router is not exactly what I need. I need the
> message to be send
> to the specified destination. I guess, I can keep a state in the message and
> return null in the second call.
> What is the overhead of this loop?
>

Sounds like you need recipient list instead
http://camel.apache.org/recipient-list.html

> Sergey.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3232289.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Custom Router

Posted by serega <se...@sybase.com>.

Claus Ibsen-2 wrote:
> 
> On Fri, Oct 22, 2010 at 3:42 PM, serega <se...@sybase.com>
> wrote:
>>
>> So, how does exactly Dynamic Router work and why does it have "to return
>> null
>> to indicate the end"?
>> Suppose my Dynamic Router returns "file://some_directory". What happens
>> with
>> the message after the call returns?
>>
> 
> It goes back to the route until it returns null.
> 

Then, perhaps the Dynamic Router is not exactly what I need. I need the
message to be send
to the specified destination. I guess, I can keep a state in the message and
return null in the second call.
What is the overhead of this loop?

Sergey.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3232289.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Custom Router

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Oct 22, 2010 at 3:42 PM, serega <se...@sybase.com> wrote:
>
> So, how does exactly Dynamic Router work and why does it have "to return null
> to indicate the end"?
> Suppose my Dynamic Router returns "file://some_directory". What happens with
> the message after the call returns?
>

It goes back to the route until it returns null.


> Sergey.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3232263.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Custom Router

Posted by serega <se...@sybase.com>.
So, how does exactly Dynamic Router work and why does it have "to return null
to indicate the end"?
Suppose my Dynamic Router returns "file://some_directory". What happens with
the message after the call returns?

Sergey.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3232263.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Custom Router

Posted by Hadrian Zbarcea <hz...@gmail.com>.
Hi Sergey, 

Messages flow along a route that can be statically or dynamically configured. If I understand you correctly there are 2 things you could look at. One is the dynamic router [1] (and related routing slip [2]) that allows you to make decisions at runtime about how your messages flow. The second is to split your complex route into multiple smaller routes using direct [3] or seda [4] endpoints that would simplify management of your routes (probably).

I hope this helps,
Hadrian

[1] http://camel.apache.org/dynamic-router.html
[2] http://camel.apache.org/routing-slip.html
[3] http://camel.apache.org/direct.html
[4] http://camel.apache.org/seda.html

On Oct 14, 2010, at 1:52 PM, serega wrote:

> 
> Camel documentation shows how to implement 
> http://camel.apache.org/message-router.html Message Router pattern .  In my
> case the given examples are not sufficient. I have tens, and may be hundreds
> of out endpoints, and complicated routing logic that is dynamic and can
> change at runtime. The Processor interface seems like the natural way of
> processing messages, but how do I specify the out endpoint in the Processor?
> Can someone give me the direction  how to solve this problem with Camel?
> 
> Thanks,
> Sergey
> -- 
> View this message in context: http://camel.465427.n5.nabble.com/Custom-Router-tp3212534p3212534.html
> Sent from the Camel - Users mailing list archive at Nabble.com.