Spring集成DSL无法在java 1.7中使用Sftp入站适配器复制文件

时间:2015-07-16 06:07:08

标签: spring-integration

在测试我的Sftp入站流后,我发现当我的本地目录为空时,远程目录中的所有文件都成功复制到我的本地目录,但如果本地目录中至少有一个文件,则没有任何文件被复制远程目录。所以任何ony一个请提供任何指针,因为我无法解决它。

这是我的Sftp入站流程....

@Bean
public IntegrationFlow sftpInboundFlow() {
    return IntegrationFlows
            .from(Sftp.inboundAdapter(this.sftpSessionFactory)
                    .preserveTimestamp(true).remoteDirectory(remDir)
                    .regexFilter(".*\\.txt$")
                    .localFilenameExpression("#this.toUpperCase()")
                    .localDirectory(new File(localDir))
                    .remoteFileSeparator("/"),
                    new Consumer<SourcePollingChannelAdapterSpec>() {
                        @Override
                        public void accept(
                                SourcePollingChannelAdapterSpec e) {
                            e.id("sftpInboundAdapter")
                                    .autoStartup(true)
                                    .poller(Pollers.fixedRate(1000)
                                            .maxMessagesPerPoll(1));
                        }
                    })
            .channel(MessageChannels.queue("sftpInboundResultChannel"))
            .get();
}

这是我的测试方法..

@Test
public void testSftpInboundFlow() {

    Message<?> message = ((PollableChannel) sftpInboundResultChannel).receive(60000);
    System.out.println("message====" + message);        
}

请找到相同的日志............

INFO: Authentication succeeded (password).
enter sftpSessionFactory.....org.springframework.integration.sftp.session.SftpSession@10cea2e
enter sftpInboundFlow.....org.springframework.integration.sftp.session.SftpSession@17ebea9
Jul 16, 2015 6:43:21 PM org.springframework.context.support.DefaultLifecycleProcessor start
INFO: Starting beans in phase -2147483648
Jul 16, 2015 6:43:21 PM org.springframework.context.support.DefaultLifecycleProcessor start
INFO: Starting beans in phase 0
Jul 16, 2015 6:43:21 PM org.springframework.integration.endpoint.EventDrivenConsumer logComponentSubscriptionEvent
INFO: Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
Jul 16, 2015 6:43:21 PM org.springframework.integration.channel.PublishSubscribeChannel adjustCounterIfNecessary
INFO: Channel 'org.springframework.context.support.GenericApplicationContext@13fb256.errorChannel' has 1 subscriber(s).
Jul 16, 2015 6:43:21 PM org.springframework.integration.endpoint.EventDrivenConsumer start
INFO: started _org.springframework.integration.errorLogger
Jul 16, 2015 6:43:21 PM org.springframework.context.support.DefaultLifecycleProcessor start
INFO: Starting beans in phase 1073741823
Jul 16, 2015 6:43:21 PM org.springframework.integration.endpoint.SourcePollingChannelAdapter start
INFO: started sftpInboundAdapter
Jul 16, 2015 6:43:21 PM org.springframework.integration.file.FileReadingMessageSource receive
INFO: Created message: [GenericMessage [payload=D:\local_copy\Test_sftp.txt, headers={timestamp=1437052401259, id=7e6054ea-9fbc-e9f0-b3e2-9c5dede1556a}]]
the channel is sftpInboundResultChannel
the sftpInboundAdapter is org.springframework.integration.dsl.sftp.SftpInboundChannelAdapterSpec@8df4ff
message====GenericMessage [payload=D:\local_copy\Test_sftp.txt, headers={timestamp=1437052401259, id=7e6054ea-9fbc-e9f0-b3e2-9c5dede1556a}]
Jul 16, 2015 6:43:21 PM org.springframework.context.support.GenericApplicationContext doClose
INFO: Closing org.springframework.context.support.GenericApplicationContext@13fb256: startup date [Thu Jul 16 18:43:10 IST 2015]; root of context hierarchy
Jul 16, 2015 6:43:21 PM org.springframework.context.support.DefaultLifecycleProcessor stop
INFO: Stopping beans in phase 1073741823
Jul 16, 2015 6:43:21 PM org.springframework.integration.endpoint.SourcePollingChannelAdapter stop
INFO: stopped sftpInboundAdapter
Jul 16, 2015 6:43:21 PM org.springframework.context.support.DefaultLifecycleProcessor stop
INFO: Stopping beans in phase 0
Jul 16, 2015 6:43:21 PM org.springframework.integration.endpoint.EventDrivenConsumer logComponentSubscriptionEvent
INFO: Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
Jul 16, 2015 6:43:21 PM org.springframework.integration.channel.PublishSubscribeChannel adjustCounterIfNecessary
INFO: Channel 'org.springframework.context.support.GenericApplicationContext@13fb256.errorChannel' has 0 subscriber(s).
Jul 16, 2015 6:43:21 PM org.springframework.integration.endpoint.EventDrivenConsumer stop
INFO: stopped _org.springframework.integration.errorLogger
Jul 16, 2015 6:43:21 PM org.springframework.context.support.DefaultLifecycleProcessor stop
INFO: Stopping beans in phase -2147483648
Jul 16, 2015 6:43:21 PM org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler shutdown
INFO: Shutting down ExecutorService 'taskScheduler'

0 个答案:

没有答案