【问题标题】:cannot download file from sftp in apache camel and no failure logs printed无法从 apache camel 中的 sftp 下载文件,也没有打印失败日志
【发布时间】:2018-12-06 08:40:56
【问题描述】:

我正在尝试使用 sftp 连接到 ftp 服务器,但似乎无法连接。 连接或凭据没有错误

骆驼上下文.xml

    <route>
<from id="_from1" uri="sftp://user@localhost:22/data/test/user?noop=true&amp;password=XXXXXX"/>
     <log id="_log1" message="downloading ${file:name}"/>
     <to id="_to1" uri="file:ftpclient"/>
</route>

我已经添加了依赖:

 <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-ftp</artifactId>
      </dependency>

日志如下:

[                      Thread-4] RawBuilder                     INFO  Copy thread finished.
[mel.test.blueprint.Main.main()] Activator                      INFO  Camel activator starting
[mel.test.blueprint.Main.main()] Activator                      INFO  Camel activator started
[         Blueprint Extender: 1] BlueprintContainerImpl         INFO  Bundle sftp_connect/1.0.0.SNAPSHOT is waiting for namespace handlers [http://camel.apache.org/schema/blueprint]
[ Blueprint Event Dispatcher: 1] BlueprintCamelContext          INFO  Attempting to start CamelContext: _context1
[ Blueprint Event Dispatcher: 1] BlueprintCamelContext          INFO  Apache Camel 2.21.0.fuse-710018-redhat-00001 (CamelContext: _context1) is starting
[ Blueprint Event Dispatcher: 1] BlueprintCamelContext          INFO  StreamCaching is enabled on CamelContext: _context1
[ Blueprint Event Dispatcher: 1] ManagedManagementStrategy      INFO  JMX is enabled
[ Blueprint Event Dispatcher: 1] DefaultManagementAgent         INFO  ManagementAgent detected JVM system properties: {org.apache.camel.jmx.createRmiConnector=true}
[KTOP-980NI68:1099/jmxrmi/camel] DefaultManagementAgent         INFO  JMX Connector thread started and listening at: service:jmx:rmi:///jndi/rmi://DESKTOP-980NI68:1099/jmxrmi/camel
[ Blueprint Event Dispatcher: 1] DefaultStreamCachingStrategy   INFO  StreamCaching in use with spool directory: C:\Users\Lenovo\AppData\Local\Temp\camel\camel-tmp-81aa83b2-0e29-4496-a4b9-17a9ff951952 and rules: [Spool > 128K body size]
[ Blueprint Event Dispatcher: 1] SftpEndpoint                   INFO  Endpoint is configured with noop=true so forcing endpoint to be idempotent as well
[ Blueprint Event Dispatcher: 1] SftpEndpoint                   INFO  Using default memory based idempotent repository with cache max size: 1000
[ Blueprint Event Dispatcher: 1] SftpOperations                 INFO  Known host file not configured, using user known host file: C:\Users\Lenovo/.ssh/known_hosts
[ Blueprint Event Dispatcher: 1] BlueprintCamelContext          INFO  Route: _route1 started and consuming from: sftp://user@localhost:/data/test/user?&noop=true&password=xxxxxx
[ Blueprint Event Dispatcher: 1] BlueprintCamelContext          INFO  Total 1 routes, of which 1 are started
[ Blueprint Event Dispatcher: 1] BlueprintCamelContext          INFO  Apache Camel 2.21.0.fuse-710018-redhat-00001 (CamelContext: _context1) started in 1.320 seconds

任何帮助将不胜感激。

编辑:

当我将 JSCH 日志级别设置为它提供的信息时:

[ Blueprint Event Dispatcher: 1] SftpOperations                 INFO  JSCH -> Connection established

【问题讨论】:

  • 那么 /data/test/user 中有文件吗?他们没有消费,对吧?
  • 路径中有文件,只是不消耗
  • 日志显示一切正常,这很奇怪。该路线是否有可能已经消耗了文件?因为您使用 noop=true 导致使用内存中的幂等存储库阻止消费已经使用的文件。
  • 我已经在我的路线中输入了日志,如果使用它应该会显示在日志中,对吗?
  • 您是否创建了 sftp 用户并正确提供了主目录? uri 中的路径在技术上是 sftp 用户主目录的相对路径。

标签: maven apache-camel sftp jbossfuse blueprint-osgi


【解决方案1】:

SFTP camel 采用相对于主/用户文件夹的路径,而不是绝对路径。搜索此路径“data/test/user”是否存在于 home/user 文件夹中的某个位置,这将是它从中挑选文件的位置。您始终可以在运行代码时启用调试日志记录,以便更好地了解正在发生的事情。 https://camel.apache.org/manual/latest/faq/how-do-i-enable-debug-logging.html

【讨论】:

  • 请解释您的答案,以便下一位用户知道为什么此解决方案对您有效。另外,总结一下您的答案,以防链接将来停止工作。
猜你喜欢
  • 2018-06-25
  • 1970-01-01
  • 2018-01-04
  • 1970-01-01
  • 2020-09-04
  • 2015-09-08
  • 1970-01-01
  • 2017-02-11
  • 2019-12-22
相关资源
最近更新 更多