1
votes

I'm using spring integration aggregator and MessageGroupStoreReaper but somehow the errors are not reaching global 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>

If there is any exception post "processInputChannel" ( e.g partial result on expiry) then exception is not reaching global "errorChannel".

Even I tried replacing task-scheduled job to inbound channel adapter( as suggested by @Gary) with poller but still it didn't work :

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

</int:inbound-channel-adapter>

Pls suggest

Thanks

1
First step is to turn on debug logging for o.s.integration and follow the messages flowing through the channels.Gary Russell
Please, see my answer for some finding and explanation.Artem Bilan

1 Answers

0
votes

Your problem is here: send-partial-result-on-expiry="true". This option is indeed mutually exclusive with the discard-channel:

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

So, that's not a surprise that your messages after reaping go to the processInputChannel, not an errorChannel.

Also, the discardChannel is not about errors. The exception is not thrown in case of discarding when we reap and an ErrorMessage is not sent from there. Everything single message from the reaped group is sent as regular one into that configured discardChannel.