[英]Camel servlet to listen address
我有一个监听ftp地址的程序,每当出现新文件时,它都会将其接收并转换为pojo。 但是我是从main()
方法运行的。 不太舒服
我想创建一个将执行相同操作的servlet,但是我将创建war
文件并将其放入TomCat中,并且程序将自行运行,因此我不必运行它。
我已经使用骆驼servlet和spring侦听器创建了web.xml
,但是我不知道下一步是什么。
这是我现在所拥有的:
我的课:
@Component
public class test extends SpringRouteBuilder {
@Override
public void configure() throws Exception {
from("ftp://Mike@localhost?noop=true&binary=true").to("file://data");
}
}
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:camel-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
骆驼-config.xml中
<context:component-scan base-package="org.apache.camel.spring.issues.contextscan"/>
<camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myBuilder" />
</camelContext>
<bean id="myBuilder" class="test"/>
UPD:
现在我看到我的程序连接到ftp,但是它不复制文件。
我粘贴了日志,我正在获取http://pastebin.com/2tTf6QmL
我从这个问题中得出的结论是,您正在尝试使用camel-servlet组件在Web应用程序中初始化骆驼路线。 Camel-servlet组件并不打算这样做。 如果您将spring与骆驼一起使用,请配置Spring Web上下文加载器org.springframework.web.context.ContextLoaderListener
并将spring-camel xml导入spring应用程序上下文文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.