@PublicEvolving public interface KafkaContextAware<T>
KafkaSerializationSchemas
that need information
about the context where the Kafka Producer is running along with information about the available
partitions.
You only need to override the methods for the information that you need. However, getTargetTopic(Object)
is required because it is used to determine the available partitions.
Modifier and Type | Method and Description |
---|---|
String |
getTargetTopic(T element)
Returns the topic that the presented element should be sent to.
|
default void |
setNumParallelInstances(int numParallelInstances)
Sets the parallelism with which the parallel task of the Kafka Producer runs.
|
default void |
setParallelInstanceId(int parallelInstanceId)
Sets the number of the parallel subtask that the Kafka Producer is running on.
|
default void |
setPartitions(int[] partitions)
Sets the available partitions for the topic returned from
getTargetTopic(Object) . |
default void setParallelInstanceId(int parallelInstanceId)
setNumParallelInstances(int)
).default void setNumParallelInstances(int numParallelInstances)
default void setPartitions(int[] partitions)
getTargetTopic(Object)
.String getTargetTopic(T element)
ProducerRecord
that
is returned from KafkaSerializationSchema.serialize(Object, Long)
, it is only used
for getting the available partitions that are presented to setPartitions(int[])
.Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.