Apache Camel 3.0.1连通FTP服务后无法捕获远程目录文件创建事件触发消费流程
开发中基于Apache Camel 3.0.1版本的FTP组件,实现对指定FTP目录的文件消费能力。经前期校验,Camel路由可正常加载、FTP服务器的账号连接、目录权限验证均无异常,但当文件被推送至目标监听目录时,无法触发文件创建事件进入后续处理流程。曾尝试在应用主类中手动初始化Camel上下文并挂载路由,问题仍复现。
相关配置与运行记录
Maven依赖配置
项目中引入的Camel相关组件依赖,核心版本统一为3.0.1,仅JacksonXML数据格式模块为3.0.0版本,具体组件如下:
camel-spring-boot-startercamel-core-startercamel-ftp-startercamel-jacksonxml-startercamel-jackson-startercamel-rabbitmq-starter
路由定义代码
package xx.listener.route; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.jackson.JacksonDataFormat; import org.springframework.stereotype.Component; import xx.listener.common.model.ddXMLModel; @Component public class DataRouter extends RouteBuilder { @Override public void configure() throws Exception { System.out.println("Initialize camel route..."); JacksonDataFormat jacksonDataFormat = new JacksonDataFormat(); jacksonDataFormat.setInclude("NON_NULL"); jacksonDataFormat.setPrettyPrint(true); from("ftp://user@localhost:21/ftp/files?password=abc@123&move=.done&moveFailed=.error") .log("${body}") .unmarshal().jacksonxml(ddXMLModel.class) .marshal(jacksonDataFormat) .log("${body}") .to("rabbitmq://localhost:5672/test_camel?username=root&password=123456&queue=camel.queue&autoDelete=false") .end(); } }
启动阶段日志
应用启动过程中无核心报错,关键日志片段如下:
Initialize camel route...
SpringBootCamelContext - Apache Camel 3.0.1 (CamelContext: camel-1) is starting
JmxManagementStrategy - JMX is enabled
RabbitMQComponent - The old syntax rabbitmq://hostname:port/exchangeName is deprecated. You should configure the hostname on the component or ConnectionFactory
JacksonDataFormat - The option autoDiscoverObjectMapper is set to false, Camel won't search in the registry
SpringBootCamelContext - Route: route1 started and consuming from: ftp://user@localhost:21/ftp/files?move=.done&moveFailed=.error&password=xxxxxx
SpringBootCamelContext - Total 1 routes, of which 1 are started
SpringBootCamelContext - Apache Camel 3.0.1 (CamelContext: camel-1) started in 0.372 seconds
ListenerApplication - Started ListenerApplication in 2.979 seconds (JVM running for 4.169)
实际运行异常表现
通过FTP客户端登录目标服务器,进入/ftp/files监听目录上传测试XML文件后,应用控制台无任何对应处理日志,路由完全未被触发,后续XML解析、JSON转换、RabbitMQ消息投递的全流程均未执行。
内容的提问来源于stack exchange,提问作者AcidBurn

