Package io.vertx.kafka.client.producer
Interface KafkaWriteStream<K,V>
- All Superinterfaces:
io.vertx.core.streams.StreamBase,io.vertx.core.streams.WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>
public interface KafkaWriteStream<K,V>
extends io.vertx.core.streams.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 TypeMethodDescriptionio.vertx.core.Future<Void>LikeabortTransaction(Handler)but with a future of the resultabortTransaction(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Aborts the ongoing transaction.io.vertx.core.Future<Void>LikebeginTransaction(Handler)but with a future of the resultbeginTransaction(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Starts a new kafka transaction.io.vertx.core.Future<Void>close()Close the streamio.vertx.core.Future<Void>close(long timeout) Likeclose(long, Handler)but returns aFutureof the asynchronous resultvoidClose the streamvoidClose the streamio.vertx.core.Future<Void>LikecommitTransaction(Handler)but with a future of the resultcommitTransaction(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Commits the ongoing transaction.static <K,V> KafkaWriteStream<K, V> create(io.vertx.core.Vertx vertx, KafkaClientOptions options) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(io.vertx.core.Vertx vertx, KafkaClientOptions options, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(io.vertx.core.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(io.vertx.core.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(io.vertx.core.Vertx vertx, Properties config) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(io.vertx.core.Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(io.vertx.core.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(io.vertx.core.Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer) Create a new KafkaWriteStream instancestatic <K,V> KafkaWriteStream<K, V> create(io.vertx.core.Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer, KafkaClientOptions options) Create a new KafkaWriteStream instance.drainHandler(io.vertx.core.Handler<Void> handler) exceptionHandler(io.vertx.core.Handler<Throwable> handler) io.vertx.core.Future<Void>flush()Likeflush(Handler)but returns aFutureof the asynchronous resultInvoking this method makes all buffered records immediately available to writeio.vertx.core.Future<Void>LikeinitTransactions(Handler)but with a future of the resultinitTransactions(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Initializes the underlying kafka transactional producer.io.vertx.core.Future<List<org.apache.kafka.common.PartitionInfo>>partitionsFor(String topic) LikepartitionsFor(String, Handler)but returns aFutureof the asynchronous resultpartitionsFor(String topic, io.vertx.core.Handler<io.vertx.core.AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler) Get the partition metadata for the give topic.io.vertx.core.Future<org.apache.kafka.clients.producer.RecordMetadata>Asynchronously write a record to a topicsend(org.apache.kafka.clients.producer.ProducerRecord<K, V> record, io.vertx.core.Handler<io.vertx.core.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(io.vertx.core.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(io.vertx.core.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(io.vertx.core.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(io.vertx.core.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(io.vertx.core.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(io.vertx.core.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(io.vertx.core.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(io.vertx.core.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 interfaceio.vertx.core.streams.StreamBase- Specified by:
exceptionHandlerin interfaceio.vertx.core.streams.WriteStream<K>
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSizein interfaceio.vertx.core.streams.WriteStream<K>
-
drainHandler
- Specified by:
drainHandlerin interfaceio.vertx.core.streams.WriteStream<K>
-
initTransactions
KafkaWriteStream<K,V> initTransactions(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Initializes the underlying kafka transactional producer. SeeKafkaProducer.initTransactions()()}- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
initTransactions
io.vertx.core.Future<Void> initTransactions()LikeinitTransactions(Handler)but with a future of the result -
beginTransaction
KafkaWriteStream<K,V> beginTransaction(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Starts a new kafka transaction. SeeKafkaProducer.beginTransaction()- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
beginTransaction
io.vertx.core.Future<Void> beginTransaction()LikebeginTransaction(Handler)but with a future of the result -
commitTransaction
KafkaWriteStream<K,V> commitTransaction(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Commits the ongoing transaction. SeeKafkaProducer.commitTransaction()- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
commitTransaction
io.vertx.core.Future<Void> commitTransaction()LikecommitTransaction(Handler)but with a future of the result -
abortTransaction
KafkaWriteStream<K,V> abortTransaction(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler) Aborts the ongoing transaction. SeeKafkaProducer.abortTransaction()- Parameters:
handler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
abortTransaction
io.vertx.core.Future<Void> abortTransaction()LikeabortTransaction(Handler)but with a future of the result -
send
io.vertx.core.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, io.vertx.core.Handler<io.vertx.core.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, io.vertx.core.Handler<io.vertx.core.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
KafkaWriteStream<K,V> flush(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> completionHandler) Invoking this method makes all buffered records immediately available to write- Parameters:
completionHandler- handler called on operation completed- Returns:
- current KafkaWriteStream instance
-
flush
io.vertx.core.Future<Void> flush()Likeflush(Handler)but returns aFutureof the asynchronous result -
close
io.vertx.core.Future<Void> 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
-