Class ApacheKafkaProducerAdapter
java.lang.Object
com.linkedin.venice.pubsub.adapter.kafka.producer.ApacheKafkaProducerAdapter
- All Implemented Interfaces:
PubSubProducerAdapter
A wrapper over Apache Kafka producer which implements
PubSubProducerAdapter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(long closeTimeOutMs) void
flush()
it.unimi.dsi.fastutil.objects.Object2DoubleMap<String>
int
getNumberOfPartitions
(String topic) Deprecated.sendMessage
(String topic, Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders pubsubMessageHeaders, PubSubProducerCallback pubsubProducerCallback) Sends a message to the Kafka Producer.
-
Constructor Details
-
ApacheKafkaProducerAdapter
- Parameters:
producerConfig
- contains producer configs
-
-
Method Details
-
getNumberOfPartitions
Deprecated.N.B.: This is an expensive call, the result of which should be cached.- Specified by:
getNumberOfPartitions
in interfacePubSubProducerAdapter
- Parameters:
topic
- for which we want to request the number of partitions.- Returns:
- the number of partitions for this topic.
-
sendMessage
public CompletableFuture<PubSubProduceResult> sendMessage(String topic, Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders pubsubMessageHeaders, PubSubProducerCallback pubsubProducerCallback) Sends a message to the Kafka Producer. If everything is set up correctly, it will show up in Kafka log.- Specified by:
sendMessage
in interfacePubSubProducerAdapter
- Parameters:
topic
- - The topic to be sent to.key
- - The key of the message to be sent.value
- - TheKafkaMessageEnvelope
, which acts as the Kafka value.pubsubProducerCallback
- - The callback function, which will be triggered when Kafka client sends out the message.partition
- The partition to which the message should be sent.pubsubMessageHeaders
- Additional headers to be included with the message.- Returns:
- - A
Future
ofPubSubProduceResult
, which will be completed when the message is sent to pub-sub server successfully. - Throws:
PubSubOpTimeoutException
- - If the operation times out.PubSubTopicAuthorizationException
- - If the producer is not authorized to send to the topic.PubSubTopicDoesNotExistException
- - If the topic does not exist.PubSubClientRetriableException
- - If the operation fails due to transient reasons.PubSubClientException
- - If the operation fails due to other reasons.
-
flush
public void flush()- Specified by:
flush
in interfacePubSubProducerAdapter
-
close
public void close(long closeTimeOutMs) - Specified by:
close
in interfacePubSubProducerAdapter
-
getMeasurableProducerMetrics
- Specified by:
getMeasurableProducerMetrics
in interfacePubSubProducerAdapter
-
getBrokerAddress
- Specified by:
getBrokerAddress
in interfacePubSubProducerAdapter
-