0

我们有 Web 应用程序并希望使用 ftp:inbound-channel-adapter 从 ftp 读取文件并创建消息并将其发送到通道

  1. local-directory设置为 local-directory="#servletContext.getRealPath('')}/temp/inFtp" 时,生成的消息是 GenericMessage [payload={applicationDeployPath}\temp\inFtp\xyz.stagging.dat, headers ={时间戳=1444812027516, id=9b5f1581-bfd2-6690-d4ea-e7398e8ecbd6}]

但是没有创建目录,我检查了我在这里有完全权限。路径 [{applicationDeployPath}\temp\inFtp]不表示可正确访问的目录。

  1. 在消息中,我想根据环境发送更多字段作为具有来自属性文件的值的有效负载,我该怎么做?

    <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>
    

提前致谢

4

1 回答 1

0

仅在local-directory初始化时评估一次(并在必要时创建),而不是针对每条消息。

我对上下文甚至初始化感到惊讶;这种语法看起来很糟糕:

local-directory="#servletContext.getRealPath('')}/temp/inFtp"

如果你的意思是

local-directory="#{servletContext.getRealPath('')}/temp/inFtp"

只有当你有一些名为 bean 时它才会起作用servletContext

如果你的意思是

local-directory="#servletContext.getRealPath('')/temp/inFtp"

您需要servletContext在评估上下文中使用一个变量。

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

如果它实际上正在生成该消息,则它必须创建该目录。

不清楚你的意思是什么

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

有效载荷是一个File.

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

于 2015-10-14T14:51:37.767 回答