How to use simple expression in properties file?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use simple expression in properties file?

shuston
Is it possible to put a simple() expression in a properties string and have Camel evaluate it at run time?

Here's what I'm trying to do:
- Set a message header ID with a value I want to use later
- Use .toD("{{event.sink}}")

application.properties can then have something like:

event.sink = simple("file://.?fileName=status-${header.ID}.txt")

The goal being to have a message body written to a file whose name includes the ID header value.

When I try to run this I get an exception:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'header.ID' in value "simple("file://.?fileName=status-${header.ID}.txt")"

Thanks,
-Steve
Reply | Threaded
Open this post in threaded view
|

Re: How to use simple expression in properties file?

Claus Ibsen-2
On Wed, Jun 26, 2019 at 11:49 PM Steve Huston <[hidden email]> wrote:

>
> Is it possible to put a simple() expression in a properties string and have Camel evaluate it at run time?
>
> Here's what I'm trying to do:
> - Set a message header ID with a value I want to use later
> - Use .toD("{{event.sink}}")
>
> application.properties can then have something like:
>
> event.sink = simple("file://.?fileName=status-${header.ID}.txt")
>

toD using a string is simple language already, so just use

event.sink = file://.?fileName=status-${header.ID}.txt

> The goal being to have a message body written to a file whose name includes the ID header value.
>
> When I try to run this I get an exception:
>
> Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'header.ID' in value "simple("file://.?fileName=status-${header.ID}.txt")"
>

And you can use $simple{xxx} syntax for the fileName value



> Thanks,
> -Steve



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

RE: How to use simple expression in properties file?

shuston
Thank you for clarifying that the string for toD is already a simple string. However, it still fails with the same exception at runtime:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'header.SMID' in value "file://.?fileName=status-${header.SMID}.txt"

-Steve

> -----Original Message-----
> From: Claus Ibsen <[hidden email]>
> Sent: Wednesday, June 26, 2019 11:41 PM
> To: [hidden email]
> Subject: Re: How to use simple expression in properties file?
>
> On Wed, Jun 26, 2019 at 11:49 PM Steve Huston <[hidden email]>
> wrote:
> >
> > Is it possible to put a simple() expression in a properties string and have
> Camel evaluate it at run time?
> >
> > Here's what I'm trying to do:
> > - Set a message header ID with a value I want to use later
> > - Use .toD("{{event.sink}}")
> >
> > application.properties can then have something like:
> >
> > event.sink = simple("file://.?fileName=status-${header.ID}.txt")
> >
>
> toD using a string is simple language already, so just use
>
> event.sink = file://.?fileName=status-${header.ID}.txt
>
> > The goal being to have a message body written to a file whose name
> includes the ID header value.
> >
> > When I try to run this I get an exception:
> >
> > Caused by: java.lang.IllegalArgumentException: Could not resolve
> placeholder 'header.ID' in value "simple("file://.?fileName=status-
> ${header.ID}.txt")"
> >
>
> And you can use $simple{xxx} syntax for the fileName value
>
>
>
> > Thanks,
> > -Steve
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: How to use simple expression in properties file?

Claus Ibsen-2
Hi

Yeah use $simple{header.xxx}

On Thu, Jun 27, 2019 at 4:55 PM Steve Huston <[hidden email]> wrote:

>
> Thank you for clarifying that the string for toD is already a simple string. However, it still fails with the same exception at runtime:
>
> Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'header.SMID' in value "file://.?fileName=status-${header.SMID}.txt"
>
> -Steve
>
> > -----Original Message-----
> > From: Claus Ibsen <[hidden email]>
> > Sent: Wednesday, June 26, 2019 11:41 PM
> > To: [hidden email]
> > Subject: Re: How to use simple expression in properties file?
> >
> > On Wed, Jun 26, 2019 at 11:49 PM Steve Huston <[hidden email]>
> > wrote:
> > >
> > > Is it possible to put a simple() expression in a properties string and have
> > Camel evaluate it at run time?
> > >
> > > Here's what I'm trying to do:
> > > - Set a message header ID with a value I want to use later
> > > - Use .toD("{{event.sink}}")
> > >
> > > application.properties can then have something like:
> > >
> > > event.sink = simple("file://.?fileName=status-${header.ID}.txt")
> > >
> >
> > toD using a string is simple language already, so just use
> >
> > event.sink = file://.?fileName=status-${header.ID}.txt
> >
> > > The goal being to have a message body written to a file whose name
> > includes the ID header value.
> > >
> > > When I try to run this I get an exception:
> > >
> > > Caused by: java.lang.IllegalArgumentException: Could not resolve
> > placeholder 'header.ID' in value "simple("file://.?fileName=status-
> > ${header.ID}.txt")"
> > >
> >
> > And you can use $simple{xxx} syntax for the fileName value
> >
> >
> >
> > > Thanks,
> > > -Steve
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

RE: How to use simple expression in properties file?

shuston
Perfect - thank you!!!

> -----Original Message-----
> From: Claus Ibsen <[hidden email]>
> Sent: Thursday, June 27, 2019 1:00 PM
> To: [hidden email]
> Subject: Re: How to use simple expression in properties file?
>
> Hi
>
> Yeah use $simple{header.xxx}
>
> On Thu, Jun 27, 2019 at 4:55 PM Steve Huston <[hidden email]>
> wrote:
> >
> > Thank you for clarifying that the string for toD is already a simple string.
> However, it still fails with the same exception at runtime:
> >
> > Caused by: java.lang.IllegalArgumentException: Could not resolve
> placeholder 'header.SMID' in value "file://.?fileName=status-
> ${header.SMID}.txt"
> >
> > -Steve
> >
> > > -----Original Message-----
> > > From: Claus Ibsen <[hidden email]>
> > > Sent: Wednesday, June 26, 2019 11:41 PM
> > > To: [hidden email]
> > > Subject: Re: How to use simple expression in properties file?
> > >
> > > On Wed, Jun 26, 2019 at 11:49 PM Steve Huston
> <[hidden email]>
> > > wrote:
> > > >
> > > > Is it possible to put a simple() expression in a properties string and have
> > > Camel evaluate it at run time?
> > > >
> > > > Here's what I'm trying to do:
> > > > - Set a message header ID with a value I want to use later
> > > > - Use .toD("{{event.sink}}")
> > > >
> > > > application.properties can then have something like:
> > > >
> > > > event.sink = simple("file://.?fileName=status-${header.ID}.txt")
> > > >
> > >
> > > toD using a string is simple language already, so just use
> > >
> > > event.sink = file://.?fileName=status-${header.ID}.txt
> > >
> > > > The goal being to have a message body written to a file whose name
> > > includes the ID header value.
> > > >
> > > > When I try to run this I get an exception:
> > > >
> > > > Caused by: java.lang.IllegalArgumentException: Could not resolve
> > > placeholder 'header.ID' in value "simple("file://.?fileName=status-
> > > ${header.ID}.txt")"
> > > >
> > >
> > > And you can use $simple{xxx} syntax for the fileName value
> > >
> > >
> > >
> > > > Thanks,
> > > > -Steve
> > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > http://davsclaus.com @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2