You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by niteshjain <ni...@gmail.com> on 2015/04/13 14:53:24 UTC

How to use Apache camel -file component to do a pattern match & rename the file

Wanted to know , how can i use camel file component to pattern match and get
the file ending with .xml and then later rename it to
filename.xml.processed.

....
<camelContext trace="false" 	xmlns="http://camel.apache.org/schema/spring">
<route id="loadtoMemory">
	<from
uri="file:{{TEST_HOME}}/myfolder?move=${date:now:yyyyMMdd}/${file:name}" />
				
	<process ref="processFile" />
</route>
.....
</camelContext>

tried
*file:{{TEST_HOME}}/myfolder&amp;include=.*.xml?move=${file:name}.processed"*

but its not working any help would be appreciated

Regards,
Nitesh



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by niteshjain <ni...@gmail.com>.
cool, That worked for me.
Thanks a lot.

Regards,
Nithesh




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765849.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by yogu13 <yo...@gmail.com>.
Please use this

<from
uri="file:{{TEST_HOME}}/myfolder/?include=Sample.*xml&amp;move=${date:now:yyyyMMdd}/${file:name}.processed"
/>

and let us know...


Regards,
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765751.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by niteshjain <ni...@gmail.com>.
Hi,

i don't know how it is modifying the URL after i deploy, so i removed
"&amp;" before include

<from
uri="file:{{TEST_HOME}}/myfolder/?&amp;include=Sample.*xml?move=${date:now:yyyyMMdd}/${file:name}.processed"
/>

java.util.regex.PatternSyntaxException: Illegal repetition near index 17
Sample.*xml?move=${date:now:yyyyMMdd}/${file:name}.processed
                 ^
        at java.util.regex.Pattern.error(Pattern.java:1924)[:1.7.0_67]
        at java.util.regex.Pattern.closure(Pattern.java:3104)[:1.7.0_67]
        at java.util.regex.Pattern.sequence(Pattern.java:2101)[:1.7.0_67]
        at java.util.regex.Pattern.expr(Pattern.java:1964)[:1.7.0_67]



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765750.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

It has to be a valid uri,

file:///opt/jboss-fuse-6.1.0.redhat-379/myfolder/?=&include=Sample

should be

file:///opt/jboss-fuse-6.1.0.redhat-379/myfolder/?include=Sample

On Tue, Apr 14, 2015 at 9:55 AM, niteshjain <ni...@gmail.com> wrote:
> getting an ResolveEndpointFailedException
>
> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
> resolve endpoint:
> file:///opt/jboss-fuse-6.1.0.redhat-379/myfolder/?=&include=Sample.*xml%3Fmove%3D%24%7Bfile%3Aname%7D.processed
> due to: There are 1 parameters that couldn't be set on the endpoint. Check
> the uri if the parameters are spelt correctly and that they are properties
> of the endpoint. Unknown parameters=[{=}]
>
> currently configured endpoint:
> <from
> uri="file:{{TEST_HOME}}/myfolder/?&amp;include=Sample.*xml?move=${file:name}.processed"
> />
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765743.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by niteshjain <ni...@gmail.com>.
getting an ResolveEndpointFailedException

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint:
file:///opt/jboss-fuse-6.1.0.redhat-379/myfolder/?=&include=Sample.*xml%3Fmove%3D%24%7Bfile%3Aname%7D.processed
due to: There are 1 parameters that couldn't be set on the endpoint. Check
the uri if the parameters are spelt correctly and that they are properties
of the endpoint. Unknown parameters=[{=}]

currently configured endpoint:
<from
uri="file:{{TEST_HOME}}/myfolder/?&amp;include=Sample.*xml?move=${file:name}.processed"
/>



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765743.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Apr 14, 2015 at 8:42 AM, niteshjain <ni...@gmail.com> wrote:
> i'm using RedHat Linux server 7.0
> camel-version: 2.12.0
>
> and the file is not being picked nor renamed.
>
> *Cannot auto create starting directory:
> /opt/boss-fuse-6.1.0.redhat-379/myfolder/&include=Sample.*xml*
>

You have configured the endpoint wrong. The ? should come before the &


>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765738.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by niteshjain <ni...@gmail.com>.
i'm using RedHat Linux server 7.0
camel-version: 2.12.0

and the file is not being picked nor renamed.

*Cannot auto create starting directory:
/opt/boss-fuse-6.1.0.redhat-379/myfolder/&include=Sample.*xml*



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765738.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What OS and Camel version do you use?

And what do you mean by not working, can you be more specific? Is the
file not moved, not picked up or what else?

And what do you do in the process file? If on windows then take care
about closing all resources otherwise the file can be locked and
cannot be moved.

On Mon, Apr 13, 2015 at 2:53 PM, niteshjain <ni...@gmail.com> wrote:
> Wanted to know , how can i use camel file component to pattern match and get
> the file ending with .xml and then later rename it to
> filename.xml.processed.
>
> ....
> <camelContext trace="false"     xmlns="http://camel.apache.org/schema/spring">
> <route id="loadtoMemory">
>         <from
> uri="file:{{TEST_HOME}}/myfolder?move=${date:now:yyyyMMdd}/${file:name}" />
>
>         <process ref="processFile" />
> </route>
> .....
> </camelContext>
>
> tried
> *file:{{TEST_HOME}}/myfolder&amp;include=.*.xml?move=${file:name}.processed"*
>
> but its not working any help would be appreciated
>
> Regards,
> Nitesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by niteshjain <ni...@gmail.com>.
The file names are "Sample-Test1.xml" "Sample-Test2.xml" and so on..

i also tried this
1. <from
uri=&quot;file:{{TEST_HOME}}/myfolder&lt;b>&include=*.xml?move=${file:name}.processed*"
/>
2. <from
uri=&quot;file:{{TEST_HOME}}/myfolder&lt;b>&include=.*xml?move=${file:name}.processed*"
/>
3.1. <from
uri=&quot;file:{{TEST_HOME}}/myfolder&lt;b>&include=\\.*xml?move=${file:name}.processed*"
/>
			



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765722.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use Apache camel -file component to do a pattern match & rename the file

Posted by yogu13 <yo...@gmail.com>.
Hi,

do your xml files to be picked start with a dot "." ?

The File Consumer will always skip any file whose name starts with a dot,
such as ., .camel, .m2 or .groovy.

Regards,
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-Apache-camel-file-component-to-do-a-pattern-match-rename-the-file-tp5765695p5765710.html
Sent from the Camel - Users mailing list archive at Nabble.com.