public interface KafkaWriteStream<K,V> extends WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>
WriteStream for writing to Kafka ProducerRecord.
The WriteStream.write(Object) provides global control over writing a record.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_SIZE |
| Modifier and Type | Method and Description |
|---|---|
KafkaWriteStream<K,V> |
abortTransaction(Handler<AsyncResult<Void>> handler)
Aborts the ongoing transaction.
|
KafkaWriteStream<K,V> |
beginTransaction(Handler<AsyncResult<Void>> handler)
Starts a new kafka transaction.
|
Future<Void> |
close()
Close the stream
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close the stream
|
Future<Void> |
close(long timeout)
Like
close(long, Handler) but returns a Future of the asynchronous result |
void |
close(long timeout,
Handler<AsyncResult<Void>> completionHandler)
Close the stream
|
KafkaWriteStream<K,V> |
commitTransaction(Handler<AsyncResult<Void>> handler)
Commits the ongoing transaction.
|
static <K,V> KafkaWriteStream<K,V> |
create(Vertx vertx,
Map<String,Object> config)
Create a new KafkaWriteStream instance
|
static <K,V> KafkaWriteStream<K,V> |
create(Vertx vertx,
Map<String,Object> config,
Class<K> keyType,
Class<V> valueType)
Create a new KafkaWriteStream instance
|
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
|
static <K,V> KafkaWriteStream<K,V> |
create(Vertx vertx,
org.apache.kafka.clients.producer.Producer<K,V> producer)
Create a new KafkaWriteStream instance
|
static <K,V> KafkaWriteStream<K,V> |
create(Vertx vertx,
Properties config)
Create a new KafkaWriteStream instance
|
static <K,V> KafkaWriteStream<K,V> |
create(Vertx vertx,
Properties config,
Class<K> keyType,
Class<V> valueType)
Create a new KafkaWriteStream instance
|
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
|
KafkaWriteStream<K,V> |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
KafkaWriteStream<K,V> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
Future<Void> |
flush()
Like
flush(Handler) but returns a Future of the asynchronous result |
KafkaWriteStream<K,V> |
flush(Handler<AsyncResult<Void>> completionHandler)
Invoking this method makes all buffered records immediately available to write
|
KafkaWriteStream<K,V> |
initTransactions(Handler<AsyncResult<Void>> handler)
Initializes the underlying kafka transactional producer.
|
Future<List<org.apache.kafka.common.PartitionInfo>> |
partitionsFor(String topic)
Like
partitionsFor(String, Handler) but returns a Future of the asynchronous result |
KafkaWriteStream<K,V> |
partitionsFor(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> |
send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
Asynchronously write a record to a topic
|
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
|
KafkaWriteStream<K,V> |
setWriteQueueMaxSize(int i)
Set the maximum size of the write queue to
maxSize. |
org.apache.kafka.clients.producer.Producer<K,V> |
unwrap() |
end, end, end, end, write, write, writeQueueFullstatic final int DEFAULT_MAX_SIZE
static <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Properties config)
vertx - Vert.x instance to useconfig - Kafka producer configurationstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType)
vertx - Vert.x instance to useconfig - Kafka producer configurationkeyType - class type for the key serializationvalueType - class type for the value serializationstatic <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)
vertx - Vert.x instance to useconfig - Kafka producer configurationkeySerializer - key serializervalueSerializer - value serializerstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Map<String,Object> config)
vertx - Vert.x instance to useconfig - Kafka producer configurationstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Map<String,Object> config, Class<K> keyType, Class<V> valueType)
vertx - Vert.x instance to useconfig - Kafka producer configurationkeyType - class type for the key serializationvalueType - class type for the value serializationstatic <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)
vertx - Vert.x instance to useconfig - Kafka producer configurationkeySerializer - key serializervalueSerializer - value serializerstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K,V> producer)
vertx - Vert.x instance to useproducer - native Kafka producer instanceKafkaWriteStream<K,V> exceptionHandler(Handler<Throwable> handler)
WriteStreamexceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>handler - the exception handlerKafkaWriteStream<K,V> setWriteQueueMaxSize(int i)
WriteStreammaxSize. You will still be able to write to the stream even
if there is more than maxSize items in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket, the number of Message for a
MessageProducer, etc...setWriteQueueMaxSize in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>i - the max size of the write streamKafkaWriteStream<K,V> drainHandler(Handler<Void> handler)
WriteStreamPump for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been
reduced to maxSize / 2.drainHandler in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>handler - the handlerKafkaWriteStream<K,V> initTransactions(Handler<AsyncResult<Void>> handler)
KafkaProducer#initTransactions() ()}handler - handler called on operation completedKafkaWriteStream<K,V> beginTransaction(Handler<AsyncResult<Void>> handler)
KafkaProducer#beginTransaction()handler - handler called on operation completedKafkaWriteStream<K,V> commitTransaction(Handler<AsyncResult<Void>> handler)
KafkaProducer#commitTransaction()handler - handler called on operation completedKafkaWriteStream<K,V> abortTransaction(Handler<AsyncResult<Void>> handler)
KafkaProducer.abortTransaction()handler - handler called on operation completedFuture<org.apache.kafka.clients.producer.RecordMetadata> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
record - record to writeFuture completed with the record metadataKafkaWriteStream<K,V> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record, Handler<AsyncResult<org.apache.kafka.clients.producer.RecordMetadata>> handler)
record - record to writehandler - handler called on operation completedKafkaWriteStream<K,V> partitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)
topic - topic partition for which getting partitions infohandler - handler called on operation completedFuture<List<org.apache.kafka.common.PartitionInfo>> partitionsFor(String topic)
partitionsFor(String, Handler) but returns a Future of the asynchronous resultKafkaWriteStream<K,V> flush(Handler<AsyncResult<Void>> completionHandler)
completionHandler - handler called on operation completedFuture<Void> flush()
flush(Handler) but returns a Future of the asynchronous resultvoid close(Handler<AsyncResult<Void>> completionHandler)
completionHandler - handler called on operation completedvoid close(long timeout,
Handler<AsyncResult<Void>> completionHandler)
timeout - timeout to wait for closingcompletionHandler - handler called on operation completedFuture<Void> close(long timeout)
close(long, Handler) but returns a Future of the asynchronous resultCopyright © 2020 Eclipse. All rights reserved.