12

我需要最简单的扩展过滤器:fe 文件 20120523.173227.CustomerMaster05092012.QWERTY.xml 路由:

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

不起作用:

在索引 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)

好吧,也许我的坏。我把整个文件包括在内:

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

整个文件没问题。让我们尝试将 * 放在文件名的中间

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

又没关系。让我们在文件名中只输入一位数字

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

noup,camel 没有找到我尝试转义星号的此类文件,但它没有帮助。

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

文件只是被忽略了。所以问题1:如何使用星号?

和问题 2:如何使用多个文件扩展名,例如 include= .xml;。压缩

谢谢

4

3 回答 3

17

该死的,好的想法随之而来,使用蛮力我发现了正确的价值包括:

.*.xml|.*.zip
于 2013-02-25T04:26:49.523 回答
5
(?i).*.xml|.*.zip

如果您想要不区分大小写的文件扩展名匹配。

于 2015-01-20T02:49:19.560 回答
4

您必须正确转义字符串中的反斜杠并使用字符串结尾符号“$”:include=.*\\.xml$

于 2018-01-25T12:28:32.053 回答