Package com.linkedin.venice.pubsub.api
Interface PubSubProducerAdapter
- All Known Implementing Classes:
ApacheKafkaProducerAdapter,MockInMemoryProducerAdapter,MockInMemoryTransformingProducerAdapter,PubSubProducerAdapterConcurrentDelegator,PubSubProducerAdapterDelegator
public interface PubSubProducerAdapter
The pub-sub producer interface with which venice writer's interact to send messages to pub-sub topic.
An implementation of this interface are required to provide the following guarantees:
1. At-least once delivery (ALOD): messages should not be dropped.
2. In order delivery (IOD): messages in the same partition should follow the order in which they were sent.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose(long closeTimeOutMs) voidflush()it.unimi.dsi.fastutil.objects.Object2DoubleMap<String>intgetNumberOfPartitions(String topic) Deprecated.default CompletableFuture<PubSubProduceResult>sendMessage(PubSubTopicPartition pubSubTopicPartition, byte[] keyBytes, byte[] valueBytes, PubSubMessageHeaders pubSubMessageHeaders, PubSubProducerCallback pubSubProducerCallback) Sends a message to a PubSub topic asynchronously and returns aCompletableFuturerepresenting the result of the produce operation.sendMessage(String topic, Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders pubSubMessageHeaders, PubSubProducerCallback pubSubProducerCallback) Sends a message to a PubSub topic asynchronously and returns aFuturerepresenting the result of the produce operation.
-
Method Details
-
getNumberOfPartitions
Deprecated.The support for the following two getNumberOfPartitions APIs will be removed. -
sendMessage
CompletableFuture<PubSubProduceResult> sendMessage(String topic, Integer partition, KafkaKey key, KafkaMessageEnvelope value, PubSubMessageHeaders pubSubMessageHeaders, PubSubProducerCallback pubSubProducerCallback) Sends a message to a PubSub topic asynchronously and returns aFuturerepresenting the result of the produce operation.- Parameters:
topic- The name of the Kafka topic to which the message will be sent.partition- The partition to which the message should be sent.key- The key associated with the message, used for partitioning and message retrieval.value- The message payload to be sent to the PubSubTopic topic.pubSubMessageHeaders- Additional headers to be included with the message.pubSubProducerCallback- An optional callback to handle the result of the produce operation.- Returns:
- A
Futurerepresenting the result of the produce operation. - Throws:
PubSubOpTimeoutException- If the produce operation times out.PubSubTopicAuthorizationException- If there's an authorization error while producing the message.PubSubTopicDoesNotExistException- If the target topic does not exist.PubSubClientRetriableException- If a retriable error occurs while producing the message.PubSubClientException- If an error occurs while producing the message.
-
sendMessage
default CompletableFuture<PubSubProduceResult> sendMessage(PubSubTopicPartition pubSubTopicPartition, byte[] keyBytes, byte[] valueBytes, PubSubMessageHeaders pubSubMessageHeaders, PubSubProducerCallback pubSubProducerCallback) Sends a message to a PubSub topic asynchronously and returns aCompletableFuturerepresenting the result of the produce operation.- Parameters:
pubSubTopicPartition- The partition of the PubSub topic to which the message will be sent.keyBytes- The key associated with the message, used for partitioning and message retrieval, represented as a byte array.valueBytes- The message payload to be sent to the PubSub topic, represented as a byte array.pubSubMessageHeaders- Additional headers to be included with the message, encapsulated in aPubSubMessageHeadersobject.pubSubProducerCallback- An optional callback to handle the result of the produce operation, encapsulated in aPubSubProducerCallbackobject.- Returns:
- A
CompletableFuturerepresenting the result of the produce operation, encapsulated in aPubSubProduceResultobject. - Throws:
PubSubOpTimeoutException- If the produce operation times out.PubSubTopicAuthorizationException- If there's an authorization error while producing the message.PubSubTopicDoesNotExistException- If the target topic does not exist.PubSubClientRetriableException- If a retriable error occurs while producing the message.PubSubClientException- If an error occurs while producing the message.
-
flush
void flush() -
close
void close(long closeTimeOutMs) -
getMeasurableProducerMetrics
it.unimi.dsi.fastutil.objects.Object2DoubleMap<String> getMeasurableProducerMetrics() -
getBrokerAddress
String getBrokerAddress()
-