MKS
MKS

Reputation: 31

SFTP inbound channel adapter hangs at PollableChannel receive method

My context xml reads as follows:

<bean id="defaultSftpSessionFactory"
            class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
        <property name="host" value="${host}"/>
        <property name="password" value="${password}"/>
        <property name="port" value="${port}"/>
        <property name="user" value="${username}"/>
    </bean>

        <int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
            session-factory="sftpSessionFactory"
            channel="receiveChannel"
            filename-pattern="*.txt"
            remote-directory="/loblawln"
            local-directory="/local-dir"
            auto-create-local-directory="true"
            temporary-file-suffix=".writing"
            delete-remote-files="false">
        <int:poller fixed-rate="1000" max-messages-per-poll="1"/>
</int-sftp:inbound-channel-adapter>

    <int:channel id="receiveChannel">
        <int:queue/>
    </int:channel>

The java file reads like this:

PollableChannel localFileChannel = context.getBean("receiveChannel", PollableChannel.class);

        SourcePollingChannelAdapter adapter = context.getBean(SourcePollingChannelAdapter.class);
        adapter.start();
        System.out.println("Adapter started...");

        Message<?> received = localFileChannel.receive();
        System.out.println("Received first file message: " + received);

I have referred to the implementation provided by Gary Russell at Github and also followed spring docs for sftp integration. I think i am missing something important. Moreover logs are also not showing anything at all.

Upvotes: 1

Views: 497

Answers (1)

MKS
MKS

Reputation: 31

The problem got solved by changing the key to read username. This seemed a bit weird to me when I debugged the code and read values in defaultSessionFactory instance, I found it was not reading the username from the properties file, rather it read the value correspnding to System.getProperty("user.name"). When I changed the key from {username} to some thing else like {sftp.username} it read it correctly.

Upvotes: 2

Related Questions