I have an aggregator configured via the Java DSL in a Spring Integration flow, and I want to throw an exception that goes to the global error channel when a group timeout occurs.
The discard channel is no good for me because discard messages are at the group member level, rather than for the whole group.
I've tried using the application event publisher as follows, but the publisher object doesn't seem to get invoked:
.aggregate(new Consumer<AggregatorSpec>() {
@Override
public void accept(AggregatorSpec aggregatorSpec) {
try {
aggregatorSpec
.outputProcessor(groupPublishStrategy())
.correlationStrategy(groupPublishStrategy())
.releaseStrategy(groupPublishStrategy())
.groupTimeout(groupTimeout)
.get().getT2().setApplicationEventPublisher(myGroupExpirationPublisher());
}
catch (Exception e) {
e.printStackTrace();
}
}
})
Is there a recommended way to get notification for this use case? Any ideas why the above doesn't seem to work?
I suppose I could extend the AggregatorSpec class to get the message handler configured the way I want, but I wanted to see if I could do this with stock SI classes.