Class MockProducerFactory<K,V>

java.lang.Object
org.springframework.kafka.mock.MockProducerFactory<K,V>
Type Parameters:
K - the key type.
V - the value type.
All Implemented Interfaces:
ProducerFactory<K,V>

public class MockProducerFactory<K,V> extends Object implements ProducerFactory<K,V>
Support the use of MockProducer in tests.
Since:
3.0.7
Author:
Gary Russell
  • Constructor Details

    • MockProducerFactory

      public MockProducerFactory(Supplier<org.apache.kafka.clients.producer.MockProducer<K,V>> producerProvider)
      Create an instance that does not support transactional producers.
      Parameters:
      producerProvider - a Supplier for a MockProducer.
    • MockProducerFactory

      public MockProducerFactory(BiFunction<Boolean,String,org.apache.kafka.clients.producer.MockProducer<K,V>> producerProvider, @Nullable String defaultTxId)
      Create an instance that supports transactions, with the supplied producer provider BiFunction. The function has two parameters, a boolean indicating whether a transactional producer is being requested and, if true, the transaction id prefix for that producer.
      Parameters:
      producerProvider - the provider function.
      defaultTxId - the default transactional id.
  • Method Details