首页 > 解决方案 > 使用 apache camel 从 http 位置下载

问题描述

我需要使用 apache camel 从 http 位置将文件下载到本地系统。当我给出以下代码时

    from("http://url/filename.xml")                         
    .to("file://C:location")  

它适用于 ftp,但当 url 为“http”时不起作用。也就是说,它不会将文件从 http 位置下载到“to()”中提供的本地地址。

标签: apacheapache-camelapache-httpclient-4.x

解决方案


http 组件不能用作消费者,即。你不能有一个路由 from("http://...")

您需要使用将启动路由的消费者组件。你可以试试这样的

from("timer:foo?fixedRate=true&period=5000")
.to("http://url/filename.xml")                         
.to("file://C:location") 

推荐阅读