配置 Apache Kafka 的 .NET 生产者客户端以处理大消息时出错

Error configuring .NET producer client of Apache Kafka to work with big messages

我正在使用 .NET client (producer and consumer) of Apache Kafka

我正在尝试增加可以发送的最大消息的大小。我阅读了 configuration manual 和一些关于我的问题的帖子:

  1. Kafka: Sending a 15MB message
  2. https://github.com/confluentinc/kafka-rest/issues/208

我看到我应该为生产者设置属性 "max.request.size"。 所以我做了以下事情:

   var config = new Dictionary<string, object>
        {
            { "bootstrap.servers", brokerList },
            { "max.request.size", 10 * 1024 * 1024 }
        };

        using (var producer = new Producer<Null, string>(config, null, new StringSerializer(Encoding.UTF8)))
        {
         ...

但是当我运行生产者时,抛出异常:

System.InvalidOperationException: 'No such configuration property: "max.request.size"'

Apache Kafka 文档讲述了生产者的这个 属性 的以下内容:

The maximum size of a request in bytes. This is also effectively a cap on the maximum record size. Note that the server has its own cap on record size which may be different from this. This setting will limit the number of record batches the producer will send in a single request to avoid sending huge requests.

如果由于某种原因文档不是最新的,属性 使用什么是正确的?

谢谢

confluent-kafka-dotnet 在底层使用 librdkafka,它与 java 客户端有一组不同的配置参数。这些记录在此处:

https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

我相信您要查找的参数是 message.max.bytes