我正在尝试根据分区键将流拆分为多个分区,但显然它不起作用。实现是这样的,我有一个类可以说Metrices
public class Metrice {
public string MetriceType { get; set; }
public double MetriceValue { get; set; }
}
度量标准将一次异步使用一个,并且可能具有不同的MetriceType
. 我想要实现的是在MetriceType
. 到目前为止我所尝试的。
- 将消息键(partitionKey)设置为
MetricesType
;
public Message<string, string> FormatMessage(string partitionKey, string message)
{
return new Message<string, string> { Key = partitionKey, Value = message };
}
消息总是在Partition.Value
= 0发布
- Confluent.Kafka 库中的 Partitoner 类,希望有类似于 Custom Partitoner的东西,这个链接但找不到任何 .net 实现。
所以我的问题是,在这种情况下,有没有办法根据属性拆分我的收入消息,MetriceType
并将它们发布在他们的专用分区上(排序是必不可少的),或者我唯一的选择是使用和AdminClient
硬编码创建一个主题分区计数,或者我可以研究另一种方法。提前致谢。