Hello camel community,

I’m taking my first steps in migrating from camel 2.25.1 to 3.0.0. Since 
(nearly) all our camel routes (more then 2000) are written using spring dsl, 
this migration is a very big job.

Our spring dsl routes regularly use external file scripting for doing some 
“coding” things. Until now, we used javascript for those scripting 
requirements. Javascript is not supported anymore in camel3 (and newer java 
versions) and therefore we will switch to groovy as scripting language.

I have several scripts where I need to access global camel context properties. 
In javascript, I did a properties.resolve("tris.dlq.mailer.to") call to resolve 
the properties. The 
https://camel.apache.org/components/latest/languages/groovy-language.html shows 
that the properties (as org.apache.camel.builder.script.PropertiesFunction) are 
passed to the external groovy file but I does not seems to work. A display of 
the groovy properties variables shows something like “{class=class 
Script_8adfd05454ebe3bbb0f3980896103164, binding=groovy.lang.Binding@62787393}” 
of type java.util.LinkedHashMap.
Examining the content of the “binding” also proves that there is no 
“properties” available.

The question I have for the community is how to work with global camel context 
properties in groovy.

Possible solutions could be:
1. value = 
camelContext.getPropertiesComponent().resolveProperty("tris.dlq.mailer.to").get();
 ⇒ gives a good result
2. value = camelContext.globalOptions.get("tris.dlq.mailer.to"); ⇒ gives a good 
result
3. value = 
org.apache.camel.builder.Builder.simple("properties:tris.dlq.mailer.to").evaluate(exchange,
 java.lang.String.class); ⇒ gives “properties:tris.dlq.mailer.to” as result and 
is not good
4. value = 
org.apache.camel.builder.Builder.simple("${properties:tris.dlq.mailer.to}").evaluate(exchange,
 java.lang.String.class); ⇒ gives a “No such property: tris for class: 
Script_56c358fac7b1c2c9df318d99c84d4670” error message.
The first option seems to be the best because it also supports default values.
--
Met vriendelijke groeten / Kind regards / Cordialement / Mit besten Grüßen,

Ronny AERTS
Product Owner Integrations / Integrations Manager
e: mailto:ronny.ae...@wisetechglobal.com  |  t: +32 (0) 3 326 50 75
https://www.linkedin.com/in/ronnyaerts/
https://www.intris.be/ / https://www.wisetechglobal.com/ | Empowering and 
enabling the logistics industry globally.
This email is subject to our 
http://www.wisetechglobal.com/ConfidentialityStatement.html




Intris nv   Wapenstilstandlaan 47   B-2600 Berchem

DISCLAIMER
This is an e-mail from Intris. The information contained in this communication 
is intended solely for use by the individual or entity to whom it is addressed.
Use of this communication by others is prohibited. If the e-mail message was 
sent to you by mistake, please notify 
intris.supp...@wisetechglobal.com<mailto:intris.supp...@wisetechglobal.com>, 
destroy it without reading, using, copying or disclosing its contents to any 
other person.
We accept no liability for damage related to data and/or documents which are 
communicated by electronic mail.

Reply via email to