moving file with camel

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

moving file with camel

adi milis
Hi,

I want to create simple routing in camel, to filter and move file

the case, I have one input folder, depends on the extention, it will be
moved to other folder

my routings are
try {
            context.addRoutes(new RouteBuilder() {
                public void configure() {

 from("file:data/inbox?noop=false&include=*.png").to("file:data/png");
                }
            });
        } catch (Exception e) {
            System.out.println(e.getMessage());
}

however, i got the following errors ..

WARNING: Consumer Consumer[file://data/inbox?include=*.png&noop=false] could
not poll endpoint: file://data/inbox?include=*.png&noop=false caused by:
Dangling meta character '*' near index 0
*.png
^
java.util.regex.PatternSyntaxException: Dangling meta character '*' near
index 0
*.png
^
        at java.util.regex.Pattern.error(Pattern.java:1713)

any idea what i'm missing here ?
Reply | Threaded
Open this post in threaded view
|

Re: moving file with camel

Claus Ibsen-2
Hi

The include option is using Java Reg Exp so you have to configure that
with a valid regexp.

So to only include PNG files you do like this: .*png$
This is a reg exp to match a string ending with png.



On Wed, Mar 16, 2011 at 1:30 PM, adi milis <[hidden email]> wrote:

> Hi,
>
> I want to create simple routing in camel, to filter and move file
>
> the case, I have one input folder, depends on the extention, it will be
> moved to other folder
>
> my routings are
> try {
>            context.addRoutes(new RouteBuilder() {
>                public void configure() {
>
>  from("file:data/inbox?noop=false&include=*.png").to("file:data/png");
>                }
>            });
>        } catch (Exception e) {
>            System.out.println(e.getMessage());
> }
>
> however, i got the following errors ..
>
> WARNING: Consumer Consumer[file://data/inbox?include=*.png&noop=false] could
> not poll endpoint: file://data/inbox?include=*.png&noop=false caused by:
> Dangling meta character '*' near index 0
> *.png
> ^
> java.util.regex.PatternSyntaxException: Dangling meta character '*' near
> index 0
> *.png
> ^
>        at java.util.regex.Pattern.error(Pattern.java:1713)
>
> any idea what i'm missing here ?
>



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

Re: moving file with camel

adi milis
Thanks .. It works now

btw, I got the code from the first chapter of your book in amazon,
in Easy Configuration section, the code doesnt even mention about regex.



On Wed, Mar 16, 2011 at 7:39 PM, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> The include option is using Java Reg Exp so you have to configure that
> with a valid regexp.
>
> So to only include PNG files you do like this: .*png$
> This is a reg exp to match a string ending with png.
>
>
>
> On Wed, Mar 16, 2011 at 1:30 PM, adi milis <[hidden email]> wrote:
> > Hi,
> >
> > I want to create simple routing in camel, to filter and move file
> >
> > the case, I have one input folder, depends on the extention, it will be
> > moved to other folder
> >
> > my routings are
> > try {
> >            context.addRoutes(new RouteBuilder() {
> >                public void configure() {
> >
> >  from("file:data/inbox?noop=false&include=*.png").to("file:data/png");
> >                }
> >            });
> >        } catch (Exception e) {
> >            System.out.println(e.getMessage());
> > }
> >
> > however, i got the following errors ..
> >
> > WARNING: Consumer Consumer[file://data/inbox?include=*.png&noop=false]
> could
> > not poll endpoint: file://data/inbox?include=*.png&noop=false caused by:
> > Dangling meta character '*' near index 0
> > *.png
> > ^
> > java.util.regex.PatternSyntaxException: Dangling meta character '*' near
> > index 0
> > *.png
> > ^
> >        at java.util.regex.Pattern.error(Pattern.java:1713)
> >
> > any idea what i'm missing here ?
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [hidden email]
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
Reply | Threaded
Open this post in threaded view
|

Re: moving file with camel

Claus Ibsen-2
On Wed, Mar 16, 2011 at 2:42 PM, adi milis <[hidden email]> wrote:
> Thanks .. It works now
>
> btw, I got the code from the first chapter of your book in amazon,
> in Easy Configuration section, the code doesnt even mention about regex.

Jonathan updated chapter 2 to mention regexp and show how to filter
only XML files.
Will be in the updated book, when Manning does a 2nd print.

>
>
>
> On Wed, Mar 16, 2011 at 7:39 PM, Claus Ibsen <[hidden email]> wrote:
>
>> Hi
>>
>> The include option is using Java Reg Exp so you have to configure that
>> with a valid regexp.
>>
>> So to only include PNG files you do like this: .*png$
>> This is a reg exp to match a string ending with png.
>>
>>
>>
>> On Wed, Mar 16, 2011 at 1:30 PM, adi milis <[hidden email]> wrote:
>> > Hi,
>> >
>> > I want to create simple routing in camel, to filter and move file
>> >
>> > the case, I have one input folder, depends on the extention, it will be
>> > moved to other folder
>> >
>> > my routings are
>> > try {
>> >            context.addRoutes(new RouteBuilder() {
>> >                public void configure() {
>> >
>> >  from("file:data/inbox?noop=false&include=*.png").to("file:data/png");
>> >                }
>> >            });
>> >        } catch (Exception e) {
>> >            System.out.println(e.getMessage());
>> > }
>> >
>> > however, i got the following errors ..
>> >
>> > WARNING: Consumer Consumer[file://data/inbox?include=*.png&noop=false]
>> could
>> > not poll endpoint: file://data/inbox?include=*.png&noop=false caused by:
>> > Dangling meta character '*' near index 0
>> > *.png
>> > ^
>> > java.util.regex.PatternSyntaxException: Dangling meta character '*' near
>> > index 0
>> > *.png
>> > ^
>> >        at java.util.regex.Pattern.error(Pattern.java:1713)
>> >
>> > any idea what i'm missing here ?
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: [hidden email]
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



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

Re: moving file with camel

axdz
Dear,

-I want to filter multiple format file (as .html,.jpg...).How can I do it?
-I want to set time (time format only includes hours as 04:00) for route moving file.Please give me some advice.

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

AW: moving file with camel

Jan Matèrne (jhm)
> -I want to filter multiple format file (as .html,.jpg...).How can I do
> it?

You could read only these files:
http://camel.apache.org/file2.html
Option "fileName": For consumers, it's used as a filename filter.
Or Options include/antInclude/exclude/antExclude

Or you use a content based router on the message header "CamelFileName".



> -I want to set time (time format only includes hours as 04:00) for
> route moving file.Please give me some advice.

Not clear to me, what you mean.


Jan

Reply | Threaded
Open this post in threaded view
|

Re: moving file with camel

Allan C.
I think using timer/quartz with content enricher (pollEnrich) could be your
solution.

Regards,
Allan C.

On Tue, Dec 6, 2016 at 4:46 PM, Jan Matèrne (jhm) <[hidden email]> wrote:

> > -I want to filter multiple format file (as .html,.jpg...).How can I do
> > it?
>
> You could read only these files:
> http://camel.apache.org/file2.html
> Option "fileName": For consumers, it's used as a filename filter.
> Or Options include/antInclude/exclude/antExclude
>
> Or you use a content based router on the message header "CamelFileName".
>
>
>
> > -I want to set time (time format only includes hours as 04:00) for
> > route moving file.Please give me some advice.
>
> Not clear to me, what you mean.
>
>
> Jan
>
>
Reply | Threaded
Open this post in threaded view
|

Re: moving file with camel

TimoRiikonen
This post has NOT been accepted by the mailing list yet.
This post was updated on .
In reply to this post by axdz
Filter

    (?i).*/.xml|.*/.zip

should accept xml and zip files both.
Reply | Threaded
Open this post in threaded view
|

Re: moving file with camel

TimoRiikonen
This post has NOT been accepted by the mailing list yet.
This post was updated on .
In reply to this post by Claus Ibsen-2
Filter

    (?i).*/.png

is better.

Reasoning:
- $ is not required to define the end. It should not do any harm, but it does not add any value either. Just defining nothing does the same.
- (?i) makes filter case-insensitive
- /. ensures that foobarpng does not pass through the filter.