我有以下配置
@Bean
public IntegrationFlow mainFlow(){
return IntegrationFlows.from("channel1")
.route("condition", p -> p
.subFlowMapping("true", flow -> flow.gateway("channel2"))
.subFlowMapping("false" flow -> {
flow.gateway("channel3", c -> c.replyChannel("aggregatorOutputChannel"));
flow.gateway("channel4");
})
.get();
}
@Bean
public MessageChannel channel3()
{
return MessageChannels.publishSubscribe().applySequence(true).get();
}
@Bean
public IntegrationFlow flow1(){
return IntegrationFlows.from("channel3")
.transform(s -> {
System.out.println(s);
return s;
}
.channel("aggregatorInputChannel")
.get();
}
@Bean
public IntegrationFlow flow2(){
return IntegrationFlows.from("channel3")
.split()
.transform(s -> {
System.out.println(s);
return s;
}
.aggregate()
.channel("aggregatorInputChannel")
.get();
}
@Bean
public IntegrationFlow aggregatorFlow(){
return IntegrationFlows.from("aggregatorInputChannel")
.aggregate((AggregatorSpec s) -> s.groupTimeout(60000)
.outputProcessor(new AggregationMessageGroupProcessor())
.sendPartialResultOnExpiry(true)
.expireGroupsUponCompletion(true)
.releaseStrategy(new TimeoutOrSequenceCountComparatorReleaseStrategy(4, 60000)), null)
.gateway("postAggregation")
.channel("aggregatorOutputChannel")
.get();
}
通道 3 是一个 pub-sub 通道,有 2 个消费者处理消息并在完成后将消息放入 aggregatorInputChannel。然而,我观察到的是,即使消息最终被放入了 aggregatorOutputChannel(我通过聚合器 bean 定义进行了调试,我可以看到消息进入 aggregatorOutputChannel),channel3 上的网关阻塞并且永远不会返回。结果,消息永远不会到达通道 4。
我在这里错过了什么吗?还是做错了什么?
AggregationMessageGroupProcessor 是我的自定义聚合器,我在其中所做的只是覆盖 aggregatePayloads 方法
public class AggregationMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor {
@Override
protected final Object aggregatePayloads(MessageGroup group, Map<String, Object> headers) {
group.getOne().getPayload();
}
}
谢谢!