How to filter files using extensions using the include parameter in the Camel File2 component

I need the simplest filter by extension: FE file 20120523.173227.CustomerMaster05092012.QWERTY.xml Route:

<from uri="file://{{fdr.folder.working.url}}&amp;include=*.xml"/>

does not work:

Hanging metacharacter '*' next to index 0

WARN - file://root_folder/working/) [FileConsumer] Consumer Consumer[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed] failed polling endpoint: Endpoint[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed]. Will try again at next poll. Caused by: [java.util.regex.PatternSyntaxException - Dangling meta character '*' near index 0
*.xml
^]
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*.xml
^
    at java.util.regex.Pattern.error(Pattern.java:1713)
    at java.util.regex.Pattern.sequence(Pattern.java:1878)
    at java.util.regex.Pattern.expr(Pattern.java:1752)
    at java.util.regex.Pattern.compile(Pattern.java:1460)
    at java.util.regex.Pattern.<init>(Pattern.java:1133)
    at java.util.regex.Pattern.compile(Pattern.java:823)
    at java.util.regex.Pattern.matches(Pattern.java:928)
    at java.lang.String.matches(String.java:2090)
    at org.apache.camel.component.file.GenericFileConsumer.isMatched(GenericFileConsumer.java:458)
    at org.apache.camel.component.file.GenericFileConsumer.isValidFile(GenericFileConsumer.java:395)
    at org.apache.camel.component.file.FileConsumer.pollDirectory(FileConsumer.java:94)
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:107)
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

OK, maybe my bad. I included the whole file:

<from uri="file://{{fdr.folder.working.url}}&amp;include=20120523.173227.CustomerMaster05092012.QWERTY.xml"/>

The whole file is in order. Try putting * in the middle of the file name

<from uri="file://{{fdr.folder.working.url}}&amp;include=20120523.*.xml"/>

and again everything is in order. Insert only one digit in the file name

<from uri="file://{{fdr.folder.working.url}}&amp;include=2*.xml"/>

noup, the camel did not find such files I tried to escape from the asterisk, but this did not help.

<from uri="file://{{fdr.folder.working.url}}&amp;include=\*.xml"/>
and
<from uri="file://{{fdr.folder.working.url}}&amp;include=\\*.xml"/>

The file was simply ignored. so question 1: how to use an asterisk?

and question 2: how to use multi-file extensions, for example include = .xml; .zip

Thks

+5
source share
4 answers

damn, { }, , include:

.*.xml|.*.zip
+11
(?i).*.xml|.*.zip

, , , .

+3

These answers are a bit wrong as they accept foobarxml through a filter. Right answers:

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

You need to correctly escape the backslash in the string and use the end of the '$' line character: include=.*\\.xml$

0
source

All Articles