Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel simple expression language - How to get property value dynamically

Tags:

apache-camel

I am new to Camel and using simple expression to get value from property file in Java DSL.

.setProperty("PortalUrl", simple("properties:Portal.url"))

Property file value -
Portal.url=abc.com/example

However now i need to get the customer specific URL from property file. Example values -

Portal.url.customer1=abc.com/example/abcd Portal.url.customer2=abc.com/example/xyz

The customer name comes in the request itself, so i want to do it like
.setProperty("PortalUrl", simple("properties:Portal.url."+"${body.customerName}"))

but the above code is not working its giving me the value of the PortalUrl property as properties:Portal.ulr.customer1

and when i tried with a direct hard-coded value its giving me the right URL from property file - .setProperty("PortalUrl", simple("properties:Portal.url."+"customer1"))

and it returned correct value - abc.com/example/abcd

But i want to get the URL dynamically as par the customer name in incoming request. Can anyone help me on this, and explain how simple works.

like image 450
SBORA Avatar asked Oct 28 '25 09:10

SBORA


1 Answers

Have you tried with the ${body} function in the simple language:

 .setProperty("PortalUrl", 
     simple("${properties:Portal.url.${body.customerName}}"))
like image 68
Claus Ibsen Avatar answered Oct 31 '25 10:10

Claus Ibsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!