0

我必须将文件 A 和 B 按顺序复制到远程文件夹。重要的是,B 仅在 A 发送之后发送,至少在同一时间发送,而不是之前发送。我已经阅读了文档,但不清楚。我的想法是将 2 条消息放入同一个频道。但我不知道链接到这两条消息的文件是否会按顺序发送。

@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>

你有什么建议吗?

4

1 回答 1

1

如果您<queue/>从频道中删除 ,它们将在您的调用线程上按顺序运行。

如果您使用队列通道;您需要一个轮询器,但只要轮询器没有task-executor,消息将在轮询器线程上按顺序发送。下一次民意调查在当前民意调查完成之前不会发生。

于 2016-12-05T14:48:08.447 回答