KafkaProducer
The kafka-python class that buffers records, batches them and sends them to Kafka in the background.
In more detail
Calling send returns a future straight away; the record is delivered by a background thread. Its settings, such as acks, linger_ms, batch_size and enable_idempotence, control durability, throughput and duplicates. Call flush or close before the program exits so buffered records are not lost.
Example
producer.send('events', key=b'k1', value=b'v1').get(timeout=10)Related terms
- kafka-python — An open-source Python client library for Kafka that provides KafkaProducer, KafkaConsumer and KafkaAdminClient.
- producer — The program that creates and sends messages or events.
- Future — An object that stands for a result that is not ready yet, which you can wait on later to get the value or the error.
- flush — A producer call that sends every buffered record immediately and waits until each request has completed.
- acks — The producer setting that decides how many brokers must confirm a record before the send counts as successful: 0, 1 or all.
Taught in
- The Payment That Was Charged Twice — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Where A Record Lands — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Acknowledged Is Not Always Safe — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Retention Deletes Files, Not Records — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- The Retry That Overtook — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Two Copies Of One Service — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Green Tests, Red Production — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- The Setting That Came Back — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Two Brokers Down — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Two Controllers At Once — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- A Producer In Python — Apache Kafka & Event Streaming
- Keys And Ordering Per Partition — Apache Kafka & Event Streaming
- Acknowledgements: What Acks Means For Durability — Apache Kafka & Event Streaming
- Batching, Linger And Throughput — Apache Kafka & Event Streaming
- Idempotent Producers And Retries — Apache Kafka & Event Streaming