You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by paramjyotsingh <pa...@gmail.com> on 2012/06/13 19:29:53 UTC

dynamic property keys

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

--
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.

Re: dynamic property keys

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jun 25, 2012 at 7:40 PM, paramjyotsingh
<pa...@gmail.com> 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: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: dynamic property keys

Posted by paramjyotsingh <pa...@gmail.com>.
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.

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.

Re: dynamic property keys

Posted by paramjyotsingh <pa...@gmail.com>.
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.

--
View this message in context: http://camel.465427.n5.nabble.com/dynamic-property-keys-tp5714449p5715072.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: dynamic property keys

Posted by paramjyotsingh <pa...@gmail.com>.
Thanks Claus It works ...

--
View this message in context: http://camel.465427.n5.nabble.com/dynamic-property-keys-tp5714449p5714488.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: dynamic property keys

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 13, 2012 at 7:29 PM, paramjyotsingh <pa...@gmail.com>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: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen