我试图构建一个简单的路由,从FTP文件夹读取数据,并将其存储在本地资源文件夹中。我可以连接到FTP端点,但之后什么也不会发生。
要启动我的程序,我使用:mvn clean compile camel:run
我真的不知道接下来该做什么来调试这个。
终端输出:
INFO | Apache Camel 2.20.0 (CamelContext: camel-1) is starting
INFO | JMX is enabled
INFO | Type converters loaded (core: 192, classpath: 4)
INFO | 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
INFO | Route: route1 started and consuming from: ftp://xx.xx.xx.xx/ftp/xx/xx?password=xxxxxx&username=xx
INFO | Total 1 routes, of which 1 are started
INFO | Apache Camel 2.20.0 (CamelContext: camel-1) started in 0.333 seconds
pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nettport</groupId>
<artifactId>camel_download_file_from_ftp_and_get_name_and_content</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- Camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>spi-annotations</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.20.0</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.20.0</version>
</dependency>
<!-- //Spring -->
<!-- FTP -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ftp</artifactId>
<version>2.20.0</version>
</dependency>
<!-- //FTP -->
<!-- Quartz -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz</artifactId>
<version>2.20.0</version>
</dependency>
<!-- //Quartz -->
<!-- ActiveMq -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.1</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.8.0-alpha2</version>
</dependency>
<!-- //Logging -->
</dependencies>
<build>
<plugins>
<!-- Allows the routes to be run via 'mvn camel:run' -->
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>2.20.0</version>
</plugin>
</plugins>
</build>
</project>
src/main/java/com/nettport/ReceiverRoute.java文件:
package com.nettport;
import org.apache.camel.builder.RouteBuilder;
public class ReceiverRoute extends RouteBuilder {
private String receiverFtpEndpoint;
public void configure() throws Exception {
// lets shutdown faster in case of in-flight messages stack up
getContext().getShutdownStrategy().setTimeout(10);
from(receiverFtpEndpoint)
.log("### FTP Receiver Route started and consuming ###")
.to("file:data/work_in_progress")
.log("Downloaded file ${file:name} complete.");
}
public void setReceiverFtpEndpoint(String receiverFtpEndpoint) {
this.receiverFtpEndpoint = receiverFtpEndpoint;
}
}
META-INF/spring/camel-contxt.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<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.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="receiverRoute" class="com.nettport.ReceiverRoute">
<property name="receiverFtpEndpoint" value="ftp://xx.xx.xx.xx/ftp/xx/xx?username=xx&password=xx"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="receiverRoute"/>
</camelContext>
</beans>