2

The Confluent Kafka library (python version in this case) has a produce method which takes a delivery callback function:

kafka_producer.produce(topic=topic,
                            key=key,
                            value=value,
                            on_delivery=delivery_callback)

This callback is called whether the message was successfully delivered or not:

def delivery_callback(err, msg):

I want to know what are the scenarios when this delivery callback is called with an error? I tried to shut down the kafka broker server and then produce and flush the message. Still the callback was not called with the error, rather the next time I did flush with the Kafka broker running, the successful delivery callback for the previous message came first.

So how can I have error callback?

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
coderelliot
  • 421
  • 5
  • 15

1 Answers1

-2

Produce message to topic. This is an asynchronous operation, an application may use the callback (alias on_delivery) argument to pass a function (or lambda) that will be called from poll() when the message has been successfully delivered or permanently fails delivery.


Currently message headers are not supported on the message returned to the callback. The msg.headers() will return None even if the original message had headers set.

Amal K
  • 4,359
  • 2
  • 22
  • 44
Ran Lupovich
  • 1,655
  • 1
  • 6
  • 13