当前位置: 首页 > 知识库问答 >
问题:

Spring Integration-无法第二次发送同名文件

范志勇
2023-03-14

我可以将本地目录中的文件document.txt发送到远程目录,但如果我删除远程目录中的文件并再次尝试从本地发送,我就不能FTP相同的文件。poller工作得很好,因为如果我将不同的文件放在同一个文件夹中,它会拾取。我能对此有一些了解吗?

enter code here





    <!-- Inbound adapter channels for reading the local directory files in    processed folder -->
<file:inbound-channel-adapter id="inboundProcessed"
                                channel="processedChannel" 
                                filename-pattern="*.txt"
                                directory="$dina-communication.batch-{localDirectory}"
                                                                >
    <int:poller fixed-rate="10000" />
</file:inbound-channel-adapter>

<int:channel id="processedChannel"></int:channel>

        <!-- Outbound adapter channels for FTP the files in processed folder to remote directory -->    
    <int-ftp:outbound-channel-adapter id="ftpProcessed"
                                channel="processedChannel" 
                                session-factory="ftpClientFactory"
                                remote-directory="$dina-communication.batch-{remoteDirectory}"
                                >

     <int-ftp:request-handler-advice-chain>
     <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
        <property name="onSuccessExpression" value="payload.delete()" />
      </bean>
</int-ftp:request-handler-advice-chain>                     

    </int-ftp:outbound-channel-adapter>

共有1个答案

柳飞鸾
2023-03-14

默认情况下, 使用 acceptoncefilelistfilter,该filter hashcode比较传入文件的路径名:

/**
 * Computes a hash code for this abstract pathname.  Because equality of
 * abstract pathnames is inherently system-dependent, so is the computation
 * of their hash codes.  On UNIX systems, the hash code of an abstract
 * pathname is equal to the exclusive <em>or</em> of the hash code
 * of its pathname string and the decimal value
 * <code>1234321</code>.  On Microsoft Windows systems, the hash
 * code is equal to the exclusive <em>or</em> of the hash code of
 * its pathname string converted to lower case and the decimal
 * value <code>1234321</code>.  Locale is not taken into account on
 * lowercasing the pathname string.
 *
 * @return  A hash code for this abstract pathname
 */
public int hashCode() {
    return fs.hashCode(this);
}

因此,当一个新文件具有相同的名称时,它将被忽略,并且不能顺流而下。

为了克服这个问题,您应该使用FilesystemPersistentAcceptonCeFileListFilter,它使用LastModified来比较文件是否已经更新:http://docs.spring.io/spring-integration/reference/html/files.html#file-reading

 类似资料:
  • 我试图在netty中模拟http握手,但客户端无法发送第二个请求。这就是流程 这是代码https://github.com/Tonghua-Li/Netty-Handshake-Test/tree/master/src/main/java 服务器和客户端日志位于git repo的根文件夹中https://github.com/Tonghua-Li/Netty-Handshake-Test/blob

  • 本人是24届学生,去年这个时候开始学安卓,没有做过什么特别的项目,都是一些小demo。 上周四上午第一次面试,深圳的一家小厂, 被HR鸽了。 下午补面,第一次面试,过于紧张了,技术面的时候问了两分钟就挂了... 问我有什么复杂的项目,复杂在哪里。突然脑子一片空白,没说出什么,就没有下文了。 今天上午面试的是广州黄埔的一家小厂,boss上招正式工,7k-10k。我私聊hr,然后给了我实习生面试的机会

  • 请参考环境准备 自定义修改归档策略 修改open-falcon/graph/rrdtool/rrdtool.go 重新编译graph组件,并替换原有的二进制 清理掉原来的所有rrd文件(默认在/home/work/data/6070/下面) 插件机制 找一个git存放公司的所有插件 通过调用agent的/plugin/update接口拉取插件repo到本地 在portal中配置哪些机器可以执行哪些

  • 我正在使用DocuSign。Net客户端发送文档。 发送的简单场景工作正常-收件人接收发送的文档,我可以从DocuSign管理选项卡打开它们。 但是,当我试图以发件人身份代表其他电子邮件发送文档时,问题是,文档可以发送给收件人(使用正确的发件人电子邮件),但我无法在“文档管理”选项卡中打开(甚至无法看到)此文档和信函。 (在“报告”选项卡中显示,但与其他选项卡不同-它没有要打开的链接) 问:这种行

  • 我正在开发一个查看器应用程序,其中服务器捕获图像,执行一些图像处理操作,这需要在客户端显示在HTML5画布上。我写的服务器是在VC和使用http://www.codeproject.com/Articles/371188/A-Cplusplus-Websocket-server-for-realtime-interact. 到目前为止,我已经实现了所需的功能。现在我需要做的就是优化。引用是一个用来

  • 下面是我的wiremock存根映射: 因此,当客户端使用url模式=/api/myApp执行http请求时,WireMock返回成功http状态=200。 美好的很好。 但我需要当客户端使用相同的url模式执行第二个请求时,WireMock必须返回这个存根响应: 所以: 第一个要求- 第二个同样的请求- 可以用WireMock吗?