Class ApacheKafkaProducerAdapter
- java.lang.Object
-
- com.linkedin.venice.pubsub.adapter.kafka.producer.ApacheKafkaProducerAdapter
-
- All Implemented Interfaces:
PubSubProducerAdapter
public class ApacheKafkaProducerAdapter extends java.lang.Object implements PubSubProducerAdapter
A wrapper over Apache Kafka producer which implementsPubSubProducerAdapter
-
-
Constructor Summary
Constructors Constructor Description ApacheKafkaProducerAdapter(ApacheKafkaProducerConfig producerConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close(long closeTimeOutMs)
void
flush()
java.lang.String
getBrokerAddress()
it.unimi.dsi.fastutil.objects.Object2DoubleMap<java.lang.String>
getMeasurableProducerMetrics()
int
getNumberOfPartitions(java.lang.String topic)
Deprecated.java.util.concurrent.CompletableFuture<PubSubProduceResult>
sendMessage(java.lang.String topic, java.lang.Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders pubsubMessageHeaders, PubSubProducerCallback pubsubProducerCallback)
Sends a message to the Kafka Producer.
-
-
-
Constructor Detail
-
ApacheKafkaProducerAdapter
public ApacheKafkaProducerAdapter(ApacheKafkaProducerConfig producerConfig)
- Parameters:
producerConfig
- contains producer configs
-
-
Method Detail
-
getNumberOfPartitions
@Deprecated public int getNumberOfPartitions(java.lang.String topic)
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 java.util.concurrent.CompletableFuture<PubSubProduceResult> sendMessage(java.lang.String topic, java.lang.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
public it.unimi.dsi.fastutil.objects.Object2DoubleMap<java.lang.String> getMeasurableProducerMetrics()
- Specified by:
getMeasurableProducerMetrics
in interfacePubSubProducerAdapter
-
getBrokerAddress
public java.lang.String getBrokerAddress()
- Specified by:
getBrokerAddress
in interfacePubSubProducerAdapter
-
-