You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gr...@t-systems.com on 2021/03/03 13:35:54 UTC

using velocity in camel route

Hello all,
I have faced with a problem using a velocity template with #parse directive

The endpoint I have looks like
<to uri="velocity:file:routes/test/resources/my.vm?contentCache=false&amp;propertiesFile=file:routes/test/velocity.properties"/>

I have file.resource.loader.path=/absolute/path/to/templates/folder/ property defined in routes/test/velocity.properties file
And it works perfectly until I replace the string literal path with property in a placeholder, like file.resource.loader.path={{templates.path}}

It seems like it doesn't get resolved despite to the docs - https://camel.apache.org/components/2.x/velocity-component.html#_options - where resolvePropertyPlaceholders component option is true by default
Please, help

Best regards,
Grigorii Ivanov
T-Systems RUS


RE: using velocity in camel route

Posted by Gr...@t-systems.com.
Hello, Claus
Thanks, now I get it!
It would certainly be great to get the placeholder resolved in velocity properties file, however I found a workaround when I use an exchange property to complete the path string in file.resource.loader.path file property which could even be empty, see https://stackoverflow.com/a/66460020/6657231 for details 

-----Original Message-----
From: Claus Ibsen <cl...@gmail.com> 
Sent: Wednesday, March 3, 2021 7:50 PM
To: users@camel.apache.org
Subject: Re: using velocity in camel route

On Wed, Mar 3, 2021 at 2:36 PM <Gr...@t-systems.com> wrote:
>
> Hello all,
> I have faced with a problem using a velocity template with #parse 
> directive
>
> The endpoint I have looks like
> <to 
> uri="velocity:file:routes/test/resources/my.vm?contentCache=false&amp;
> propertiesFile=file:routes/test/velocity.properties"/>
>
> I have file.resource.loader.path=/absolute/path/to/templates/folder/ 
> property defined in routes/test/velocity.properties file And it works 
> perfectly until I replace the string literal path with property in a 
> placeholder, like file.resource.loader.path={{templates.path}}
>
> It seems like it doesn't get resolved despite to the docs - 
> https://camel.apache.org/components/2.x/velocity-component.html#_optio
> ns - where resolvePropertyPlaceholders component option is true by 
> default Please, help

That option is NOT for velocity templates but the component options itself.

I dont think velocity engine supports {{ }} placeholders in its template with Camel.
This would require somehow to be able to let velocity have 3rd party parsing / functions where it can delegate to Camel so we can do property placeholder.

I suggest you can try to research velocity how to add support for 3rd party functions and then we can take a look at how to leverage this with property placeholder.


>
> Best regards,
> Grigorii Ivanov
> T-Systems RUS
>


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

Re: using velocity in camel route

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 3, 2021 at 2:36 PM <Gr...@t-systems.com> wrote:
>
> Hello all,
> I have faced with a problem using a velocity template with #parse directive
>
> The endpoint I have looks like
> <to uri="velocity:file:routes/test/resources/my.vm?contentCache=false&amp;propertiesFile=file:routes/test/velocity.properties"/>
>
> I have file.resource.loader.path=/absolute/path/to/templates/folder/ property defined in routes/test/velocity.properties file
> And it works perfectly until I replace the string literal path with property in a placeholder, like file.resource.loader.path={{templates.path}}
>
> It seems like it doesn't get resolved despite to the docs - https://camel.apache.org/components/2.x/velocity-component.html#_options - where resolvePropertyPlaceholders component option is true by default
> Please, help

That option is NOT for velocity templates but the component options itself.

I dont think velocity engine supports {{ }} placeholders in its
template with Camel.
This would require somehow to be able to let velocity have 3rd party
parsing / functions where it can delegate to Camel so we can do
property placeholder.

I suggest you can try to research velocity how to add support for 3rd
party functions and then we can take a look at how to leverage this
with property placeholder.


>
> Best regards,
> Grigorii Ivanov
> T-Systems RUS
>


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