Package org.springframework.kafka.mock
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>
Support the use of
MockConsumer in tests.- Since:
- 3.0.7
- Author:
- Gary Russell
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.kafka.core.ConsumerFactory
ConsumerFactory.Listener<K,V> -
Constructor Summary
ConstructorsConstructorDescriptionMockConsumerFactory(Supplier<org.apache.kafka.clients.consumer.MockConsumer> consumerProvider) Create an instance with the supplied consumer provicer. -
Method Summary
Modifier and TypeMethodDescriptioncreateConsumer(String groupId, String clientIdPrefix, String clientIdSuffix) Create a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides theclient.idproperty, if present.createConsumer(String groupId, String clientIdPrefix, String clientIdSuffix, Properties properties) Create a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides theclient.idproperty, if present.Return an unmodifiable reference to the configuration map for this factory.booleanReturn true if consumers created by this factory use auto commit.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.kafka.core.ConsumerFactory
addListener, addListener, addPostProcessor, createConsumer, createConsumer, createConsumer, getKeyDeserializer, getListeners, getPostProcessors, getValueDeserializer, removeConfig, removeListener, removePostProcessor, updateConfigs
-
Constructor Details
-
MockConsumerFactory
public MockConsumerFactory(Supplier<org.apache.kafka.clients.consumer.MockConsumer> consumerProvider) Create an instance with the supplied consumer provicer.- Parameters:
consumerProvider- the consumer provider.
-
-
Method Details
-
getConfigurationProperties
Description copied from interface:ConsumerFactoryReturn an unmodifiable reference to the configuration map for this factory. Useful for cloning to make a similar factory.- Specified by:
getConfigurationPropertiesin interfaceConsumerFactory<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:ConsumerFactoryCreate a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides theclient.idproperty, if present.- Specified by:
createConsumerin interfaceConsumerFactory<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:ConsumerFactoryCreate a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides theclient.idproperty, if present. In addition, consumer properties can be overridden if the factory implementation supports it.- Specified by:
createConsumerin interfaceConsumerFactory<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:ConsumerFactoryReturn true if consumers created by this factory use auto commit.- Specified by:
isAutoCommitin interfaceConsumerFactory<K,V> - Returns:
- true if auto commit.
-