2017-02-09 150 views
-2

我试图通过使用Apache Camel条件路由来传输文件。条件是如果文件名以“041PACS”开头。它在源文件夹上创建了一个.camel目录。但不知道为什么文件没有传输到目标文件夹。控制台中没有错误。Apache 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> 
+0

@ halfer ..你为什么要编辑我的文章? – shubho

回答

0

可以请你的文件分隔符的Unix的尝试?

file:// home/41/CAMEL/result?noop = true

+0

我认为简单的语言是行不通的。我正在使用过滤器,它的工作正常。谢谢你的帮助。 – shubho