Ftp 入站通道适配器本地目录&;消息

Ftp 入站通道适配器本地目录&;消息,ftp,spring-integration,adaptor,Ftp,Spring Integration,Adaptor,我们有一个web应用程序,希望使用ftp:inbound channel adapter从ftp读取文件并创建消息并将其发送到频道 当local directory设置为local directory=“#servletContext.getRealPath(“”)}/temp/inFtp”时,它给出 生成的消息是 GenericMessage[payload={applicationDeployPath}\temp\inFtp\xyz.stagging.dat,headers={timesta

我们有一个web应用程序,希望使用ftp:inbound channel adapter从ftp读取文件并创建消息并将其发送到频道

  • local directory设置为local directory=“#servletContext.getRealPath(“”)}/temp/inFtp”时,它给出 生成的消息是 GenericMessage[payload={applicationDeployPath}\temp\inFtp\xyz.stagging.dat,headers={timestamp=1444812027516,id=9b5f1581-bfd2-6690-d4ea-e7398e8ecbd6}]
  • 但目录没有创建,我检查了我在这里有完全权限。 路径[{applicationDeployPath}\temp\inFtp]不表示可正确访问的目录。

  • 在消息中,我想根据环境从属性文件中发送更多的字段作为有效负载,该如何做

    <int-ftp:inbound-channel-adapter id="ftpInboundAdaptor"
        channel="ftpInboundChannel"
        session-factory="ftpClientFactory"
        filename-pattern="*.stagging.dat"
        delete-remote-files="false"
        remote-directory="/stagging/"
        local-directory="#servletContext.getRealPath('')}/temp/inFtp"
        auto-create-local-directory="true">
        <int:poller  fixed-rate="1000"/>
    </int-ftp:inbound-channel-adapter>
    
    
    

  • 提前感谢

    在初始化时,
    本地目录
    仅评估一次(必要时创建),而不是针对每条消息

    我很惊讶上下文甚至会初始化;此语法看起来很糟糕:

    local-directory="#servletContext.getRealPath('')}/temp/inFtp"
    
    如果你是说

    local-directory="#{servletContext.getRealPath('')}/temp/inFtp"
    
    只有当您有一个名为
    servletContext
    的bean时,它才会工作

    如果你是说

    local-directory="#servletContext.getRealPath('')/temp/inFtp"
    
    在求值上下文中需要一个变量
    servletContext

    它给出生成的消息是GenericMessage[payload={applicationDeployPath}\temp\inFtp\xyz.stagging.dat,headers={timestamp=1444812027516,id=9b5f1581-bfd2-6690-d4ea-e7398e8ecbd6}]

    如果它真的在生成那个消息,那么它一定已经创建了那个目录

    不清楚你说的是什么意思

    我想发送更多字段作为有效负载

    有效负载是一个
    文件


    如果要将有效负载更改为包含文件和其他字段的其他内容,请使用转换器。

    感谢Gary在消息有效负载中添加额外信息,我将使用转换器。写问题时是打字错误。真正的配置是
    localdirectory=“#{servletContext.getRealPath(“”)}/temp/inFtp”
    ,如您所述。文件夹正在创建,文件正在按预期进行复制,但由于它是共享临时空间,因此被另一个进程清除。