gpt4 book ai didi

java - Spring Integration 去抖动/去重

转载 作者:行者123 更新时间:2023-12-04 00:37:05 27 4
gpt4 key购买 nike

Spring Integration 中是否有一些组件可用于在指定时间范围内过滤掉重复项?

我正在寻找类似 Debounce from ReactiveX 的内容

在我的项目中,我正在发送一个包含 UUID 的有效负载,如果在 10 秒内通过队列发送,我想过滤掉具有相同 UUID 的多个有效负载 - 然后我只想让最后一个通过只要在接下来的 10 秒内没有其他具有相同 UUID 的 Payload 出现。

最佳答案

您可以使用 aggregator为了这个目的。您需要设置的是

  • 识别重复消息的关联策略
  • 将单个消息视为完整组的发布策略
  • expire-groups-upon-completionfalse,这样组完成发送出去就不会被删除
  • group-timeout到,例如10秒
  • 保持 expire-groups-upon-timeouttrue(默认是这样)

来自引用文档:

(expire-groups-upon-completion) When set to true (default false), completed groups are removed from the message store, allowing subsequent messages with the same correlation to form a new group. The default behavior is to send messages with the same correlation as a completed group to the discard-channel.

关于java - Spring Integration 去抖动/去重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39916795/

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