camel-quarkus icon indicating copy to clipboard operation
camel-quarkus copied to clipboard

Add extension DSL modeline

Open zbendhiba opened this issue 2 years ago • 10 comments

Fixes #3834

zbendhiba avatar Jun 21 '22 14:06 zbendhiba

@davsclaus could you review please ?

zbendhiba avatar Jun 21 '22 14:06 zbendhiba

@davsclaus I want to make sure, it's an extension needed.

zbendhiba avatar Jun 21 '22 14:06 zbendhiba

Needs an integration test

zbendhiba avatar Jun 21 '22 15:06 zbendhiba

@davsclaus @jamesnetherton I'm trying to get some examples in the project. The lookup of properties doesn't work out of the box.

This line of code doesn't get the expected result. The reason behind is that the property is not available in the camel-microprofile-config propertiesComponent.

Any idea how can I bind those camel-dsl-modeline properties?

zbendhiba avatar Jun 27 '22 09:06 zbendhiba

Yes you cannot test it as if that is added to the property - the modeline is in use during route creations and are available for these routes.

Can you try to get the property trait via

        PropertiesComponent pc = camelContext.getPropertiesComponent();
        PropertiesSource ps = pc.getPropertiesSource("property");

davsclaus avatar Jun 27 '22 10:06 davsclaus

Yes you cannot test it as if that is added to the property - the modeline is in use during route creations and are available for these routes.

Can you try to get the property trait via

        PropertiesComponent pc = camelContext.getPropertiesComponent();
        PropertiesSource ps = pc.getPropertiesSource("property");

@davsclaus Nope, but I guess the way I test is not okay. When you say the modeline is in use during route creations. Is having the dependency is enough, or do we need to configure the context before starting the routes ?

zbendhiba avatar Jun 27 '22 12:06 zbendhiba

@davsclaus what makes this propertiesSource different from null. I'm missing the part of what init this one.

zbendhiba avatar Jun 27 '22 12:06 zbendhiba

Its loaded via classpath service detection https://github.com/apache/camel/blob/2245f5c1eb1c63ec0beaaf598cc476bb6038a1ff/dsl/camel-dsl-modeline/src/generated/resources/META-INF/services/org/apache/camel/properties-source-factory

Which is done on startup at https://github.com/apache/camel/blob/main/core/camel-base/src/main/java/org/apache/camel/component/properties/PropertiesComponent.java#L740

It may be that camel-quarkus need some "build step" code that detect that camel-modeline-dsl is on the classpath and automatic loads the properties source and enlist in the registry.

For what its worth is similar to how many of the other optional services in Camel are auto-detect from classpath, where quarkus has some build time optimizations.

davsclaus avatar Jun 27 '22 15:06 davsclaus

@davsclaus thanks for all the explanations. I resolved it by adding the trait via a recorder on Runtime Init. I'll add more tests, and try native mode, so I'm keeping this one as draft.

zbendhiba avatar Jun 28 '22 15:06 zbendhiba

The PR is ready for reviews. I've added integrations tests and native support

zbendhiba avatar Jul 04 '22 14:07 zbendhiba