Quantcast

dynamic property keys

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

dynamic property keys

paramjyotsingh
I am trying to read a property with dynamic property key

i have property like

1234_host=<hostname>
1234_port=<port>

where "1234" is group code, and it it dynamic, i will extract it from input file i receive and consume service running at this host

i have configuration like

<route>
  <from uri="file://inputfolder/" />
  <bean ref="extractGroupAndSetInHeader" />
  <setHeader headerName="groupHost">
        <constant>{{${in.header.groupID}_host}}</constant>
  </setHeader>
  <setHeader headerName="groupPort">
        <constant>{{${in.header.groupID}_port}}</constant>
  </setHeader>
  <recipientList>         
        <simple>cxfrs://http://${header.groupHost}:${header.groupPort}/item/${in.header.itemId}</simple>
  </recipientList>
</route>

But reading property with dynamic key does not works this way.

Can someone please help me about how to read properties with dynamic keys in camel spring DSL.

Thanks and Regards,
Paramjyot Singh
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dynamic property keys

Claus Ibsen-2
On Wed, Jun 13, 2012 at 7:29 PM, paramjyotsingh <[hidden email]>wrote:

> I am trying to read a property with dynamic property key
>
> i have property like
>
> 1234_host=<hostname>
> 1234_port=<port>
>
> where "1234" is group code, and it it dynamic, i will extract it from input
> file i receive and consume service running at this host
>
> i have configuration like
>
> <route>
>  <from uri="file://inputfolder/" />
>  <bean ref="extractGroupAndSetInHeader" />
>  <setHeader headerName="groupHost">
>        <constant>{{${in.header.groupID}_host}}</constant>
>  </setHeader>
>  <setHeader headerName="groupPort">
>        <constant>{{${in.header.groupID}_port}}</constant>
>  </setHeader>
>  <recipientList>
>
>
Can you try with simple instead of the constant
<simple>${properties:${header.groupID}_host}</simple>




> <simple>cxfrs://http://
> ${header.groupHost}:${header.groupPort}/item/${in.header.itemId}</simple>
>  </recipientList>
> </route>
>
> But reading property with dynamic key does not works this way.
>
> Can someone please help me about how to read properties with dynamic keys
> in
> camel spring DSL.
>
> Thanks and Regards,
> Paramjyot Singh
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/dynamic-property-keys-tp5714449.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Claus Ibsen
-----------------
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dynamic property keys

paramjyotsingh
Thanks Claus It works ...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dynamic property keys

paramjyotsingh
Hi Claus,

In different system I have camel 2.8.1, and i am getting error while executing same configuration on that version. Can you please tell me this does not work in camel 2.8.1.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dynamic property keys

paramjyotsingh
This post was updated on .
Hey Claus,

I looked at the documentation it says that nested expressions are not supported in 2.8.X and older. Can you please suggest any work around for this scenario.

Thanks and Regards,
Paramjyot Singh
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: dynamic property keys

Claus Ibsen-2
On Mon, Jun 25, 2012 at 7:40 PM, paramjyotsingh
<[hidden email]> wrote:
> Hey Clause,
>
> I looked at the documentation it says that nested expressions are not
> supported in 2.8.X and older. Can you please suggest any work around for
> this scenario.
>

You can use a java bean / processor, and then there is any API on
CamelContext to resolve property placeholders
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContext.html#resolvePropertyPlaceholders(java.lang.String)

Then you can lookup the placeholders 2 times as nested are still not
supported. But then you can do this manually in some java code.

And then in the <setHeader> you can use a <bean> expression to call
your bean / processor.

> Thanks and Regards,
> Paramjyot Singh
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/dynamic-property-keys-tp5714449p5715074.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Loading...