【发布时间】:2021-06-03 23:16:55
【问题描述】:
我在 Spring Integration 流程中使用 scatter-gatter 来并行调用 3 个服务:
.scatterGather(rlr -> rlr.applySequence(true)
.recipientFlow(f1 -> f1
.channel(c -> c.executor(executorMLCalls))
.route(ifService1NeedsToBeCalled(), routeToService1OrBypassCall()))
.recipientFlow(f2 -> f2
.channel(c -> c.executor(executorMLCalls))
.enrich(this::service2RequestEnricher)
.enrich(this::service2Enricher))
.recipientFlow(f3 -> f3
.channel(c -> c.executor(executorMLCalls))
.enrich(this::service3RequestEnricher)
.enrich(this::service3Enricher)),
agg -> agg.correlationStrategy(msg -> msg.getHeaders().get("corrMLCalls"))
.releaseExpression("size() == 3"),
sgs -> sgs.gatherTimeout(gatherTimeout)
.requiresReply(true)
)
所以 service2 和 service3 必须始终被调用,但调用 service1 取决于条件。
因此,我不能使用 size() == 3 释放表达式,因为有时它应该是 size() == 2。
如何在表达式中使用动态值?可以在release表达式中调用本地方法吗?
谢谢!
问候,
五、
【问题讨论】:
标签: spring-integration spring-integration-dsl