We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c87d11 commit 4267ed5Copy full SHA for 4267ed5
docs/usage.rst
@@ -91,6 +91,18 @@ KafkaProducer
91
for _ in range(100):
92
producer.send('my-topic', b'msg')
93
94
+ def on_send_success(record_metadata):
95
+ print(record_metadata.topic)
96
+ print(record_metadata.partition)
97
+ print(record_metadata.offset)
98
+
99
+ def on_send_error(excp):
100
+ log.error('I am an errback', exc_info=excp)
101
+ # handle exception
102
103
+ # produce asynchronously with callbacks
104
+ producer.send('my-topic', b'raw_bytes').add_callback(on_send_success).add_errback(on_send_error)
105
106
# block until all async messages are sent
107
producer.flush()
108
0 commit comments