2017-10-09 122 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);