"不允许空相关"当尝试使用带有@CorrelationStrategy注释的bean时

时间:2016-07-04 19:03:22

标签: spring-integration

我是Spring Integration的新手,我正在尝试使用Java DSL配置来指定使用具有@ Aggregator,@ ReleaseStrategy和@CorrelationStrategy注释的类GroupPublishAggregator聚合消息的流。

我怀疑我在配置中犯了新手错误,因为我在聚合器收到消息时看到的是" java.lang.IllegalStateException:不允许空关联。也许CorrelationStrategy失败了?"如果我调试框架代码,我看到AbstractCorrelatingMessageHandler正在调用默认的org.springframework.integration.aggregator.HeaderAttributeCorrelationStrategy而不是我的策略。

配置代码如下所示:

@Bean 
public GroupPublishAggregator publishAggregator() {
    //  This class has methods with @Aggregator, @ReleaseStrategy,
    //  and @CorrelationStrategy annotations.
    return new GroupPublishAggregator();
}

@Bean
public IntegrationFlow publish() {
    return IntegrationFlows.from(this.inputChannel())
            .wireTap("monitor")
            .aggregate(new Consumer<AggregatorSpec>() {
                @Override
                public void accept(AggregatorSpec aggregatorSpec) {
                    aggregatorSpec.processor(publishAggregator(), null);
                }
            })
            .get();
}

1 个答案:

答案 0 :(得分:0)

这是一个错误。即将修复:https://github.com/spring-projects/spring-integration-java-dsl/issues/93

与此同时,您的解决方法是将CorrelationStrategyFactoryBeanReleaseStrategyFactoryBean分别用作@Bean,并分别使用correlationStrategy(CorrelationStrategy correlationStrategy)releaseStrategy(ReleaseStrategy releaseStrategy)

我们不会为那些afterPropertiesSet()致电FactoryBean的问题。