You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by alloyer <al...@gmail.com> on 2009/06/26 10:57:14 UTC

Does the RouteDefinition instance contain only one route?

I see RouteDefinition uses List<FromDefinition> and List<ProcessorDefinition>
as inputs and outputs to maintain the message endpoints. It seems a route
can handle several message flows, like:
      from("direct:a").to("mock:results")
      from("direct:b").to("mock:results")
  But in my test case, when I set a route configuration which contains the
above two line of routes, the route builder will separate this configuration
into two RouteDefinition instance.

Route configuration form:
http://www.nabble.com/file/p24217052/routeDefinitionForm.jpg
routeDefinitionForm.jpg 
Routes generated:
http://www.nabble.com/file/p24217052/routes.jpg routes.jpg 

  Does the RouteDefinition always maintain only one sentence like
"from().to()" ? If not, how does it distinguish the <from,to> pairs?

   Thanks
-- 
View this message in context: http://www.nabble.com/Does-the-RouteDefinition-instance-contain-only-one-route--tp24217052p24217052.html
Sent from the Camel Development mailing list archive at Nabble.com.


Re: Does the RouteDefinition instance contain only one route?

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jun 27, 2009 at 11:09 AM, alloyer<al...@gmail.com> wrote:
>
> When I remove a route through "camelContext.removeRouteDefinition(id)"
> method, the route still do the message delivery sometimes. Is it caused by
> the second route you mentioned as EventDrivenConsumerRoute?
I think you need to use stopRoute instead. It will remove and stop at
the same time.


>
>
> Claus Ibsen-2 wrote:
>>
>> On Fri, Jun 26, 2009 at 10:57 AM, alloyer<al...@gmail.com> wrote:
>>>
>>> I see RouteDefinition uses List<FromDefinition> and
>>> List<ProcessorDefinition>
>>> as inputs and outputs to maintain the message endpoints. It seems a route
>>> can handle several message flows, like:
>>>      from("direct:a").to("mock:results")
>>>      from("direct:b").to("mock:results")
>>>  But in my test case, when I set a route configuration which contains the
>>> above two line of routes, the route builder will separate this
>>> configuration
>>> into two RouteDefinition instance.
>>>
>>> Route configuration form:
>>> http://www.nabble.com/file/p24217052/routeDefinitionForm.jpg
>>> routeDefinitionForm.jpg
>>> Routes generated:
>>> http://www.nabble.com/file/p24217052/routes.jpg routes.jpg
>>>
>>>  Does the RouteDefinition always maintain only one sentence like
>>> "from().to()" ? If not, how does it distinguish the <from,to> pairs?
>> It uses a magic wand :)
>>
>> No kidding.
>>
>> You have defined in your route builder that you have 2 routes. As
>> there a 2 from() in the DSL.
>>
>> If you want multiple inputs to the same route you can do that as well
>> and have 1 route
>> from("direct:a", "direct:b").to("mock:results");
>>
>> Then there is only 1 from in the DSL and thus only 1 route, but it has
>> multiple inputs.
>> That is not so common as most users either dont know this or usually
>> use 1 input.
>>
>> This applies for the model, eg the RoutesDefinition.
>>
>> But at runtime Camel will generate a new route per. input, regardless
>> if there is only 1 route model. So in this case no matter how we
>> define the route model
>> Camel will at runtime generate 2 x runtime rutes. It does this as it
>> wraps a route in the EventDrivenConsumerRoute as the starting point,
>> eg the from("direct:a").
>>
>> What might be better or something we can work on in the future is to
>> allow Camel to detect this better and reuse the same runtime route
>> for multiple EventDrivenConsumerRoute that was defined to use the same
>> route model.
>>
>>
>>
>>
>>
>>>
>>>   Thanks
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Does-the-RouteDefinition-instance-contain-only-one-route--tp24217052p24217052.html
>>> Sent from the Camel Development mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Does-the-RouteDefinition-instance-contain-only-one-route--tp24217052p24231568.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Does the RouteDefinition instance contain only one route?

Posted by alloyer <al...@gmail.com>.
When I remove a route through "camelContext.removeRouteDefinition(id)"
method, the route still do the message delivery sometimes. Is it caused by
the second route you mentioned as EventDrivenConsumerRoute? 


