Spring Integration - 无法第二次发送具有相同名称的文件

时间:2017-07-11 12:55:22

标签: ftp spring-integration

我能够将本地目录中的文件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 个答案:

答案 0 :(得分:0)

默认情况下,<file:inbound-channel-adapter使用AcceptOnceFileListFilter,将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);
}

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

要解决此问题,您应该使用FileSystemPersistentAcceptOnceFileListFilterlastModified使用AttributeError: 'list' object has no attribute 'StopService'来比较文件是否已更新:http://docs.spring.io/spring-integration/reference/html/files.html#file-reading