[英]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.