You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Kevin-Void <an...@gmail.com> on 2016/05/13 11:39:35 UTC

Dynamic URI based on file name/cfg file/property value

Hi Folks,

I am trying to pass a *to URI value dynamically* with a property value. That
property value will be configured  already in the cfg file.

When the file name is extracted using *CamelFileNameOnly* header, it has to
get passed to the to Uri endpoint. So that the same name is referred in the
code.

Please find my code below:

I have dropped a file with name *KevinFile.txt* in my server location=
D:\Servers\jboss-fuse-6.2.0.redhat-133\data\myLocalFTP
(file://data/myLocalFTP)

*Config File*

local.folder.url=file://data/myLocalFTP
KevinFile=file://data/KevinFileDirectory


*Camel Route*

<route id="awsRoute">
      <from uri="{{local.folder.url}}"/>
      <bean ref="processorClass" method="process"/>
      <log message="myProperty value is ${exchangeProperty.myProperty}"/>   
<---Gives the fileName
      <to uri="{{${exchangeProperty.myProperty}}}"/>       <--This is the
spot i am getting error :(
</route>


*ProcessorClass.java*

public class ProcessorClass implements Processor{
@Override
	public void process(Exchange exchange) throws Exception {
		
		String fileName = (String)
exchange.getIn().getHeader("CamelFileNameOnly");
		exchange.setProperty("myProperty", fileName);

	}
}

Thanks in advance.

Regards,
Kevin



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-URI-based-on-file-name-cfg-file-property-value-tp5782550.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic URI based on file name/cfg file/property value

Posted by Claus Ibsen <cl...@gmail.com>.
See this FAQ
http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

On Fri, May 13, 2016 at 1:39 PM, Kevin-Void <an...@gmail.com> wrote:
> Hi Folks,
>
> I am trying to pass a *to URI value dynamically* with a property value. That
> property value will be configured  already in the cfg file.
>
> When the file name is extracted using *CamelFileNameOnly* header, it has to
> get passed to the to Uri endpoint. So that the same name is referred in the
> code.
>
> Please find my code below:
>
> I have dropped a file with name *KevinFile.txt* in my server location=
> D:\Servers\jboss-fuse-6.2.0.redhat-133\data\myLocalFTP
> (file://data/myLocalFTP)
>
> *Config File*
>
> local.folder.url=file://data/myLocalFTP
> KevinFile=file://data/KevinFileDirectory
>
>
> *Camel Route*
>
> <route id="awsRoute">
>       <from uri="{{local.folder.url}}"/>
>       <bean ref="processorClass" method="process"/>
>       <log message="myProperty value is ${exchangeProperty.myProperty}"/>
> <---Gives the fileName
>       <to uri="{{${exchangeProperty.myProperty}}}"/>       <--This is the
> spot i am getting error :(
> </route>
>
>
> *ProcessorClass.java*
>
> public class ProcessorClass implements Processor{
> @Override
>         public void process(Exchange exchange) throws Exception {
>
>                 String fileName = (String)
> exchange.getIn().getHeader("CamelFileNameOnly");
>                 exchange.setProperty("myProperty", fileName);
>
>         }
> }
>
> Thanks in advance.
>
> Regards,
> Kevin
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-URI-based-on-file-name-cfg-file-property-value-tp5782550.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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