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
ConstructorDescriptionMockConsumerFactory
(Supplier<org.apache.kafka.clients.consumer.MockConsumer<K, V>> consumerProvider) Create an instance with the supplied consumer provider. -
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.id
property, 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.id
property, if present.Return an unmodifiable reference to the configuration map for this factory.boolean
Return 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, wait
Methods inherited from interface org.springframework.kafka.core.ConsumerFactory
addListener, addListener, addPostProcessor, createConsumer, createConsumer, createConsumer, getKeyDeserializer, getListeners, getPostProcessors, getValueDeserializer, removeConfig, removeListener, removePostProcessor, updateConfigs
-
Constructor Details
-
Method Details
-
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 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:ConsumerFactory
Create a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides theclient.id
property, if present.- Specified by:
createConsumer
in 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:ConsumerFactory
Create a consumer with an explicit group id; in addition, the client id suffix is appended to the clientIdPrefix which overrides theclient.id
property, if present. In addition, consumer properties can be overridden if the factory implementation supports it.- Specified by:
createConsumer
in 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:ConsumerFactory
Return true if consumers created by this factory use auto commit.- Specified by:
isAutoCommit
in interfaceConsumerFactory<K,
V> - Returns:
- true if auto commit.
-