Search code examples
spring-integration

Correct way of using @Aggregator annotation with MethodInvokingMessageGroupProcessor


When creating a MethodInvokingMessageGroupProcessor(Object target) is it correct to annotate the desired processing method in target with @Aggregator or will this cause a useless creation of an AggregatingMessageHandler object?


Solution

  • That's correct. That's the logic of that MethodInvokingMessageGroupProcessor and its MessagingMethodInvokerHelper delegate:

    public MethodInvokingMessageGroupProcessor(Object target) {
        this.processor = new MethodInvokingMessageListProcessor<Object>(target, Aggregator.class);
    }
    

    Although adding an annotation is still optional, it would be good to have to give that MessagingMethodInvokerHelper a little help.

    No, it does not create an extra AggregatingMessageHandler, if your @Aggregator doesn't come with an inputChannel attribute.