K - the key type.V - the value type.public class DefaultKafkaConsumerFactory<K,V> extends java.lang.Object implements ConsumerFactory<K,V>
ConsumerFactory implementation to produce a new Consumer instance
for provided Map configs and optional Deserializer keyDeserializer,
valueDeserializer implementations on each ConsumerFactory.createConsumer()
invocation.| Constructor and Description |
|---|
DefaultKafkaConsumerFactory(java.util.Map<java.lang.String,java.lang.Object> configs)
Construct a factory with the provided configuration.
|
DefaultKafkaConsumerFactory(java.util.Map<java.lang.String,java.lang.Object> configs,
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
Construct a factory with the provided configuration and deserializers.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.kafka.clients.consumer.Consumer<K,V> |
createConsumer(java.lang.String groupId,
java.lang.String clientIdPrefix,
java.lang.String clientIdSuffix)
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. |
protected org.apache.kafka.clients.consumer.KafkaConsumer<K,V> |
createKafkaConsumer(java.util.Map<java.lang.String,java.lang.Object> configs) |
protected org.apache.kafka.clients.consumer.KafkaConsumer<K,V> |
createKafkaConsumer(java.lang.String groupId,
java.lang.String clientIdPrefix,
java.lang.String clientIdSuffixArg) |
java.util.Map<java.lang.String,java.lang.Object> |
getConfigurationProperties()
Return an unmodifiable reference to the configuration map for this factory.
|
org.apache.kafka.common.serialization.Deserializer<K> |
getKeyDeserializer()
Return the configured key deserializer (if provided as an object instead
of a class name in the properties).
|
org.apache.kafka.common.serialization.Deserializer<V> |
getValueDeserializer()
Return the configured value deserializer (if provided as an object instead
of a class name in the properties).
|
boolean |
isAutoCommit()
Return true if consumers created by this factory use auto commit.
|
void |
setKeyDeserializer(org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer) |
void |
setValueDeserializer(org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateConsumer, createConsumer, createConsumerpublic DefaultKafkaConsumerFactory(java.util.Map<java.lang.String,java.lang.Object> configs)
configs - the configuration.public DefaultKafkaConsumerFactory(java.util.Map<java.lang.String,java.lang.Object> configs,
@Nullable
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
@Nullable
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
configs - the configuration.keyDeserializer - the key Deserializer.valueDeserializer - the value Deserializer.public void setKeyDeserializer(@Nullable
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer)
public void setValueDeserializer(@Nullable
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer)
public java.util.Map<java.lang.String,java.lang.Object> getConfigurationProperties()
ConsumerFactorygetConfigurationProperties in interface ConsumerFactory<K,V>public org.apache.kafka.common.serialization.Deserializer<K> getKeyDeserializer()
ConsumerFactorygetKeyDeserializer in interface ConsumerFactory<K,V>public org.apache.kafka.common.serialization.Deserializer<V> getValueDeserializer()
ConsumerFactorygetValueDeserializer in interface ConsumerFactory<K,V>public org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer(@Nullable java.lang.String groupId, @Nullable java.lang.String clientIdPrefix, @Nullable java.lang.String clientIdSuffix)
ConsumerFactoryclient.id property, if present.
If a factory does not implement this method, ConsumerFactory.createConsumer(String, String)
is invoked, ignoring the prefix.createConsumer in interface ConsumerFactory<K,V>groupId - the group id.clientIdPrefix - the prefix.clientIdSuffix - the suffix.protected org.apache.kafka.clients.consumer.KafkaConsumer<K,V> createKafkaConsumer(@Nullable java.lang.String groupId, @Nullable java.lang.String clientIdPrefix, @Nullable java.lang.String clientIdSuffixArg)
protected org.apache.kafka.clients.consumer.KafkaConsumer<K,V> createKafkaConsumer(java.util.Map<java.lang.String,java.lang.Object> configs)
public boolean isAutoCommit()
ConsumerFactoryisAutoCommit in interface ConsumerFactory<K,V>