2016-12-05 36 views
0

我必須將文件A和B順序複製到遠程文件夾。只有在A被髮送之後才發送B是重要的,至少在同一時間,而不是在之前。 我已閱讀文檔,但尚不清楚。我的想法是將2條消息放入同一個頻道。但我不知道鏈接到這兩條消息的文件是否會按順序發送。如何通過SFTP順序複製文件(彈簧集成)?

@Component 
public class JobExportExecutionsRouter { 
    ... 
    @Autowired 
    private MessageChannel sftpIncrExportChannel; 
    ... 
    @Router 
    public List<String> routeJobExecution(JobExecution jobExecution) { 
    final List<String> routeToChannels = new ArrayList<String>(); 
    ... 
    sftpIncrExportChannel.send(MessageBuilder.withPayload(fileA).build()); 
    sftpIncrExportChannel.send(MessageBuilder.withPayload(fileB).build()); 
    routeToChannels.add("sftpIncrExportChannel"); 
    return routeToChannels; 
    } 
} 

我的XML配置包含:

<int:channel id="sftpIncrExportChannel"> 
    <int:queue/> 
</int:channel> 
... 
<int-sftp:outbound-channel-adapter session-factory="sftpSessionFactory" channel="sftpIncrExportChannel" charset="UTF8" remote-directory="${export.incr.sftp.dir}" /> 
... 
<bean id="sftpSessionFactory" 
    class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory"> 
    <property name="host" value="${export.incr.sftp.dir}"/> 
    <property name="user" value="${export.incr.sftp.user}"/> 
    <property name="password" value="${export.incr.sftp.password}"/> 
</bean> 

你有什麼建議?

回答

1

如果您從通道中刪除<queue/>,它們將在您的調用線程上按順序運行。

如果您使用隊列通道;你需要一個輪詢器,但是,只要輪詢器沒有task-executor,消息就會在輪詢器線程上按順序發送。下一個民意調查不會發生,直到目前的民意調查完成。

+0

好。我會試試這個。謝謝 – salidou