Class MockProducer<K,​V>

java.lang.Object
org.apache.kafka.clients.producer.MockProducer<K,​V>
All Implemented Interfaces:
Closeable, AutoCloseable, Producer<K,​V>

public class MockProducer<K,​V>
extends Object
implements Producer<K,​V>
A mock of the producer interface you can use for testing code that uses Kafka.

By default this mock will synchronously complete each send call successfully. However it can be configured to allow the user to control the completion of the call and supply an optional error for the producer to throw.