mlethys
mlethys

Reputation: 436

Downloading file using spring integration

I have some issue when I try to download file from ftp server. Everything works perfectly when I try to save downloaded file to empty folder, but when folder contains any other file my code don't even connect to server. Here's my context file:

    <bean id="ftpClientFactory"
        class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="${host}"/>
    <property name="username" value="${user}"/>
    <property name="password" value="${password}"/>
    <property name="clientMode" value="0"/>
    <property name="fileType" value="2"/>
    <property name="bufferSize" value="10000000"/>                  
</bean>
    <int:channel id="getFtpChannel">
    <int:queue/>
</int:channel>
<int-ftp:inbound-channel-adapter local-directory="ftp/" 
            channel="getFtpChannel" 
            session-factory="ftpClientFactory" 
            remote-directory="./"
            auto-create-local-directory="false"
            delete-remote-files="true"
            filename-pattern="*.exi">
    <int:poller fixed-rate="10000"/>
</int-ftp:inbound-channel-adapter>

And my java code:

public void receiveTest() {
    ConfigurableApplicationContext context = 
            new FileSystemXmlApplicationContext("/src/citrus/resources/citrus-context.xml");
    PollableChannel channel = context.getBean("getFtpChannel", PollableChannel.class);
    channel.receive(); 
    context.close();
}

Test passes and looks like everything works but it don't. Do you have some ideas what is wrong? Thanks for advance.

Upvotes: 0

Views: 1214

Answers (1)

Gary Russell
Gary Russell

Reputation: 174514

Is this in a test case?

We don't fetch from ftp if there are already local files, until those files are processed.

We had a similar question a few weeks ago, when a user's test case exited before it got to the point where we looked for remote files.

Add a sleep to the end of test to verify.

Upvotes: 1

Related Questions