You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ski n <ra...@gmail.com> on 2021/03/30 06:49:25 UTC

Using Multi language DSL's

Hi all,

In the latest and coming Camel versions various CamelK functionalities are
made broadly available within Camel. Exciting things like Kamelets and
Multi language DSL's.

About the last one I have some questions. In the routeloader example and
also in the blog post on version 3.9 spoken is that the routes (in Java,
xml, yaml, Kotlin, Groovy, Javascript) are loaded from a directory.

1) Is it also available to add/update routes programmatically directly from
the context or managedcontext?

For example you now can do this with XML:

ManagedCamelContext managed =
context.getExtension(ManagedCamelContext.class);
ManagedCamelContextMBean managedContext = managed.getManagedCamelContext();
managedContext.addOrUpdateRoutesFromXml(xml);

Is there away to do this generically for all DSL's? Like this:

context.addOrUpdateRoute(routeAsString,camelDSL);

Here the Camel route is presented as string and the camelDSL specify the
used DSL language (for example as an enum)

2) Is there a conversion between DSL's? The rationale is that it's easier
to migrate and learn a new DSL. For example a company has a lot of routes
in XML or Java. Now developers want to use Kotlin for example, but they are
maybe holding back because of migration and lack of documentation/examples.

p.s. the link in the 3.9 blog post points to

https://github.com/apache/camel-examples/tree/master/examples/camel-example-routeloader

instead of

https://github.com/apache/camel-examples/tree/master/examples/routeloader

Kind regards,

Raymond

Re: Using Multi language DSL's

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ad 1)
There is no direct support for this, but it would be possible. You
would need to stop and remove the existing routes.
And then you can load the routes again which then will compile and add
the routes on-the-fly.

Ad 2)
The Camel DSL is language agnostic, and you should be able to do all
of it in anything that can run on a Java JVM.
The kotlin and groovy dsl provided from Camel does not offer a rich
extended kotlin/groovy syntax but resemble more naturally the Java DSL
of Camel.
But you can of course use all of the kotlin/groovy power as you wish.

And thanks for reporting the broken link - fixing this now.

On Tue, Mar 30, 2021 at 8:49 AM ski n <ra...@gmail.com> wrote:
>
> Hi all,
>
> In the latest and coming Camel versions various CamelK functionalities are
> made broadly available within Camel. Exciting things like Kamelets and
> Multi language DSL's.
>
> About the last one I have some questions. In the routeloader example and
> also in the blog post on version 3.9 spoken is that the routes (in Java,
> xml, yaml, Kotlin, Groovy, Javascript) are loaded from a directory.
>
> 1) Is it also available to add/update routes programmatically directly from
> the context or managedcontext?
>
> For example you now can do this with XML:
>
> ManagedCamelContext managed =
> context.getExtension(ManagedCamelContext.class);
> ManagedCamelContextMBean managedContext = managed.getManagedCamelContext();
> managedContext.addOrUpdateRoutesFromXml(xml);
>
> Is there away to do this generically for all DSL's? Like this:
>
> context.addOrUpdateRoute(routeAsString,camelDSL);
>
> Here the Camel route is presented as string and the camelDSL specify the
> used DSL language (for example as an enum)
>
> 2) Is there a conversion between DSL's? The rationale is that it's easier
> to migrate and learn a new DSL. For example a company has a lot of routes
> in XML or Java. Now developers want to use Kotlin for example, but they are
> maybe holding back because of migration and lack of documentation/examples.
>
> p.s. the link in the 3.9 blog post points to
>
> https://github.com/apache/camel-examples/tree/master/examples/camel-example-routeloader
>
> instead of
>
> https://github.com/apache/camel-examples/tree/master/examples/routeloader
>
> Kind regards,
>
> Raymond



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2