正确使用 @Aggregator 注解与 MethodInvokingMessageGroupProcessor 的方法是:

huangapple go评论63阅读模式
英文:

Correct way of using @Aggregator annotation with MethodInvokingMessageGroupProcessor

问题

在创建一个MethodInvokingMessageGroupProcessor(Object target)时,将目标对象target中所需的处理方法标记为@Aggregator是否正确?或者这会导致创建一个无用的AggregatingMessageHandler对象?

英文:

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?

答案1

得分: 1

这是正确的。这是MethodInvokingMessageGroupProcessor及其MessagingMethodInvokerHelper代理的逻辑:

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

虽然添加注释仍然是可选的,但为了帮助MessagingMethodInvokerHelper,最好添加一个。

不,如果您的@Aggregator没有inputChannel属性,它不会创建额外的AggregatingMessageHandler

英文:

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.

huangapple
  • 本文由 发表于 2023年8月5日 03:50:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76838801.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定