如何在分布式环境中使用Spring聚合器?

How to use Spring Aggregator in distributed environment?

我有一个要求,应用程序在 Kafka 主题中为 1 个批次发送 n 条异步消息以进行某些处理。我想在 Kafka 消费者处集成 Spring 聚合器,以便在处理完该批次的所有消息后生成一个事件。我的问题是,由于同一批次有多个 Kafka 消费者,我将如何在分布式环境中集成聚合器?我们应该将它与 Hazelcast 等任何内存数据库集成吗?

没错。您需要使用一些共享持久存储配置该聚合器:https://docs.spring.io/spring-integration/docs/current/reference/html/message-routing.html#reaper.

Hazelcast 没有 MessageGroupStore 实现:https://github.com/spring-projects/spring-integration-extensions/tree/main/spring-integration-hazelcast. But you can consider to use whatever is available for you from our implementations: https://docs.spring.io/spring-integration/docs/current/reference/html/system-management.html#message-store

欢迎就 Hazelcast 扩展问题做出贡献!