Spring integration spring集成按分类器分组消息

Spring integration spring集成按分类器分组消息,spring-integration,spring-integration-dsl,Spring Integration,Spring Integration Dsl,使用Java 8 streams,我可以通过分类器对消息进行分组: Map<String, List<String>> grouped = Arrays.asList("a", "b", "b", "b", "c") .stream() .collect(Collectors.groupingBy(Function.identity())); 解决方法是根本不使用聚合器,而是将传入列表分组到转换器中。但我希望我可以使用聚合器来实现这一点

使用Java 8 streams,我可以通过分类器对消息进行分组:

Map<String, List<String>> grouped = Arrays.asList("a", "b", "b", "b", "c")
        .stream()
        .collect(Collectors.groupingBy(Function.identity()));
解决方法是根本不使用聚合器,而是将传入列表分组到转换器中。但我希望我可以使用聚合器来实现这一点

@Bean
public IntegrationFlow groupStringsFlow() {
    return IntegrationFlows.from(StringGrouper.class)
        .<List<String>, Collection<List<String>>>transform(source -> source.stream()
            .collect(Collectors.collectingAndThen(
                Collectors.groupingBy(Function.identity()), 
                grouped -> grouped.values())))
        .split()
        .log() // work with messages
        .aggregate()
        .get();
}
@Bean
公共集成流组StringsFlow(){
返回IntegrationFlows.from(StringGrouper.class)
.transform(source->source.stream()
收集,收集收集,然后收集(
Collectors.groupingBy(Function.identity()),
分组->分组.values()))
.split()
.log()//处理消息
.aggregate()
.get();
}

使用默认的序列大小释放策略将它们聚合为单个组,并使用自定义输出处理器(
MessageGroupProcessor
)在有效负载上重新分组,返回一个
集合到现在为止,我应该已经知道MessageGroupProcessor:-)
@Bean
public IntegrationFlow groupStringsFlow() {
    return IntegrationFlows.from(StringGrouper.class)
        .<List<String>, Collection<List<String>>>transform(source -> source.stream()
            .collect(Collectors.collectingAndThen(
                Collectors.groupingBy(Function.identity()), 
                grouped -> grouped.values())))
        .split()
        .log() // work with messages
        .aggregate()
        .get();
}