2013-08-20 115 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}}应该这样做(同样对于错误路径)。