Skip to content

Commit 5aa7281

Browse files
committed
README: Add delivery report to Avro example
1 parent fe85968 commit 5aa7281

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Confluent's Python Client for Apache Kafka<sup>TM</sup>
55
[Apache Kafka<sup>TM<sup>](http://kafka.apache.org/) brokers >= v0.8, [Confluent Cloud](https://www.confluent.io/confluent-cloud/)
66
and the [Confluent Platform](https://www.confluent.io/product/compare/). The client is:
77

8-
- **Reliable** - It's a wrapper around [librdkafka](https://github.com/edenhill/librdkafka) (provided automatically via binary wheels) which is widely deployed in a diverse set of production scenarios. It's tested using [the same set of system tests](https://github.com/confluentinc/confluent-kafka-python/tree/master/confluent_kafka/kafkatest) as the Java client [and more](https://github.com/confluentinc/confluent-kafka-python/tree/master/tests). It's supported by [Confluent](https://confluent.io).
8+
- **Reliable** - It's a wrapper around [librdkafka](https://github.com/edenhill/librdkafka) (provided automatically via binary wheels) which is widely deployed in a diverse set of production scenarios. It's tested using [the same set of system tests](https://github.com/confluentinc/confluent-kafka-python/tree/master/confluent_kafka/kafkatest) as the Java client [and more](https://github.com/confluentinc/confluent-kafka-python/tree/master/tests). It's supported by [Confluent](https://confluent.io).
99

1010
- **Performant** - Performance is a key design consideration. Maximum throughput is on par with the Java client for larger message sizes (where the overhead of the Python interpreter has less impact). Latency is on par with the Java client.
1111

@@ -125,8 +125,19 @@ key_schema = avro.loads(key_schema_str)
125125
value = {"name": "Value"}
126126
key = {"name": "Key"}
127127

128+
129+
def delivery_report(err, msg):
130+
""" Called once for each message produced to indicate delivery result.
131+
Triggered by poll() or flush(). """
132+
if err is not None:
133+
print('Message delivery failed: {}'.format(err))
134+
else:
135+
print('Message delivered to {} [{}]'.format(msg.topic(), msg.partition()))
136+
137+
128138
avroProducer = AvroProducer({
129139
'bootstrap.servers': 'mybroker,mybroker2',
140+
'on_delivery': delivery_report,
130141
'schema.registry.url': 'http://schema_registry_host:port'
131142
}, default_key_schema=key_schema, default_value_schema=value_schema)
132143

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy