camel cdi extension

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

camel cdi extension

Romain Manni-Bucau
Hi,

following a discussion on deltaspike IRC channel i created a small CDI
extension camel oriented -->
https://github.com/rmannibucau/camel-cdi-extension

the idea is to decorate route builders with @CamelContextConfig(contextName
= "xxxx") and then be able to get injected the context directly:

     @Inject
    @CamelContextId("context1")
    private CamelContext ctx1;


Currently the context is created when needed (injection time) and destroyed
with the application.

That's more a poc than something completely done but was to let you know (I
know some work is done and the question on the way to start a context is
not totally completed).

- Romain
Reply | Threaded
Open this post in threaded view
|

Re: camel cdi extension

Charles Moulliard
Hi Romain,

This is really interesting what you have have developed. I don't really like how you add RouteBuilder in the create method (class CamelContextBean) and I would prefer that the user can provide this information like we do in a more Camel traditional way. By the way, I suggest that in the CamelContextBean class (method create) we use CdiCamelContext as it implements Camel Registry to do CDI bean lookup in the registry.

@Inject
@CamelContextId("context1")
private CamelContext ctx1;

ctx1.addRoutes(new MyRouteBuilder())

Remark : camel-cdi (2.10) allows already to do this ;-)

@Inject
protected CdiCamelContext camelCtx;

@Inject
protected org.fusesource.example.cdi.camel.SimpleCamelRoute simpleRoute;
 ...

 simpleRoute.setTimerUri("timer://simple?fixedRate=true&period=10s");

 // Add Camel Route
 camelCtx.addRoutes(simpleRoute);

So what could be the benefit to use this CDI extension ?

I will have a look on that today.

Regards,

Charles
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com