1

我正在使用spring集成聚合器和MessageGroupStoreReaper,但不知何故错误没有到达全局errorChannel。

    <int:aggregator id="agg"
                    ref="MyMsgsAggregator"
                    input-channel="myAggInputChannel"
                    output-channel="processInputChannel"
                    discard-channel="errorChannel"
                    method="aggMessages"
                    message-store="messageGroupStore"
                    send-partial-result-on-expiry="true"
                    expire-groups-upon-completion="true" />
                    
<bean id="messageGroupStore" class="org.springframework.integration.store.SimpleMessageStore" />

<task:scheduled-tasks>
        <task:scheduled ref="multipartAggregatorReaper" method="run" fixed-rate="5000" />
</task:scheduled-tasks>

如果在“processInputChannel”后有任何异常(例如到期时的部分结果),那么异常不会到达全局“errorChannel”。

即使我尝试用轮询器将任务计划的工作替换为入站通道适配器(如@Gary所建议的那样),但它仍然不起作用:

<int:inbound-channel-adapter channel="reaperChannel" ref="MyMsgsAggregator" method="triggerReaper"> 
<int:poller error-channel="**errorChannel**" fixed-rate="5000">         
</int:poller>

</int:inbound-channel-adapter>

请建议

谢谢

4

1 回答 1

0

你的问题在这里:send-partial-result-on-expiry="true"。此选项确实与discard-channel:

protected void expireGroup(Object correlationKey, MessageGroup group, Lock lock) {
    ...
    if (this.sendPartialResultOnExpiry) {
        ...
        completeGroup(correlationKey, group, lock);
    }
    else {
        ...
        group.getMessages()
                .forEach(this::discardMessage);
    }
    ...
}

因此,您的消息在收获后转到.processInputChannel而不是errorChannel.

此外,这discardChannel与错误无关。当我们收获并且ErrorMessage没有从那里发送时,如果丢弃,则不会抛出异常。来自 reaped 组的所有单个消息都作为常规消息发送到配置discardChannel的 .

于 2021-03-05T17:27:15.527 回答