You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bilgin Ibryam <bi...@gmail.com> on 2014/11/25 12:18:44 UTC

Best way for reusing routes

Hi all,

I'd like to write couple of route definitions that will be reused in
multiple places.

If I use the Java DSL it is straight forward, I can reuse the RouteBuilder
class in many places, but I want to use the XML DSL and I can see two
options:

1. Use <routes> statements. Looks like it is mostly used for unit tests.
2. Use routeContext to define the routes.

Can anyone tell me what is the difference and the intended use of 1 and 2?

What limitations they have compared to normal routes defined in Java DSL or
XML DSL?


[1] http://camel.apache.org/loading-routes-from-xml-files.html
[2] http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html

TIA,

-- 
Bilgin Ibryam

Red Hat, Inc.
Apache Camel & Apache OFBiz committer
Blog: ofbizian.com
Twitter: @bibryam <https://twitter.com/bibryam>

Author of Instant Apache Camel Message Routing
http://www.amazon.com/dp/1783283475

Re: Best way for reusing routes

Posted by Bilgin Ibryam <bi...@gmail.com>.
Further looking into that, the docs say
"<routeContext> is isolated and that that it cannot use <onException>,
<intercept>, <dataFormats> from the camelcontext"

 but looking into latest Camel code it can use

Does the doc out of date or I'm misinterpreting it?



On 25 November 2014 at 11:18, Bilgin Ibryam <bi...@gmail.com> wrote:

> Hi all,
>
> I'd like to write couple of route definitions that will be reused in
> multiple places.
>
> If I use the Java DSL it is straight forward, I can reuse the RouteBuilder
> class in many places, but I want to use the XML DSL and I can see two
> options:
>
> 1. Use <routes> statements. Looks like it is mostly used for unit tests.
> 2. Use routeContext to define the routes.
>
> Can anyone tell me what is the difference and the intended use of 1 and 2?
>
> What limitations they have compared to normal routes defined in Java DSL
> or XML DSL?
>
>
> [1] http://camel.apache.org/loading-routes-from-xml-files.html
> [2]
> http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html
>
> TIA,
>
> --
> Bilgin Ibryam
>
> Red Hat, Inc.
> Apache Camel & Apache OFBiz committer
> Blog: ofbizian.com
> Twitter: @bibryam <https://twitter.com/bibryam>
>
> Author of Instant Apache Camel Message Routing
> http://www.amazon.com/dp/1783283475
>



-- 
Bilgin Ibryam

Red Hat, Inc.
Apache Camel & Apache OFBiz committer
Blog: ofbizian.com
Twitter: @bibryam <https://twitter.com/bibryam>

Author of Instant Apache Camel Message Routing
http://www.amazon.com/dp/1783283475

Re: Best way for reusing routes

Posted by Bilgin Ibryam <bi...@gmail.com>.
Thanks Claus.
And from top of your head, can you tell me how much is 1 and 2 different to
defining routes in a <camelContex> element?

My guess is that I have to go with Java DSL to be on the safe side and be
sure that the route definitions will function properly and reused in
different camel contexts defined in blueprint... Is that true?


On 25 November 2014 at 13:06, Claus Ibsen <cl...@gmail.com> wrote:

> 1 and 2 boils down to the same.
>
> <routeContextRef> will load the routes the same was as #1 does.
>
> On Tue, Nov 25, 2014 at 12:18 PM, Bilgin Ibryam <bi...@gmail.com> wrote:
> > Hi all,
> >
> > I'd like to write couple of route definitions that will be reused in
> > multiple places.
> >
> > If I use the Java DSL it is straight forward, I can reuse the
> RouteBuilder
> > class in many places, but I want to use the XML DSL and I can see two
> > options:
> >
> > 1. Use <routes> statements. Looks like it is mostly used for unit tests.
> > 2. Use routeContext to define the routes.
> >
> > Can anyone tell me what is the difference and the intended use of 1 and
> 2?
> >
> > What limitations they have compared to normal routes defined in Java DSL
> or
> > XML DSL?
> >
> >
> > [1] http://camel.apache.org/loading-routes-from-xml-files.html
> > [2]
> http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html
> >
> > TIA,
> >
> > --
> > Bilgin Ibryam
> >
> > Red Hat, Inc.
> > Apache Camel & Apache OFBiz committer
> > Blog: ofbizian.com
> > Twitter: @bibryam <https://twitter.com/bibryam>
> >
> > Author of Instant Apache Camel Message Routing
> > http://www.amazon.com/dp/1783283475
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>



-- 
Bilgin Ibryam

Red Hat, Inc.
Apache Camel & Apache OFBiz committer
Blog: ofbizian.com
Twitter: @bibryam <https://twitter.com/bibryam>

Author of Instant Apache Camel Message Routing
http://www.amazon.com/dp/1783283475

Re: Best way for reusing routes

Posted by Claus Ibsen <cl...@gmail.com>.
1 and 2 boils down to the same.

<routeContextRef> will load the routes the same was as #1 does.

On Tue, Nov 25, 2014 at 12:18 PM, Bilgin Ibryam <bi...@gmail.com> wrote:
> Hi all,
>
> I'd like to write couple of route definitions that will be reused in
> multiple places.
>
> If I use the Java DSL it is straight forward, I can reuse the RouteBuilder
> class in many places, but I want to use the XML DSL and I can see two
> options:
>
> 1. Use <routes> statements. Looks like it is mostly used for unit tests.
> 2. Use routeContext to define the routes.
>
> Can anyone tell me what is the difference and the intended use of 1 and 2?
>
> What limitations they have compared to normal routes defined in Java DSL or
> XML DSL?
>
>
> [1] http://camel.apache.org/loading-routes-from-xml-files.html
> [2] http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html
>
> TIA,
>
> --
> Bilgin Ibryam
>
> Red Hat, Inc.
> Apache Camel & Apache OFBiz committer
> Blog: ofbizian.com
> Twitter: @bibryam <https://twitter.com/bibryam>
>
> Author of Instant Apache Camel Message Routing
> http://www.amazon.com/dp/1783283475



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/