【问题标题】:Camel Spring DSL is not working as expectedCamel Spring DSL 未按预期工作
【发布时间】:2014-11-24 11:49:44
【问题描述】:

尝试使用 Java 和 Spring DSL 创建一个非常简单的从 FTP 位置读取的路由。

使用 Java DSL 创建的路由按预期工作。

from("{{ftp.server}}").to("file:target/download").log(
            "Downloaded file ${file:name} complete.");

选项:

ftp://x.x.x.x:21/in?username=kallada&password=kallada&passiveMode=false&localWorkDirectory=/tmp&delay=5s&move=done

但是使用 Spring DSL 创建的路由只是在登录 FTP 服务器后才退出。

<route id="ftpSend">
    <from uri="ftp://kallada@x.x.x.x:21/in?password=kallada&amp;passiveMode=false&amp;binary=true&amp;delay=6000&amp;localWorkDirectory=/tmp"/> 
    <to uri="file://target/download"/> 
</route>

我正在使用本地安装的 FTP 服务器 (FileZilla) 来测试这个应用程序。在调用使用 Spring DSL 创建的路由之后,程序刚刚退出。请参阅随附的控制台日志。

05:06:04.402 INFO  [main][org.apache.camel.impl.converter.DefaultTypeConverter] Loaded 176 type converters
05:06:04.896 INFO  [main][org.apache.camel.spring.SpringCamelContext] StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
05:06:05.156 INFO  [main][org.apache.camel.spring.SpringCamelContext] Route: ftpSend started and consuming from: Endpoint[ftp://kallada@127.0.0.1:21/in?binary=true&delay=6000&localWorkDirectory=%2Ftmp&passiveMode=false&password=xxxxxx]
05:06:05.171 INFO  [main][org.apache.camel.spring.SpringCamelContext] Total 1 routes, of which 1 is started.
05:06:05.174 INFO  [main][org.apache.camel.spring.SpringCamelContext] Apache Camel 2.12.0 (CamelContext: camel-1) started in 1.272 seconds

超过这个点程序就退出了。

另请参阅 FTP 服务器控制台日志。

(000079)24-11-2014 05:02:45 - kallada (x.x.x.x)> 250 CWD successful. "/" is current directory.
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> PWD
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> 257 "/" is current directory.
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> CWD in
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> 250 CWD successful. "/in" is current directory.
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> PORT 127,0,0,1,251,174
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> 200 Port command successful
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> LIST
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> 150 Opening data channel for directory listing of "/in"
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> 226 Successfully transferred "/in"
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> CWD /
(000079)24-11-2014 05:02:50 - kallada (x.x.x.x)> 250 CWD successful. "/" is current directory.
(000079)24-11-2014 05:02:53 - kallada (x.x.x.x)> disconnected.

任何解决此问题的建议都会有所帮助。

感谢和问候, 桑托什

【问题讨论】:

  • 春天你是怎么开始的?
  • @WillemJiang import rg.springframework.context.support.ClassPathXmlApplicationContext;公共类 TestTransfer { public static void main(String[] args) { new ClassPathXmlApplicationContext("/camel-spring-context.xml"); } }

标签: java apache-camel spring-dsl


【解决方案1】:

我认为你的 main 只是在启动骆驼上下文后退出。请查看this 了解如何独立运行 Camel 并保持其运行。

【讨论】:

  • 谢谢回复,情况和你解释的一样。我正在调用来自 camel-spring-context.xml 的骆驼路线作为类路径资源。但是只要我调用该文件,程序就会退出。有没有办法从 spring DSL 文件(Camel)加载路由并保持运行?
  • 我的基于 Spring DSL 的应用程序一旦被调用就会退出。但是,如果我将应用程序更改为使用 FILE 端点,该应用程序就可以正常工作。或者如果我将其更改为 JAVA DSL,该应用程序也可以正常工作。
  • 为了更加清晰,我的应用程序是一个独立的应用程序,使用 camel 2.10.2 创建。运行应用程序后,它说 [Camel (camel-1) thread #0 - kallada@x.x.x.x:21/… Connected and logged in to: kallada@x.x.x.x:21 并且没有初始化文件传输,将直接关闭。
  • 您可以使用camel-spring中的Main类来加载应用程序,请查看此页面camel.apache.org/…了解更多信息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-01
  • 1970-01-01
  • 2020-01-18
  • 2015-10-02
  • 2016-08-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多