2017-03-22 58 views
0

我想讓WSO2 ESB以遞歸方式掃描本地文件夾,如果該目錄包含一個或多個目錄,則esb應該掃描目錄中的xml格式的文件(.info.xml左右)文件不包含在xml文件中,esb應執行數據庫操作,並將有關新文件的信息添加到xml文件中。Wso2 ESB使用新文件過濾器的目錄循環

但我如何讓序列做到這一點,更重要的是,我需要一個入站序列,它應該怎麼做?

+0

相信文件連接器應該是有幫助:https://docs.wso2.com/display/ ESBCONNECTORS/Working + with + File + Connector + Version + 2 –

+0

爲了能夠使用連接器 - 您應該先添加並啓用它:https://docs.wso2.com/display/ESB500/Working+with+連接器+通過+管理+控制檯和https://docs.wso2.com/display/ESB500/Working+with+Connectors+via+WSO2+ESB+Tooling –

回答

1

是的,你可以通過使用文件連接器search操作來做到這一點。

<fileconnector.search> 
    <source>{$ctx:source}</source> 
    <filePattern>{$ctx:filePattern}</filePattern> 
    <recursiveSearch>{$ctx:recursiveSearch}</recursiveSearch> 
    <setTimeout>{$ctx:setTimeout}</setTimeout> 
    <setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode> 
    <setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout> 
    <setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot> 
    <setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking> 
</fileconnector.search> 

filePattern:文件的圖案將被搜索(例如,[A-ZA-Z] [A-ZA-Z] *(TXT | XML |罐))。

請檢查here作爲搜索操作的示例用例。

1

您可以下載連接器[1]並按照鏈接[2]添加並啓用連接器,然後創建代理[3]。

文件搜索操作示例代理[4]。

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="FileConnector_search" 
     startOnLoad="true" 
     statistics="disable" 
     trace="disable" 
     transports="https,http"> 
    <target> 
     <inSequence> 
     <property expression="json-eval($.source)" name="source"/> 
     <property expression="json-eval($.filePattern)" name="filePattern"/> 
     <property expression="json-eval($.recursiveSearch)" name="recursiveSearch"/> 
     <fileconnector.search> 
      <source>{$ctx:source}</source> 
      <filePattern>{$ctx:filePattern}</filePattern> 
      <recursiveSearch>{$ctx:recursiveSearch}</recursiveSearch> 
     </fileconnector.search> 
     <respond/> 
     </inSequence> 
    </target> 
    <description/> 
</proxy> 

樣品申請。

{ 
    "source":"/home/vive/Desktop/file", 
    "recursiveSearch":"true", 
    "filePattern":".*\.xml" 
} 

[1] https://store.wso2.com/store/assets/esbconnector/details/48bab332-c6a6-4f5a-9b79-17e29c7ad4c6 [2] https://docs.wso2.com/display/ESB490/Managing+Connectors+in+Your+ESB+Instance [3] https://docs.wso2.com/display/ESB490/Custom+Proxy+Template [4] https://docs.wso2.com/display/ESBCONNECTORS/Working+with+the+File+Connector+Version+2#WorkingwiththeFileConnectorVersion2-search