简体   繁体   English

骆驼servlet监听地址

[英]Camel servlet to listen address

I have a program that listens to ftp address and whenever new file appears it takes it and converts to pojo. 我有一个监听ftp地址的程序,每当出现新文件时,它都会将其接收并转换为pojo。 But I run it from main() method. 但是我是从main()方法运行的。 It's not very comfortable. 不太舒服

I would like to create a servlet that will do the same, but i will create war file and put it into TomCat and the program will run itself, so i wouldn't have to run it. 我想创建一个将执行相同操作的servlet,但是我将创建war文件并将其放入TomCat中,并且程序将自行运行,因此我不必运行它。

I have created web.xml with camel servlet and spring listener and don't know what my further steps should be. 我已经使用骆驼servlet和spring侦听器创建了web.xml ,但是我不知道下一步是什么。

Here's what I have now: 这是我现在所拥有的:

My class: 我的课:

@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: 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>

camel-config.xml 骆驼-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: UPD:

Now i see that my program connects to ftp, but it doesn't copy files. 现在我看到我的程序连接到ftp,但是它不复制文件。

I pasted log i'm getting http://pastebin.com/2tTf6QmL 我粘贴了日志,我正在获取http://pastebin.com/2tTf6QmL

What I make from the question is that you are trying to use camel-servlet component for initializing camel routes in a web-application. 我从这个问题中得出的结论是,您正在尝试使用camel-servlet组件在Web应用程序中初始化骆驼路线。 Camel-servlet component is not meant for doing this. Camel-servlet组件并不打算这样做。 If you are using spring with camel, then configure Spring web context loader org.springframework.web.context.ContextLoaderListener and import the spring-camel xml's in spring application context file. 如果您将spring与骆驼一起使用,请配置Spring Web上下文加载器org.springframework.web.context.ContextLoaderListener并将spring-camel xml导入spring应用程序上下文文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM