2013-08-20 187 views
-1

我們使用下面的配置將文件從單一來源發送到多個遠程目標。駱駝組播問題

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xsi:schemaLocation=" 
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd 
     http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> 

     <routeContext id="gcgRatesOutbound" xmlns="http://camel.apache.org/schema/spring"> 
       <route id="gcgRatesFileOut">  
         <from uri="file:{{nas.root}}/{{gcg.out.prices.dir}}?delay={{poll.delay}}&amp;initialDelay={{initial.delay}}&amp;readLock=rename&amp;scheduledExecutorService=#scheduledExecutorService" />          
         <multicast stopOnException="true"> 

           <to uri="scp://{{gcg.ste.Client1_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client1}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" /> 

           <to uri="scp://{{gcg.ste.Client2_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client2}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" />        

           <to uri="scp://{{gcg.ste.Client3_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client3}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" />            
         </multicast> 
       </route> 
     </routeContext> 
</beans> 

使用上述確認,文件到達遠程目標,它確認到所有遠程目標的連接都已成功完成。

我們需要在將文件成功傳輸到所有遠程目標後,將文件移動到存檔文件夾。 並且應該移動到錯誤文件夾incase任何錯誤。

然而,當我將存檔代碼(元素)作爲子元素添加到上述配置中的多播元素並使用和標籤將文件移動到出錯文件夾時。該文件不會到達遠程目標。

<doTry>  
     <multicast stopOnException="true" parallelProcessing="true"> 

           <to uri="scp://{{gcg.ste.Client1_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client1}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" /> 

           <to uri="scp://{{gcg.ste.Client2_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client2}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" />        

           <to uri="scp://{{gcg.ste.Client3_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client3}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" /> 

       <to uri="file://{{nas.root}}/{{gcg.out.prices.dir}}?fileName={{archive.dir}}" /> 
     </multicast> 
<doCatch> 
     <exception>java.lang.Exception</exception> 
       <handled> 
         <constant>true</constant> 
       </handled>          

       <to uri="file://{{nas.root}}/{{gcg.out.prices.dir}}?fileName={{error.dir}}" /> 
</doCatch> 
</doTry> 

該文件沒有到達遠程目標,也沒有產生任何日誌,文件被移動到存檔文件夾。

我試圖將遙控目的地,歸檔代碼和錯誤在單獨的路由碼,並且具有其在一個單一的多播參考如下的舉動

  <to uri="direct:Client1FileOut" /> 

      <to uri="direct:Client2FileOut" />                              

      <to uri="direct:Client3FileOut" />      

      <to uri="direct:MoveToArchive" />          

<route id="gcgFileOut1">  
         <from uri="direct:Client1FileOut" />      
         <doTry>      

           <to uri="scp://{{gcg.ste.Client1_User_Name}}@{{gcg.ste.Host_Name}}:{{gcg.ste.Port_Number}}/{{gcg.ste.Destination_Client1}}?knownHostsFile={{ssh.knownHosts}}&amp;privateKeyFile={{ssh.privateKey}}" /> 
           <doCatch> 
               <exception>java.lang.Exception</exception> 
               <handled> 
                 <constant>true</constant> 
               </handled> 

               <to uri="direct:gcgError" />  

           </doCatch> 
         </doTry> 
       </route> 

但是,文件不會到達遠程目標,也不會產生任何日誌,並且該文件將被移至歸檔文件夾。

我是駱駝新手。

我嘗試使用shareUnitOfWork屬性如下

<multicast shareUnitOfWork="true"> 

但是,文件移動到與Test_2_19082013_3.txt.camelLock文件

不知道一起存檔文件夾,爲什麼這個文件也被移動時要存檔丟棄的文件是Test_2_19082013_3.txt

此外,在放置位置中創建了名爲「ARCHIV〜1」的文件夾。

+0

這也在駱駝郵件列表中首先討論過。記者並不在意:( –

+0

克勞斯,我想我在這裏,因爲答覆沒有幫助,我仍然在等待執行。 – MMM

回答

1

將文件移動到歸檔文件時可能出錯。您有stopOnException="true" parallelProcessing="true",並且本地文件可能首先完成,因爲它應該是最快的。

您可能想要在某處打印該錯誤。現在,您捕獲異常並將錯誤標記爲已處理。你仍然期待日誌。使用log組件並手動輸出一些日誌語句。不僅在案件或錯誤,而且在成功的情況下。您可以登錄調試級別,以便在需要的時候手動啓用日誌打印 - 就像現在一樣。

另一種選擇讓你找出發生了什麼是啓用trace這將使你更少的「盲」。

儘管如此有關調試你自己 - 在輸入目錄

要存檔和storeing錯誤消息。你看到的鎖文件是駱駝正在讀的時候。這可能是你的應用程序發生故障的原因。

{{nas.root}}/{{gcg.out.prices.dir}}

fileName=...是文件名,而不是其他子目錄。

因此:file://{{nas.root}}/{{gcg.out.prices.dir}}/{{archive.dir}}應該這樣做(同樣對於錯誤路徑)。