繁体   English   中英

在Mule SFTP文件连接器中使用属性文件中的正则表达式

[英]Using a regex expression from property file in a Mule SFTP file connector

我有一个流程,可以通过正则表达式表达式过滤SFTP文件。 我使用属性文件来利用SFTP连接器的许多设置。 我无法执行的一项设置是file:filename-regex-filter元素内的regex模式属性。

这就是我拥有的SFTP连接器。

        <!-- Get the HiTrack files via SFTP -->
        <sftp:inbound-endpoint name="HiTrackInboundSFTPEndpoint"
            doc:name="Get SFTP"
            user="${sftp.origin.user}"
            password="${sftp.origin.password}"
            port="${sftp.origin.port}"
            path="${sftp.origin.path}"
            host="${sftp.origin.host}"
            pollingFrequency="${sftp.origin.pollingFrequency}"
            fileAge="${sftp.origin.fileAge}"
            responseTimeout="${sftp.origin.responseTimeout}"
            tempDir="${sftp.origin.tempDir}" 
            archiveDir="${local.archive.directory}" 
            archiveTempReceivingDir="${local.archive.receiveDir}" 
            archiveTempSendingDir="${local.archive.sendingDir}" 
            useTempFileTimestampSuffix="true">

            <!-- Use RegEx filter to filter only HiTrack files with within the proper date format YYYYMMdd
                 Range of dates are from 19000101 to 20991231 -->
            <file:filename-regex-filter
                pattern="hitrack_(19|20)\d\d(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])_(.*).xml"
                caseSensitive="false" />
        </sftp:inbound-endpoint>

我已经尝试过以下两种模式属性,但均未成功。

pattern="#[${regex.filter}]"

pattern="${regex.filter}"

我的属性文件包含所有列出的值,并且除了regex过滤器模式外,效果都很好。

regex.filter的属性文件如下:

regex.filter=hitrack_(19|20)\d\d(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])_(.*).xml

我没有任何错误; 使用属性表达式时,它只是不会传递任何有效文件。 仅在显式使用正则表达式时有效。

对于此问题,我将提供任何建议或更好的解决方案。

如果您正在读取spring属性,则需要转义某些字符,例如\\。 因此,请尝试:

regex.filter = hitrack_(19 | 20)\\\\ d \\\\ d(0 [1-9] | 1 [012])(0 [1-9] | [12] [0-9] | 3 [01] )_(。*)。XML

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM