Apache Camel 3.0.1 无法启动和消费路由器到 FTPs 文件夹

问题描述

我正在使用 Apache Camel FTP 3.0.1 和 Spring Boot 来连接和侦听 FTP 远程文件夹上的文件创建事件。它适用于我的本地 FTP 服务器(我还没有在我的本地 docker 上使用 FTP)。但是当我连接到FTPs服务器时它无法启动和消耗路由器。

这是我的代码

@Component
public class ListenerSyncDaTarouter extends RouteBuilder {

    Logger logger = LoggerFactory.getLogger(ListenerSyncDaTarouter.class);

    @Autowired
    ListenerSyncDataFileProcessor listenerSyncDataFileProcessor;

    @Override
    public void configure() throws Exception {
        from("ftps://user@ftps_server_ip:21/ReceiveDataFile/Processing?password=xxx&ftpClient.trustStore.file=keys/diode.jks&ftpClient.trustStore.password=xxx&passiveMode=true&include=.*.xml&filter=#ftpFileFilter&move=ReceiveDataFile/Temp&maxMessagesPerPoll=200&throwExceptionOnConnectFailed=true&soTimeout=3000")
                .log("${body}")
                .log(LoggingLevel.INFO,"Processing ${id}")
                .process(listenerSyncDataFileProcessor)
                .end();
    }
}

我收到异常日志:

[INFO ] 2021-01-23 19:58:31.413 [main] SpringBootRoutesCollector - Loading additional Camel XML routes from: classpath:camel/*.xml
[INFO ] 2021-01-23 19:58:31.413 [main] SpringBootRoutesCollector - Loading additional Camel XML rests from: classpath:camel-rest/*.xml
[INFO ] 2021-01-23 19:58:31.420 [main] SpringBootCamelContext - Apache Camel 3.0.1 (CamelContext: camel-1) is starting
[INFO ] 2021-01-23 19:58:31.421 [main] JmxManagementStrategy - JMX is enabled
[INFO ] 2021-01-23 19:58:31.650 [main] SpringBootCamelContext - 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

日志在 Apache Camel 3.0.1 (CamelContext: camel-1) is starting 处停止,不会为路由器启动和消耗。

这是我本地 FTP 服务器的正常日志:

用于连接本地 FTP 服务器的 FTP URI : ftp://ftpuser@localhost:21/files?filter=%23ftpFileFilter&include=.*.xml&move=files%2Ftemp&passiveMode=true&password=xxxxxx

[INFO ] 2021-01-23 19:53:45.474 [main] SpringBootRoutesCollector - Loading additional Camel XML routes from: classpath:camel/*.xml
[INFO ] 2021-01-23 19:53:45.474 [main] SpringBootRoutesCollector - Loading additional Camel XML rests from: classpath:camel-rest/*.xml
[INFO ] 2021-01-23 19:53:45.481 [main] SpringBootCamelContext - Apache Camel 3.0.1 (CamelContext: camel-1) is starting
[INFO ] 2021-01-23 19:53:45.481 [main] JmxManagementStrategy - JMX is enabled
[INFO ] 2021-01-23 19:53:45.727 [main] SpringBootCamelContext - 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 ] 2021-01-23 19:53:46.047 [main] SpringBootCamelContext - Route: route1 started and consuming from: ftp://ftpuser@localhost:21/files?filter=%23ftpFileFilter&include=.*.xml&move=files%2Ftemp&passiveMode=true&password=xxxxxx
[INFO ] 2021-01-23 19:53:46.090 [main] SpringBootCamelContext - Route: route2 started and consuming from: ftp://ftpuser@localhost:21/logs?filter=%23ftpFileFilter&include=.*.json&move=logs%2Ftemp&passiveMode=true&password=xxxxxx
[INFO ] 2021-01-23 19:53:46.093 [main] SpringBootCamelContext - Total 2 routes,of which 2 are started
[INFO ] 2021-01-23 19:53:46.094 [main] SpringBootCamelContext - Apache Camel 3.0.1 (CamelContext: camel-1) started in 0.613 seconds
[INFO ] 2021-01-23 19:53:46.099 [main] ListenerApplication - Started ListenerApplication in 3.811 seconds (JVM running for 4.866)
Directory Change Listener running...

它不会在 FTP 本地运行时获取启动和使用路由器的日志,因此它无法注册路由器并侦听 FTPs 文件夹上的文件创建事件。

我的代码有什么问题?

解决方法

我建议您调查 ReceiveDataFile 是否是 FTP 用户主目录中的目录。

Camel FTP component中所述:

不支持绝对路径。骆驼将绝对路径转换为 通过修剪目录名中的所有前导斜杠来实现相对。会有 be WARN 消息打印在日志中。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...