首页 > 解决方案 > (功能性)Spring Cloud Stream 自定义分区键实现,用于将消息列表发布到单个 Kafka 主题

问题描述

我创建了一个应用程序,它使用基于函数的 Spring 云流库将消息列表发布到单个 Kafka 主题。我想知道我们如何为列表中的每条消息设置分区键。基本上,每条消息都应该有自己的分区键逻辑。目前,如果我编写 custom ,它不会发布partitionKeyExtractor。让我知道是否有人以前解决过这个问题。例如:

Function<Message<String, List<Message<String>> processor(NotificationProcessor notification) {
return notification::processNotification
}

标签: apache-kafkaspring-cloud-streamspring-cloud-stream-binder-kafka

解决方案


推荐阅读