Spring integration 迭代器的释放策略
当我在迭代器中使用split()时,有没有办法使用或模拟ReleaseStrategySpring integration 迭代器的释放策略,spring-integration,Spring Integration,当我在迭代器中使用split()时,有没有办法使用或模拟ReleaseStrategy @Bean IntegrationFlow flow(CourseRepository courseRepository, EnrollmentRepository enrollmentRepository) { return IntegrationFlows.from(courseRepository, "findAllWithEnrollmentToProcess", c -> c .pol
@Bean
IntegrationFlow flow(CourseRepository courseRepository, EnrollmentRepository enrollmentRepository) {
return IntegrationFlows.from(courseRepository, "findAllWithEnrollmentToProcess", c -> c
.poller(Pollers.fixedDelay(this.executionIntervalInSeconds, SECONDS)))
.split()
.transform(Course::getId)
.transform(enrollmentRepository::findUnprocessedEnrollments)
.split()
.handle(...)
// do something when split ends
.get();
}
findAllWithEnrollmentToProcess和FindUnprocessedRollments两种方法都返回迭代器。只有使用
.aggregate()
才能实现这一点。你的情况是两次
我们在XML配置中有一个类似的示例:
<splitter id="upstream-splitter" input-channel="splitter" output-channel="upstream-splits" />
<splitter id="downstream-splitter" input-channel="upstream-splits" output-channel="downstream-splits" />
<aggregator id="first-aggregator" input-channel="downstream-splits" output-channel="pre-output" />
<aggregator id="second-aggregator" input-channel="pre-output" />
但是对于JavaDSL配置来说,这是完全相同的
虽然您的问题是,您确实必须为您的用例找出合适的发布策略,因为您可能不知道迭代器的大小。我不再使用.aggregate()。现在,在.split()之前,我将迭代器保存在标题中,并使用丢弃通道将I.filter(“headers['iterator'].hasNext()”)保存在标题中。