camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonin Stefanutti <anto...@stefanutti.fr>
Subject Re: cdi reuse the route
Date Thu, 13 Oct 2016 15:06:42 GMT
Hi,

There are multiple ways to achieve sharing routes across contexts in CDI. Maybe the most simple
example could be the following one:

@ContextName("foo")
@ContextName("bar")
class MySharedRouteBuilder extends RouteBuilder {

}

@ApplicationScoped
@ContextName("foo")
class FooCamelContext extends DefaultCamelContext {
}


@ApplicationScoped
@ContextName("bar")
class BarCamelContext extends DefaultCamelContext {
}

In that example you’ll get two Camel contexts auto-configured with the same RouteBuilder,
which can be configured depending on each context properties configuration sources. There
are probably a couple of other ways to achieve reuse though that first example should help
you get started.

As you mention Spring XML, starting Camel 2.18.0, Camel CDI can import Camel XML files as
documented in [1]. You can find an example in [2]. This may be useful to leverage existing
routeContext and routeContextRef elements.

Hope that helps.

[1]: http://camel.apache.org/cdi.html#CDI-CamelXMLconfigurationimport
[2]: https://github.com/apache/camel/tree/master/examples/camel-example-cdi-xml

Antonin

> On 13 Oct 2016, at 09:53, a746076drdrb <a746076@drdrb.net> wrote:
> 
> Hello,
> 
> I have a few question hot to use CDI routes. With spring xml it was easy to
> reuse routes and separate them into context. Is it also possible to use the
> same route twice with CDI but with diffrent config and maybe in difftent
> contexts? 
> 
> Is it possible to disable routes per configuration?
> 
> Thanks!
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/cdi-reuse-the-route-tp5788716.html
> Sent from the Camel Development mailing list archive at Nabble.com.

Mime
View raw message