2

I could able to send a file Document.txt in local directory to remote directory , but couldnt able to FTP the same file ,if i delete the file in remote and try to send from local again .Poller is working fine ,since it picks up if i put different file in same folder .Can i have some insight on this ?

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

1 Answer 1

1

The <file:inbound-channel-adapter uses AcceptOnceFileListFilter by default, which compares incoming files by their hashCode for the pathname:

/**
 * 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);
}

Therefore when a new file comes with the same name it is ignored and can't go downstream your flow.

To overcome the problem you should use FileSystemPersistentAcceptOnceFileListFilter, which uses lastModified to compare if the files has been updated: http://docs.spring.io/spring-integration/reference/html/files.html#file-reading

2
  • Sure ,i will give a try and keep posted !!
    – DinaMike
    Jul 11, 2017 at 20:25
  • I actually tried using create another FTP client factory for outbound and it solved the issue ,since there are lot of FTP'e sessions in the project , tried that approach .
    – DinaMike
    Jul 12, 2017 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.