【问题标题】:Apache Camel conditional routing didn't workApache Camel 条件路由不起作用
【发布时间】:2017-02-09 12:30:06
【问题描述】:

我正在尝试使用 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>

【问题讨论】:

  • @halfer..你为什么要编辑我的帖子???

标签: java spring-mvc apache-camel


【解决方案1】:

你能用Unix方式的文件分隔符试试吗?

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

【讨论】:

  • 我认为简单的语言是行不通的。我正在使用过滤器,它工作正常。感谢您的帮助。
猜你喜欢
  • 2018-02-14
  • 2016-09-29
  • 1970-01-01
  • 1970-01-01
  • 2018-07-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-19
  • 2014-05-23
相关资源
最近更新 更多