Kafka producer callback Exception

后端 未结 3 867
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 00:15

When we produce messages we can define a callback, this callback can expect an exception:

kafkaProducer.send(produce         


        
3条回答
  •  无人及你
    2020-12-12 00:39

    You may get BufferExhaustedException or TimeoutException

    Just bring your Kafka down after the producer has produced one record. And then continue producing records. After sometime, you should be seeing exceptions in the callback.

    This is because, when you sent the first record, the metadata is fetched, after that, the records will be batched and buffered and they expire eventually after some timeout during which you may see these exceptions.

    I suppose that the timeout is delivery.timeout.ms which when expired give you a TimeoutException exception there.

提交回复
热议问题