使用骆驼FTP从多个位置拾取文件

发布于 2025-02-03 01:18:35 字数 1008 浏览 2 评论 0原文

我需要使用骆驼FTP从两个不同位置拾取文件。

当前,我的代码是

尝试{

        from(format("sftp://%s@%s:22/../../..%s?password=%s&delete=true", ftpUserName, ftpServer, responsePath, ftpPassword ))
                .filter(header("CamelFileName").endsWith(".PDF"))
                .to(format("sftp://%s@%s:22/../../..%s/processed?password=%s", ftpUserName, ftpServer, responsePath, ftpPassword))
                .process(documentProcessor)
               /*.log(LoggingLevel.INFO, (org.slf4j.Logger) logger, "Download file ${file:name} complete.")*/
                /*.to(downloadLocation)*/;
        /*.to(format("smtp://relay.us.signintra.com?to=%s&[email protected]&subject=GTM response from cisco", emailTo))*/
        ;
    } catch (Exception e) {
        e.printStackTrace();
    }

这是在application.properties文件中提到的文件。我该怎么做才能从多级位置拼凑文件。

i have a situation i need to pick up files from two different location using camel FTP.

currently my code is

try {

        from(format("sftp://%s@%s:22/../../..%s?password=%s&delete=true", ftpUserName, ftpServer, responsePath, ftpPassword ))
                .filter(header("CamelFileName").endsWith(".PDF"))
                .to(format("sftp://%s@%s:22/../../..%s/processed?password=%s", ftpUserName, ftpServer, responsePath, ftpPassword))
                .process(documentProcessor)
               /*.log(LoggingLevel.INFO, (org.slf4j.Logger) logger, "Download file ${file:name} complete.")*/
                /*.to(downloadLocation)*/;
        /*.to(format("smtp://relay.us.signintra.com?to=%s&[email protected]&subject=GTM response from cisco", emailTo))*/
        ;
    } catch (Exception e) {
        e.printStackTrace();
    }

This is picking up the file that is mentioned in the application.properties files. How can i do this to puck up files from multile locations.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洒一地阳光 2025-02-10 01:18:35

您可以配置多个FTP消费者路由,并将消息转发到共享的直接点。

示例:

from("ftp:{{target.host}}:{{ftp.port}}/{{target.path1}}...")
    .routeId("PollForFilesInPath1")
    .to("direct:handleFileFromFTP");

from("ftp:{{target.host}}:{{ftp.port}}/{{target.path2}}...")
    .routeId("PollForFilesInPath2")
    .to("direct:handleFileFromFTP");

from("direct:handleFileFromFTP")
    .routeId("handleFileFromFTP")
    .log("file received from ftp: ${headers.CamelFileName }")
    // Do stuff with the file

如果您需要从单一路线中调用2 FTP消费者终点“ rel =“ nofollow noreferrer”> poll-enrich 。

You can configure multiple FTP consumer routes and forward the message to shared direct-endpoint.

Example:

from("ftp:{{target.host}}:{{ftp.port}}/{{target.path1}}...")
    .routeId("PollForFilesInPath1")
    .to("direct:handleFileFromFTP");

from("ftp:{{target.host}}:{{ftp.port}}/{{target.path2}}...")
    .routeId("PollForFilesInPath2")
    .to("direct:handleFileFromFTP");

from("direct:handleFileFromFTP")
    .routeId("handleFileFromFTP")
    .log("file received from ftp: ${headers.CamelFileName }")
    // Do stuff with the file

If you need to call 2 FTP consumer endpoints from single route you can use poll-enrich.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文