Claus Ibsen-2 wrote:
> 
> On Fri, Jun 26, 2009 at 10:57 AM, alloyer<al...@gmail.com> wrote:
>>
>> I see RouteDefinition uses List<FromDefinition> and
>> List<ProcessorDefinition>
>> as inputs and outputs to maintain the message endpoints. It seems a route
>> can handle several message flows, like:
>>      from("direct:a").to("mock:results")
>>      from("direct:b").to("mock:results")
>>  But in my test case, when I set a route configuration which contains the
>> above two line of routes, the route builder will separate this
>> configuration
>> into two RouteDefinition instance.
>>
>> Route configuration form:
>> http://www.nabble.com/file/p24217052/routeDefinitionForm.jpg
>> routeDefinitionForm.jpg
>> Routes generated:
>> http://www.nabble.com/file/p24217052/routes.jpg routes.jpg
>>
>>  Does the RouteDefinition always maintain only one sentence like
>> "from().to()" ? If not, how does it distinguish the <from,to> pairs?
> It uses a magic wand :)
> 
> No kidding.
> 
> You have defined in your route builder that you have 2 routes. As
> there a 2 from() in the DSL.
> 
> If you want multiple inputs to the same route you can do that as well
> and have 1 route
> from("direct:a", "direct:b").to("mock:results");
> 
> Then there is only 1 from in the DSL and thus only 1 route, but it has
> multiple inputs.
> That is not so common as most users either dont know this or usually
> use 1 input.
> 
> This applies for the model, eg the RoutesDefinition.
> 
> But at runtime Camel will generate a new route per. input, regardless
> if there is only 1 route model. So in this case no matter how we
> define the route model
> Camel will at runtime generate 2 x runtime rutes. It does this as it
> wraps a route in the EventDrivenConsumerRoute as the starting point,
> eg the from("direct:a").
> 
> What might be better or something we can work on in the future is to
> allow Camel to detect this better and reuse the same runtime route
> for multiple EventDrivenConsumerRoute that was defined to use the same
> route model.
> 
> 
> 
> 
> 
>>
>>   Thanks
>> --
>> View this message in context:
>> http://www.nabble.com/Does-the-RouteDefinition-instance-contain-only-one-route--tp24217052p24217052.html
>> Sent from the Camel Development mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/Does-the-RouteDefinition-instance-contain-only-one-route--tp24217052p24231568.html
Sent from the Camel Development mailing list archive at Nabble.com.


Re: Does the RouteDefinition instance contain only one route?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jun 26, 2009 at 10:57 AM, alloyer<al...@gmail.com> wrote:
>
> I see RouteDefinition uses List<FromDefinition> and List<ProcessorDefinition>
> as inputs and outputs to maintain the message endpoints. It seems a route
> can handle several message flows, like:
>      from("direct:a").to("mock:results")
>      from("direct:b").to("mock:results")
>  But in my test case, when I set a route configuration which contains the
> above two line of routes, the route builder will separate this configuration
> into two RouteDefinition instance.
>
> Route configuration form:
> http://www.nabble.com/file/p24217052/routeDefinitionForm.jpg
> routeDefinitionForm.jpg
> Routes generated:
> http://www.nabble.com/file/p24217052/routes.jpg routes.jpg
>
>  Does the RouteDefinition always maintain only one sentence like
> "from().to()" ? If not, how does it distinguish the <from,to> pairs?
It uses a magic wand :)

No kidding.

You have defined in your route builder that you have 2 routes. As
there a 2 from() in the DSL.

If you want multiple inputs to the same route you can do that as well
and have 1 route
from("direct:a", "direct:b").to("mock:results");

Then there is only 1 from in the DSL and thus only 1 route, but it has
multiple inputs.
That is not so common as most users either dont know this or usually
use 1 input.

This applies for the model, eg the RoutesDefinition.

But at runtime Camel will generate a new route per. input, regardless
if there is only 1 route model. So in this case no matter how we
define the route model
Camel will at runtime generate 2 x runtime rutes. It does this as it
wraps a route in the EventDrivenConsumerRoute as the starting point,
eg the from("direct:a").

What might be better or something we can work on in the future is to
allow Camel to detect this better and reuse the same runtime route
for multiple EventDrivenConsumerRoute that was defined to use the same
route model.





>
>   Thanks
> --
> View this message in context: http://www.nabble.com/Does-the-RouteDefinition-instance-contain-only-one-route--tp24217052p24217052.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus