K
- the key type.V
- the value type.public interface ProducerFactory<K,V>
Producer
instance(s).Modifier and Type | Interface and Description |
---|---|
static interface |
ProducerFactory.Listener<K,V>
Called whenever a producer is added or removed.
|
Modifier and Type | Field and Description |
---|---|
static java.time.Duration |
DEFAULT_PHYSICAL_CLOSE_TIMEOUT
The default close timeout duration as 30 seconds.
|
Modifier and Type | Method and Description |
---|---|
default void |
addListener(int index,
ProducerFactory.Listener<K,V> listener)
Add a listener at a specific index.
|
default void |
addListener(ProducerFactory.Listener<K,V> listener)
Add a listener.
|
default void |
addPostProcessor(ProducerPostProcessor<K,V> postProcessor)
Add a post processor.
|
default void |
closeProducerFor(java.lang.String transactionIdSuffix)
Remove the specified producer from the cache and close it.
|
default void |
closeThreadBoundProducer()
If the factory implementation uses thread-bound producers, call this method to
close and release this thread's producer.
|
default org.apache.kafka.clients.producer.Producer<K,V> |
createNonTransactionalProducer()
Create a non-transactional producer.
|
org.apache.kafka.clients.producer.Producer<K,V> |
createProducer()
Create a producer which will be transactional if the factory is so configured.
|
default org.apache.kafka.clients.producer.Producer<K,V> |
createProducer(java.lang.String txIdPrefix)
Create a producer with an overridden transaction id prefix.
|
default java.util.Map<java.lang.String,java.lang.Object> |
getConfigurationProperties()
Return an unmodifiable reference to the configuration map for this factory.
|
default java.util.function.Supplier<org.apache.kafka.common.serialization.Serializer<K>> |
getKeySerializerSupplier()
Return a supplier for a key serializer.
|
default java.util.List<ProducerFactory.Listener<K,V>> |
getListeners()
Get the current list of listeners.
|
default java.time.Duration |
getPhysicalCloseTimeout()
Get the physical close timeout.
|
default java.util.List<ProducerPostProcessor<K,V>> |
getPostProcessors()
Get the current list of post processors.
|
default java.lang.String |
getTransactionIdPrefix()
Return the transaction id prefix.
|
default java.util.function.Supplier<org.apache.kafka.common.serialization.Serializer<V>> |
getValueSerializerSupplier()
Return a supplier for a value serializer.
|
default boolean |
isProducerPerConsumerPartition()
Return the producerPerConsumerPartition.
|
default boolean |
isProducerPerThread()
Return true when there is a producer per thread.
|
default boolean |
removeListener(ProducerFactory.Listener<K,V> listener)
Remove a listener.
|
default boolean |
removePostProcessor(ProducerPostProcessor<K,V> postProcessor)
Remove a post processor.
|
default void |
reset()
Reset any state in the factory, if supported.
|
default boolean |
transactionCapable()
Return true if the factory supports transactions.
|
static final java.time.Duration DEFAULT_PHYSICAL_CLOSE_TIMEOUT
org.apache.kafka.clients.producer.Producer<K,V> createProducer()
transactionCapable()
default org.apache.kafka.clients.producer.Producer<K,V> createProducer(java.lang.String txIdPrefix)
txIdPrefix
- the transaction id prefix.default org.apache.kafka.clients.producer.Producer<K,V> createNonTransactionalProducer()
transactionCapable()
default boolean transactionCapable()
default void closeProducerFor(java.lang.String transactionIdSuffix)
transactionIdSuffix
- the producer's transaction id suffix.default boolean isProducerPerConsumerPartition()
default void closeThreadBoundProducer()
default void reset()
default java.util.Map<java.lang.String,java.lang.Object> getConfigurationProperties()
default java.util.function.Supplier<org.apache.kafka.common.serialization.Serializer<V>> getValueSerializerSupplier()
default java.util.function.Supplier<org.apache.kafka.common.serialization.Serializer<K>> getKeySerializerSupplier()
default boolean isProducerPerThread()
@Nullable default java.lang.String getTransactionIdPrefix()
default java.time.Duration getPhysicalCloseTimeout()
default void addListener(ProducerFactory.Listener<K,V> listener)
listener
- the listener.default void addListener(int index, ProducerFactory.Listener<K,V> listener)
index
- the index (list position).listener
- the listener.default boolean removeListener(ProducerFactory.Listener<K,V> listener)
listener
- the listener.default java.util.List<ProducerFactory.Listener<K,V>> getListeners()
default void addPostProcessor(ProducerPostProcessor<K,V> postProcessor)
postProcessor
- the post processor.default boolean removePostProcessor(ProducerPostProcessor<K,V> postProcessor)
postProcessor
- the post processor.default java.util.List<ProducerPostProcessor<K,V>> getPostProcessors()