Apache Camel条件路由没有工作

时间:2017-02-09 12:30:07

标签: java spring-mvc apache-camel

我正在尝试使用Apache Camel条件路由传输文件。条件是文件名以" 041PACS"开头。它在源文件夹上创建了一个.camel目录。但不知道为什么文件没有转移到目标文件夹。控制台没有错误。

我使用的是Camel 2.17.3和JDK 1.7。

的applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName"
    xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.17.3.xsd 
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">


<import resource="actionRoutes.xml" />

    <camelContext streamCache="true"
        xmlns="http://camel.apache.org/schema/spring">
        <package>in.client.camelbean</package>
        <routeContextRef ref="actionRoutes" />
    </camelContext> 

</beans>

actionRoutes.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.17.3.xsd ">

    <!-- Only the routeContext is here -->

    <routeContext id="actionRoutes" xmlns="http://camel.apache.org/schema/spring">

   <route id="route36">
            <from uri="file:\\home\41\CAMEL\reports" />         
           <choice>
                    <when>
                        <simple>${header.CamelFileName.startsWith("041PACS")} == 'true'</simple>
                            <to uri="file:\\home\41\CAMEL\result?noop=true" />                  
                    </when>
           </choice>
        </route>

</routeContext>
</beans>

1 个答案:

答案 0 :(得分:0)

你可以尝试使用File Seperator的Unix方式吗?

文件://家/ 41 / CAMEL /结果空操作=真