Class MockConsumerFactory<K,V>

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

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

    • MockConsumerFactory

      public MockConsumerFactory(Supplier<org.apache.kafka.clients.consumer.MockConsumer<K,V>> consumerProvider)
      Create an instance with the supplied consumer provider.
      Parameters:
      consumerProvider - the consumer provider.
  • Method Details

    • getConfigurationProperties

      public Map<String,Object> getConfigurationProperties()
      Description copied from interface: ConsumerFactory
      Return an unmodifiable reference to the configuration map for this factory. Useful for cloning to make a similar factory.
      Specified by:
      getConfigurationProperties in interface ConsumerFactory<K,V>
      Returns:
      the configs.
    • createConsumer

      public org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer(@Nullable String groupId, @Nullable String clientIdPrefix, @Nullable String clientIdSuffix)
      Description copied from interface: ConsumerFactory
      Create a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides the client.id property, if present.
      Specified by:
      createConsumer in interface ConsumerFactory<K,V>
      Parameters:
      groupId - the group id.
      clientIdPrefix - the prefix.
      clientIdSuffix - the suffix.
      Returns:
      the consumer.
    • createConsumer

      public org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer(@Nullable String groupId, @Nullable String clientIdPrefix, @Nullable String clientIdSuffix, @Nullable Properties properties)
      Description copied from interface: ConsumerFactory
      Create a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides the client.id property, if present. In addition, consumer properties can be overridden if the factory implementation supports it.
      Specified by:
      createConsumer in interface ConsumerFactory<K,V>
      Parameters:
      groupId - the group id.
      clientIdPrefix - the prefix.
      clientIdSuffix - the suffix.
      properties - the properties to override.
      Returns:
      the consumer.
    • isAutoCommit

      public boolean isAutoCommit()
      Description copied from interface: ConsumerFactory
      Return true if consumers created by this factory use auto commit.
      Specified by:
      isAutoCommit in interface ConsumerFactory<K,V>
      Returns:
      true if auto commit.