3

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

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

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

哪一个是正确的?

4

2 回答 2

3

默认值为假。

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

于 2016-02-23T13:34:05.810 回答
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)

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

于 2016-07-06T03:00:13.737 回答