MockProducer
In-memory stand-ins for the Kafka producer and consumer, shipped in kafka-clients for unit tests.
In more detail
A MockProducer records what was sent and lets a test complete or fail each send. A MockConsumer hands out records the test adds and needs its beginning offsets set before it can poll.
Example
new MockProducer<>(true, null, new StringSerializer(), new StringSerializer())Related terms
- KafkaProducer — The kafka-python class that buffers records, batches them and sends them to Kafka in the background.
- KafkaConsumer — The kafka-python class that reads records from Kafka topics, joins consumer groups and commits offsets.
- TopologyTestDriver — A Kafka Streams test utility that runs a topology in memory without a broker.
Taught in
- Green Tests, Red Production — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep
- Seventy One Percent — Confluent Apache Kafka Certifications (CCDAK and CCAAK) Exam Prep