public class KafkaWriteStreamImpl<K,V> extends Object implements KafkaWriteStream<K,V>
DEFAULT_MAX_SIZE| Constructor and Description |
|---|
KafkaWriteStreamImpl(Context context,
org.apache.kafka.clients.producer.Producer<K,V> producer) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the stream
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close the stream
|
void |
close(long timeout,
Handler<AsyncResult<Void>> completionHandler)
Close the stream
|
static <K,V> KafkaWriteStreamImpl<K,V> |
create(Vertx vertx,
Map<String,Object> config)
Create a new KafkaWriteStream instance
|
static <K,V> KafkaWriteStreamImpl<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> KafkaWriteStreamImpl<K,V> |
create(Vertx vertx,
Properties config)
Create a new KafkaWriteStream instance
|
static <K,V> KafkaWriteStreamImpl<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
|
KafkaWriteStreamImpl<K,V> |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
Ends the stream.
|
void |
end(Handler<AsyncResult<Void>> handler)
Same as
WriteStream.end() but with an handler called when the operation completes |
KafkaWriteStreamImpl<K,V> |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the write stream.
|
KafkaWriteStreamImpl<K,V> |
flush(Handler<Void> completionHandler)
Invoking this method makes all buffered records immediately available to write
|
KafkaWriteStreamImpl<K,V> |
partitionsFor(String topic,
Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)
Get the partition metadata for the give topic.
|
KafkaWriteStream<K,V> |
send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
Asynchronously write a record to a topic
|
KafkaWriteStreamImpl<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
|
KafkaWriteStreamImpl<K,V> |
setWriteQueueMaxSize(int size)
Set the maximum size of the write queue to
maxSize. |
org.apache.kafka.clients.producer.Producer<K,V> |
unwrap() |
KafkaWriteStreamImpl<K,V> |
write(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
Write some data to the stream.
|
KafkaWriteStreamImpl<K,V> |
write(org.apache.kafka.clients.producer.ProducerRecord<K,V> data,
Handler<AsyncResult<Void>> handler)
Same as
#write(T) but with an handler called when the operation completes |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, create, createend, endpublic static <K,V> KafkaWriteStreamImpl<K,V> create(Vertx vertx, Properties config)
KafkaWriteStreamcreate in interface KafkaWriteStream<K,V>vertx - Vert.x instance to useconfig - Kafka producer configurationpublic static <K,V> KafkaWriteStreamImpl<K,V> create(Vertx vertx, Properties config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer)
KafkaWriteStreamcreate in interface KafkaWriteStream<K,V>vertx - Vert.x instance to useconfig - Kafka producer configurationkeySerializer - key serializervalueSerializer - value serializerpublic static <K,V> KafkaWriteStreamImpl<K,V> create(Vertx vertx, Map<String,Object> config)
KafkaWriteStreamcreate in interface KafkaWriteStream<K,V>vertx - Vert.x instance to useconfig - Kafka producer configurationpublic static <K,V> KafkaWriteStreamImpl<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)
KafkaWriteStreamcreate in interface KafkaWriteStream<K,V>vertx - Vert.x instance to useconfig - Kafka producer configurationkeySerializer - key serializervalueSerializer - value serializerpublic KafkaWriteStream<K,V> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
KafkaWriteStreamsend in interface KafkaWriteStream<K,V>record - record to writepublic KafkaWriteStreamImpl<K,V> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record, Handler<AsyncResult<org.apache.kafka.clients.producer.RecordMetadata>> handler)
KafkaWriteStreamsend in interface KafkaWriteStream<K,V>record - record to writehandler - handler called on operation completedpublic KafkaWriteStreamImpl<K,V> write(org.apache.kafka.clients.producer.ProducerRecord<K,V> data, Handler<AsyncResult<Void>> handler)
WriteStream#write(T) but with an handler called when the operation completeswrite in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>public KafkaWriteStreamImpl<K,V> write(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
WriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.write in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>record - the data to writepublic KafkaWriteStreamImpl<K,V> setWriteQueueMaxSize(int size)
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>>size - the max size of the write streampublic boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)writeQueueFull in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>public KafkaWriteStreamImpl<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 handlerpublic void end()
WriteStreamOnce the stream has ended, it cannot be used any more.
end in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>public void end(Handler<AsyncResult<Void>> handler)
WriteStreamWriteStream.end() but with an handler called when the operation completesend in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>public KafkaWriteStreamImpl<K,V> exceptionHandler(Handler<Throwable> handler)
WriteStreamexceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>handler - the exception handlerpublic KafkaWriteStreamImpl<K,V> partitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)
KafkaWriteStreampartitionsFor in interface KafkaWriteStream<K,V>topic - topic partition for which getting partitions infohandler - handler called on operation completedpublic KafkaWriteStreamImpl<K,V> flush(Handler<Void> completionHandler)
KafkaWriteStreamflush in interface KafkaWriteStream<K,V>completionHandler - handler called on operation completedpublic void close()
KafkaWriteStreamclose in interface KafkaWriteStream<K,V>public void close(Handler<AsyncResult<Void>> completionHandler)
KafkaWriteStreamclose in interface KafkaWriteStream<K,V>completionHandler - handler called on operation completedpublic void close(long timeout,
Handler<AsyncResult<Void>> completionHandler)
KafkaWriteStreamclose in interface KafkaWriteStream<K,V>timeout - timeout to wait for closingcompletionHandler - handler called on operation completedCopyright © 2020. All rights reserved.