Kafka block.on.buffer.full默认值

时间:2016-02-23 13:11:32

标签: apache-kafka kafka-producer-api

我正在查看kafka(0.9.0.1)生产者配置,文档中的属性block.on.buffer.full说:

  

当我们的内存缓冲区耗尽时,我们必须停止接受新内存缓冲区   记录(阻止)或抛出错误。 默认情况下,此设置为true 和   我们阻止,但在某些情况下,阻止是不可取的   最好立即给出错误。将此设置为false将   实现:如果生成器将抛出BufferExhaustedException   发送一个recrord并且缓冲区空间已满。

理论上它应该是真的,但在同一文档(http://kafka.apache.org/documentation.html)中,该表有一个名为“default”的列,指出默认值实际上是假的。

哪一个是正确的?

2 个答案:

答案 0 :(得分:3)

默认值为false。

这是最新版本的生产者默认configuration

答案 1 :(得分:1)

你是对的,代码和javadoc也是错误的,请参阅ProducerConfig类:

javadoc说,它默认为true。

 @Deprecated
    public static final String BLOCK_ON_BUFFER_FULL_CONFIG = "block.on.buffer.full";
    private static final String BLOCK_ON_BUFFER_FULL_DOC = "When our memory buffer is exhausted we must either stop accepting new records (block) or throw errors. **By default this setting is true** and we block, however in some scenarios blocking is not desirable and it is better to immediately give an error. Setting this to <code>false</code> will accomplish that: the producer will throw a BufferExhaustedException if a recrord is sent and the buffer space is full.";

但是,代码将其设置为false:)。

 .define(BLOCK_ON_BUFFER_FULL_CONFIG, Type.BOOLEAN, **false,** Importance.LOW, BLOCK_ON_BUFFER_FULL_DOC)

无论如何,它已弃用,不应使用。

相关问题