【问题标题】:transfer files from sftp server to another sftp server with mule flow使用 mule 流将文件从 sftp 服务器传输到另一个 sftp 服务器
【发布时间】:2014-08-28 07:49:17
【问题描述】:
<flow name="test1" doc:name="test1">
    <sftp:inbound-endpoint host="${source.server.host}"
        port="${source.server.port}" path="${source.server.customer.path}" user="${source.server.user}"
        password="${source.server.password}" responseTimeout="10000"
        pollingFrequency="${source.server.pollfrequency}" doc:name="source SFTP server" connector-ref="SFTPone"/>
    <sftp:outbound-endpoint exchange-pattern="one-way"
        outputPattern="#[message.inboundProperties['originalFilename']]"
        host="${target.server.host}" port="${target.server.port}" path="${target.server.customer.path}"
        user="${target.server.user}" password="${target.server.password}"
        responseTimeout="10000" doc:name="Intermediate Host" connector-ref="TARGETSFTPone"/>
</flow>
<flow name="test2" doc:name="test2">
    <sftp:inbound-endpoint host="${source.server.host}"
        port="${source.server.port}" path="${source.server.wells.path}" user="${source.server.user}"
        password="${source.server.password}" responseTimeout="10000"
        pollingFrequency="${source.server.pollfrequency}" doc:name="source SFTP server" connector-ref="SFTPtwo"/>
    <sftp:outbound-endpoint exchange-pattern="one-way"
        outputPattern="#[message.inboundProperties['originalFilename']]"
        host="${target.server.host}" port="${target.server.port}" path="${target.server.wells.path}"
        user="${target.server.user}" password="${target.server.password}"
        responseTimeout="10000" doc:name="Intermediate Host" connector-ref="TARGETSFTPtwo"/>
</flow>

我想从多个路径的sftp服务器传输文件,我在一个项目中配置了十个这样的流程,它们将访问一个SFTP服务器上的不同路径以将文件同时传输到另一个SFTP服务器的不同路径。但是当我运行这个项目时,它返回 "SSH_MSG_DISCONNECT: 2 Too many users for this IP" ,我该如何解决这个问题,或者有更好的方法来满足这个要求。 有什么建议吗?谢谢

【问题讨论】:

    标签: mule sftp


    【解决方案1】:

    您可以结合使用 foreach + 动态端点来执行此操作,但缺点是您需要在入站端点之后禁用 SFTP 连接器中的流式传输(或使用对象到流式转换器),即:看起来像

    <sftp:inbound endpoint>
    <object-to-byte-array />
    <set-variable variableName="fileContents" value="#[payload]" />
    <foreach value="#[expressionToTheListOfSites]">
        <set-variable variableName="site" value="#[payload]" />
        <set-payload value="#[fileContents]" />
        <sftp:outbound-endpoint address="sftp://#[site]" />
    </foreach>
    

    你可能需要修正语法,但逻辑就是那个。

    【讨论】:

    • 谢谢你的回答,胡安。根据您的流程配置,流程可以将sftpA的PATH(A)上的文件传输到sftpB的PATH(A),PATH(B),PATH(C)......对吗?但我的要求是这样的:将 sftpA 的 PATH(A) 上的文件传输到 sftpB 的 PATH(A),将 sftpA 的 PATH(B) 上的文件传输到 sftpB 的 PATH(B),将 sftpA 的 PATH(C) 上的文件传输到 sftpB 的 PATH( C)...同时。有什么建议吗??非常感谢!
    【解决方案2】:
    Inbound:
    
    EndpointBuilder endpointBuilder = eventContext
                    .getMuleContext()
                    .getEndpointFactory()
                    .getEndpointBuilder(
                            "sftp"+"://" + userName+ ":"
                                    + password+ "@"
                                    + host+ ":"+port
                                    + path+"?connector=SFTPIN");
    
     InboundEndpoint inboundEndPoint = endpointBuilder.buildInboundEndpoint();
    
        endpointBuilder.addMessageProcessor(new MessageFilter(new WildcardFilter("sample*")));
    
        endpointBuilder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
    
        MuleMessage message= inboundEndPoint.request(1000000L);
    
    outbound:
    
    //To send file to destination 
        EndpointBuilder outboundEndpointBuilder = eventContext
                .getMuleContext()
                .getEndpointFactory()
                .getEndpointBuilder(
                        "sftp"+"://" + userName+ ":"
                                + password+ "@"
                                + host+ ":"+port
                                + path+"?connector=SFTPOUT");
    
        OutboundEndpoint outboundPoint=outboundEndpointBuilder.buildOutboundEndpoint();
    
        SftpConnector sftpConnector=(SftpConnector) outboundPoint.getConnector();
    
        sftpConnector.setOutputPattern("sample1.txt");
        eventContext.getMuleContext().getClient().process(outboundPoint, msg);
    

    【讨论】:

    • 您可以根据需要更改用户名和主机名并显式调用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-29
    • 1970-01-01
    • 2021-12-25
    • 2016-01-28
    • 2021-12-31
    • 1970-01-01
    • 2018-07-11
    相关资源
    最近更新 更多