带有 Camel Ftp 组件的损坏文件
Corrupted files with Camel Ftp component
我正在使用 apache camel 制作一个 ftp 客户端,用于将一些文件下载到某个本地目录。该程序读取 xml 文件以获取将从 ftp.The 程序中获取的文件的名称,除了下载的文件已损坏外,该程序似乎可以正常工作。现在我正在尝试下载一些图像文件,但我得到的是 14.9Kb 并且已损坏,没有显示错误消息。
这是我的代码:
主要
public void main() throws FileNotFoundException {
BasicConfigurator.configure();
RutaFtp routeBuilder = new RutaFtp();
CamelContext ctx = new DefaultCamelContext();
try {
ctx.addRoutes(routeBuilder);
ctx.start();
Thread.sleep(10000);
ctx.stop();
}
catch (Exception e) {
e.printStackTrace();
}
}
骆驼路线:
from("file:./?fileName=Datos.xml&noop=true")
.split(xpath("//Datos/imagen/text()"))
.setProperty("rutaArchivo", this.body())
.log(LoggingLevel.INFO, "imagen: ${body}")
.process(ExtraerNombre).to("direct:ftp").end();
from("direct:ftp")
.pollEnrich("ftp://"+user+"@"+ftp+"/?password="+password+"&recursive=true&passiveMode=true&fileName=${body}&delete="+borrado+"")
.to("file:C:/outputFolder?flatten=true").end();
}
我试过使用 streamDownload 参数但是阻止了文件的下载(我不知道为什么)
.pollEnrich("ftp://"+user+"@"+ftp+"/?password="+password+"&recursive=true&passiveMode=true&streamDownload=true&fileName=${body}&delete="+borrado+"")
控制台日志:
INFO | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is
starting 0 [main] INFO org.apache.camel.impl.DefaultCamelContext -
Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is starting
INFO | JMX is enabled 10 [main] INFO
org.apache.camel.management.ManagedManagementStrategy - JMX is
enabled INFO | Loaded 185 type converters 208 [main] INFO
org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 185
type converters INFO | AllowUseOriginalMessage is enabled. If access
to the original message is not needed, then its recommended to turn
this option off as it may improve performance. 395 [main] INFO
org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage
is enabled. If access to the original message is not needed, then its
recommended to turn this option off as it may improve performance.
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 395 [main] INFO
org.apache.camel.impl.DefaultCamelContext - 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
| Endpoint is configured with noop=true so forcing endpoint to be
idempotent as well 395 [main] INFO
org.apache.camel.component.file.FileEndpoint - Endpoint is configured
with noop=true so forcing endpoint to be idempotent as well INFO |
Using default memory based idempotent repository with cache max size:
1000 395 [main] INFO org.apache.camel.component.file.FileEndpoint -
Using default memory based idempotent repository with cache max size:
1000 INFO | Route: route1 started and consuming from:
Endpoint[file://./?fileName=Datos.xml&noop=true] 502 [main] INFO
org.apache.camel.impl.DefaultCamelContext - Route: route1 started and
consuming from: Endpoint[file://./?fileName=Datos.xml&noop=true] INFO
| Route: route2 started and consuming from: Endpoint[direct://ftp] 504
[main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route2
started and consuming from: Endpoint[direct://ftp] INFO | Total 2
routes, of which 2 is started. 504 [main] INFO
org.apache.camel.impl.DefaultCamelContext - Total 2 routes, of which
2 is started. INFO | Apache Camel 2.15.1.redhat-621084 (CamelContext:
camel-1) started in 0.504 seconds 507 [main] INFO
org.apache.camel.impl.DefaultCamelContext - Apache Camel
2.15.1.redhat-621084 (CamelContext: camel-1) started in 0.504 seconds INFO | Created default XPathFactory
com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533
[Camel (camel-1) thread #0 - file://./] INFO
org.apache.camel.builder.xml.XPathBuilder - Created default
XPathFactory
com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO
| imagen: ftp://190.0.56.190:8021/pruebasumman/conductor/71708375.jpg
1635 [Camel (camel-1) thread #0 - file://./] INFO route1 - imagen:
ftp://190.0.56.190:8021/pruebasumman/conductor/71708375.jpg INFO |
Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is shutting
down 10521 [main] INFO org.apache.camel.impl.DefaultCamelContext -
Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is shutting
down INFO | Starting to graceful shutdown 2 routes (timeout 300
seconds) 10524 [main] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful
shutdown 2 routes (timeout 300 seconds) INFO | Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 300
seconds. 10524 [Camel (camel-1) thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 300
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 299 seconds. 11525 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 299
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 298 seconds. 12528 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 298
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 297 seconds. 13529 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 297
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 296 seconds. 14540 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 296
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 295 seconds. 15555 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 295
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 294 seconds. 16568 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 294
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 293 seconds. 17569 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 293
seconds. INFO | Waiting as there are still 3 inflight and pending
exchanges to complete, timeout in 292 seconds. 18574 [Camel (camel-1)
thread #2 - ShutdownTask] INFO
org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are
still 3 inflight and pending exchanges to complete, timeout in 292
seconds.
提前致谢。
Download image file in binary mode
默认情况下,Camel FTP 通过 ASCII 模式下载文件。
将 binary=true
添加到您的 ftp 路由中将从 ASCII 模式变为二进制模式
我正在使用 apache camel 制作一个 ftp 客户端,用于将一些文件下载到某个本地目录。该程序读取 xml 文件以获取将从 ftp.The 程序中获取的文件的名称,除了下载的文件已损坏外,该程序似乎可以正常工作。现在我正在尝试下载一些图像文件,但我得到的是 14.9Kb 并且已损坏,没有显示错误消息。
这是我的代码:
主要
public void main() throws FileNotFoundException {
BasicConfigurator.configure();
RutaFtp routeBuilder = new RutaFtp();
CamelContext ctx = new DefaultCamelContext();
try {
ctx.addRoutes(routeBuilder);
ctx.start();
Thread.sleep(10000);
ctx.stop();
}
catch (Exception e) {
e.printStackTrace();
}
}
骆驼路线:
from("file:./?fileName=Datos.xml&noop=true")
.split(xpath("//Datos/imagen/text()"))
.setProperty("rutaArchivo", this.body())
.log(LoggingLevel.INFO, "imagen: ${body}")
.process(ExtraerNombre).to("direct:ftp").end();
from("direct:ftp")
.pollEnrich("ftp://"+user+"@"+ftp+"/?password="+password+"&recursive=true&passiveMode=true&fileName=${body}&delete="+borrado+"")
.to("file:C:/outputFolder?flatten=true").end();
}
我试过使用 streamDownload 参数但是阻止了文件的下载(我不知道为什么)
.pollEnrich("ftp://"+user+"@"+ftp+"/?password="+password+"&recursive=true&passiveMode=true&streamDownload=true&fileName=${body}&delete="+borrado+"")
控制台日志:
INFO | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is starting 0 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is starting INFO | JMX is enabled 10 [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX is enabled INFO | Loaded 185 type converters 208 [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 185 type converters INFO | AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. 395 [main] INFO org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. 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 395 [main] INFO org.apache.camel.impl.DefaultCamelContext - 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 | Endpoint is configured with noop=true so forcing endpoint to be idempotent as well 395 [main] INFO org.apache.camel.component.file.FileEndpoint - Endpoint is configured with noop=true so forcing endpoint to be idempotent as well INFO | Using default memory based idempotent repository with cache max size: 1000 395 [main] INFO org.apache.camel.component.file.FileEndpoint - Using default memory based idempotent repository with cache max size: 1000 INFO | Route: route1 started and consuming from: Endpoint[file://./?fileName=Datos.xml&noop=true] 502 [main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route1 started and consuming from: Endpoint[file://./?fileName=Datos.xml&noop=true] INFO | Route: route2 started and consuming from: Endpoint[direct://ftp] 504 [main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route2 started and consuming from: Endpoint[direct://ftp] INFO | Total 2 routes, of which 2 is started. 504 [main] INFO org.apache.camel.impl.DefaultCamelContext - Total 2 routes, of which 2 is started. INFO | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) started in 0.504 seconds 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) started in 0.504 seconds INFO | Created default XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) thread #0 - file://./] INFO org.apache.camel.builder.xml.XPathBuilder - Created default XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | imagen: ftp://190.0.56.190:8021/pruebasumman/conductor/71708375.jpg 1635 [Camel (camel-1) thread #0 - file://./] INFO route1 - imagen: ftp://190.0.56.190:8021/pruebasumman/conductor/71708375.jpg INFO | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is shutting down 10521 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) is shutting down INFO | Starting to graceful shutdown 2 routes (timeout 300 seconds) 10524 [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 2 routes (timeout 300 seconds) INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 300 seconds. 10524 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 300 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 299 seconds. 11525 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 299 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 298 seconds. 12528 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 298 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 297 seconds. 13529 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 297 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 296 seconds. 14540 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 296 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 295 seconds. 15555 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 295 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 294 seconds. 16568 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 294 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 293 seconds. 17569 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 293 seconds. INFO | Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 292 seconds. 18574 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Waiting as there are still 3 inflight and pending exchanges to complete, timeout in 292 seconds.
提前致谢。
Download image file in binary mode
默认情况下,Camel FTP 通过 ASCII 模式下载文件。
将 binary=true
添加到您的 ftp 路由中将从 ASCII 模式变为二进制模式