-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>

使用上述配置文件到达远程目的地,这确认到所有远程目的地的连接都是成功的。

我们需要在文件成功传输到所有远程目标后将文件移动到存档文件夹。并且应该移动到错误文件夹以防出现任何错误。

但是,当我在上述配置中将归档代码(元素)作为子元素添加到多播元素并使用 和 标签将文件移动到错误文件夹时,以防出现错误。该文件未到达远程目标。

<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”的文件夹。

4

1 回答 1

1

Something might went wrong when moving the file to archive. You have stopOnException="true" parallelProcessing="true" and the local file is probably done first as it should be the fastest.

You probably want to print the error somewhere. Now, you catch the exception and mark the error as handled. Still you expect logs. Use the log component and output some log statements manually. Not only in case or error but also in case of success. You can log in the debug level so that you can manually enable log outprint in case you need it - like now.

Another option for you to figure out what's going on is to enable trace which will make you less "blind".

That said about debugging on your own -

You are archiving and storeing error messages in the input directory. The lock file you see is when Camel is reading. This is likely what's casuing your application to malfunction.

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

The fileName=... is the filename, not another sub directory.

So: file://{{nas.root}}/{{gcg.out.prices.dir}}/{{archive.dir}} should do it (likewise for the error path).

于 2013-08-20T05:01:25.250 回答