2017-10-09 119 views
0

我想通过REST调用使用骆驼的路线从FTP下载文件集: 我想以下几点: from("cxfrs:bean:restndpoint") .pollEnrich("some ftp url") .to("destinationFilesLocation") .bean(MyBean.class);
它仅适用于一个文件在ftp上,当我试图运行它再一次它只是等待文件。如果我用(“某些ftp url”替换pollEnrich(“某个ftp url”)机智),骆驼不会等待休息时间,随时调用下载文件。下载集从FTP与骆驼的文件通过REST调用

回答

0

这就是pollEnrich EIP模式的工作原理。它轮询单个消息。

您的用例通过REST调用下载一组FTP文件听起来更像是您应该使用Control Bus EIP模式,其中REST调用将触发启动另一个执行FTP下载的路由。

请参见:http://camel.apache.org/controlbus.html

+0

谢谢您的回答。这听起来正是我需要的。你能指点一下路线应该是什么样子的例子吗? –

0

像这样的事情对我的作品:

from("cxfrs:bean:restndpoint") 
      .to("controlbus:route?action=start&routeId=ftpRouteId&async=true"); 

    from("some ftp url").routeId("ftpRouteId").noAutoStartup() 
      .choice() 
      .when(body().isNull()) 
       .to("direct:extract") 
      .otherwise() 
       .to("destinationFilesLocation"); 

    from("direct:extract") 
      .to("controlbus:route?action=stop&routeId=ftpRouteId&async=true") 
      .bean(MyBean.class);