Package io.vertx.kafka.client.producer
Interface KafkaWriteStream<K,V>
- All Superinterfaces:
StreamBase,WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>
public interface KafkaWriteStream<K,V>
extends WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>
A
WriteStream for writing to Kafka ProducerRecord.
The WriteStream.write(Object) provides global control over writing a record.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionLikeabortTransaction(Handler)but with a future of the resultabortTransaction(Handler<AsyncResult<Void>> handler) Aborts the ongoing transaction.LikebeginTransaction(Handler)but with a future of the resultbeginTransaction(Handler<AsyncResult<Void>> handler) Starts a new kafka transaction.close()Close the streamclose(long timeout) Likeclose(long, Handler)but returns aFutureof the asynchronous resultvoidclose(long timeout, Handler<AsyncResult<Void>> completionHandler) Close the streamvoidclose(Handler<AsyncResult<Void>> completionHandler) Close the streamLikecommitTransaction(Handler)but with a future of the resultcommitTransaction(Handler<AsyncResult<Void>> handler) Commits the ongoing transaction.static <K,V> KafkaWriteStream<K, V> create(Vertx vertx, KafkaClientOptions options) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, KafkaClientOptions options, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, KafkaClientOptions options, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, Map<String, Object> config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, Properties config) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, Properties config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer, KafkaClientOptions options) Create a new KafkaWriteStream instance.drainHandler(Handler<Void> handler) exceptionHandler(Handler<Throwable> handler) flush()Likeflush(Handler)but returns aFutureof the asynchronous resultflush(Handler<AsyncResult<Void>> completionHandler) Invoking this method makes all buffered records immediately available to writeLikeinitTransactions(Handler)but with a future of the resultinitTransactions(Handler<AsyncResult<Void>> handler) Initializes the underlying kafka transactional producer.partitionsFor(String topic) LikepartitionsFor(String, Handler)but returns aFutureof the asynchronous resultpartitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler) Get the partition metadata for the give topic.Future<org.apache.kafka.clients.producer.RecordMetadata>Asynchronously write a record to a topicsend(org.apache.kafka.clients.producer.ProducerRecord<K, V> record, Handler<AsyncResult<org.apache.kafka.clients.producer.RecordMetadata>> handler) Asynchronously write a record to a topicsetWriteQueueMaxSize(int i) unwrap()Methods inherited from interface io.vertx.core.streams.WriteStream
end, end, end, end, write, write, writeQueueFull
-
Field Details
-
DEFAULT_MAX_SIZE
static final int DEFAULT_MAX_SIZE- See Also:
-
-
Method Details
-
create
Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configuration- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configurationkeyType- class type for the key serializationvalueType- class type for the value serialization- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Properties config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configurationkeySerializer- key serializervalueSerializer- value serializer- Returns:
- an instance of the KafkaWriteStream
-
create
Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configuration- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Map<String, Object> config, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configurationkeyType- class type for the key serializationvalueType- class type for the value serialization- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Map<String, Object> config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configurationkeySerializer- key serializervalueSerializer- value serializer- Returns:
- an instance of the KafkaWriteStream
-
create
Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useoptions- Kafka producer options- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, KafkaClientOptions options, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useoptions- Kafka producer optionskeyType- class type for the key serializationvalueType- class type for the value serialization- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, KafkaClientOptions options, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useoptions- Kafka producer optionskeySerializer- key serializervalueSerializer- value serializer- Returns:
- an instance of the KafkaWriteStream
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer) Create a new KafkaWriteStream instance- Parameters:
vertx- Vert.x instance to useproducer- native Kafka producer instance
-
create
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer, KafkaClientOptions options) Create a new KafkaWriteStream instance.- Parameters:
vertx- Vert.x instance to useproducer- native Kafka producer instanceoptions- options used only for tracing settings
-
exceptionHandler
- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<K>
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<K>
-
drainHandler
- Specified by:
drainHandlerin interfaceWriteStream<K>
-
initTransactions
Initializes the underlying kafka transactional producer. SeeKafkaProducer.initTransactions()()}- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
initTransactions
LikeinitTransactions(Handler)but with a future of the result -
beginTransaction
Starts a new kafka transaction. SeeKafkaProducer.beginTransaction()- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
beginTransaction
LikebeginTransaction(Handler)but with a future of the result -
commitTransaction
Commits the ongoing transaction. SeeKafkaProducer.commitTransaction()- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
commitTransaction
LikecommitTransaction(Handler)but with a future of the result -
abortTransaction
Aborts the ongoing transaction. SeeKafkaProducer.abortTransaction()- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
abortTransaction
LikeabortTransaction(Handler)but with a future of the result -
send
Future<org.apache.kafka.clients.producer.RecordMetadata> send(org.apache.kafka.clients.producer.ProducerRecord<K, V> record) Asynchronously write a record to a topic- Parameters:
record- record to write- Returns:
- a
Futurecompleted with the record metadata
-
send
KafkaWriteStream<K,V> send(org.apache.kafka.clients.producer.ProducerRecord<K, V> record, Handler<AsyncResult<org.apache.kafka.clients.producer.RecordMetadata>> handler) Asynchronously write a record to a topic- Parameters:
record- record to writehandler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
partitionsFor
KafkaWriteStream<K,V> partitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler) Get the partition metadata for the give topic.- Parameters:
topic- topic partition for which getting partitions infohandler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
partitionsFor
LikepartitionsFor(String, Handler)but returns aFutureof the asynchronous result -
flush
Invoking this method makes all buffered records immediately available to write- Parameters:
completionHandler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
flush
Likeflush(Handler)but returns aFutureof the asynchronous result -
close
Close the stream -
close
Close the stream- Parameters:
completionHandler- handler called on operation completed
-
close
Close the stream- Parameters:
timeout- timeout to wait for closingcompletionHandler- handler called on operation completed
-
close
Likeclose(long, Handler)but returns aFutureof the asynchronous result -
unwrap
- Returns:
- the underlying producer
-