gpt4 book ai didi

spring-integration - Spring Integration Aggregator 组超时值的问题

转载 作者:行者123 更新时间:2023-12-04 07:59:26 27 4
gpt4 key购买 nike

我们正在使用 Spring Integration 4.2.3 聚合器组件和定义的组超时,并期望组在给定的超时值内超时,同时向组添加消息和发布大小标准不满足。

但我们看到了不同的结果,当我们向服务输入重负载时,聚合器正在等待所有消息被添加到组中,而不是在达到超时时使组过期。

有什么方法可以覆盖聚合器功能以在超时组时查看第一条消息而不是最后一条消息。

最佳答案

好吧,实际上你现在就可以做你需要做的事。使用相同的 group-timeout-expression。但是您必须引用评估上下文的 #root 对象,这正是您所需要的 - MessageGroup。有了它,您可以为您的目的调用其中之一:

/**
* @return the timestamp (milliseconds since epoch) associated with the creation of this group
*/
long getTimestamp();

/**
* @return the timestamp (milliseconds since epoch) associated with the time this group was last updated
*/
long getLastModified();

因此,您的原始请求的表达式可能是这样的:

group-timeout-expression="timestamp + 10000 - T(System).currentTimeMillis()"

我们得到调整后的超时,它将应用于计划任务,其值如下:new Date(System.currentTimeMillis() + groupTimeout));

关于spring-integration - Spring Integration Aggregator 组超时值的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48230453/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com