gpt4 book ai didi

java - KafkaProducer 是否具有容错能力?

转载 作者:太空宇宙 更新时间:2023-11-04 14:08:06 27 4
gpt4 key购买 nike

我们有一个系统,它从用户接收数据并将数据推送到 kafka,只有当我们确定数据已推送时,我们才会向用户发送“OK”响应。
由于新的kafka使用的是异步发送(ProducerRecord,Callback),我想知道这个发送是否具有抗崩溃(容错)功能?
我的猜测是它很可能不是,那么我如何在同步模式下使用它呢?或者我应该让用户等到回调被调用?

最佳答案

根据Kafka's Design :

Asynchronous send

Batching is one of the big drivers of efficiency, and to enable batching the Kafka producer has an asynchronous mode that accumulates data in memory and sends out larger batches in a single request. The batching can be configured to accumulate no more than a fixed number of messages and to wait no longer than some fixed latency bound (say 100 messages or 5 seconds). This allows the accumulation of more bytes to send, and few larger I/O operations on the servers. Since this buffering happens in the client it obviously reduces the durability as any data buffered in memory and not yet sent will be lost in the event of a producer crash.

关于java - KafkaProducer 是否具有容错能力?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28642638/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com