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>> AWriteStreamfor writing to KafkaProducerRecord.The WriteStream.write(Object)provides global control over writing a record.
- 
- 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_MAX_SIZE
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Future<Void>abortTransaction()Aborts the ongoing transaction.Future<Void>beginTransaction()Starts a new kafka transaction.Future<Void>close()Close the streamFuture<Void>close(long timeout)Close the streamFuture<Void>commitTransaction()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(Vertx vertx, Map<String,Object> config)Create a new KafkaWriteStream instancestatic <K,V>
 KafkaWriteStream<K,V>create(Vertx vertx, Map<String,Object> config, Class<K> keyType, Class<V> valueType)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(Vertx vertx, org.apache.kafka.clients.producer.Producer<K,V> producer)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.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()Invoking this method makes all buffered records immediately available to writeFuture<Void>initTransactions()Initializes the underlying kafka transactional producer.Future<List<org.apache.kafka.common.PartitionInfo>>partitionsFor(String topic)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 topicKafkaWriteStream<K,V>setWriteQueueMaxSize(int i)Set the maximum size of the write queue tomaxSize.org.apache.kafka.clients.producer.Producer<K,V>unwrap()- 
Methods inherited from interface io.vertx.core.streams.WriteStreamend, end, write, writeQueueFull
 
- 
 
- 
- 
- 
Field Detail- 
DEFAULT_MAX_SIZEstatic final int DEFAULT_MAX_SIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
createstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Properties config) Create a new KafkaWriteStream instance- Parameters:
- vertx- Vert.x instance to use
- config- Kafka producer configuration
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- config- Kafka producer configuration
- keyType- class type for the key serialization
- valueType- class type for the value serialization
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- config- Kafka producer configuration
- keySerializer- key serializer
- valueSerializer- value serializer
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, Map<String,Object> config) Create a new KafkaWriteStream instance- Parameters:
- vertx- Vert.x instance to use
- config- Kafka producer configuration
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- config- Kafka producer configuration
- keyType- class type for the key serialization
- valueType- class type for the value serialization
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- config- Kafka producer configuration
- keySerializer- key serializer
- valueSerializer- value serializer
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <K,V> KafkaWriteStream<K,V> create(Vertx vertx, KafkaClientOptions options) Create a new KafkaWriteStream instance- Parameters:
- vertx- Vert.x instance to use
- options- Kafka producer options
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- options- Kafka producer options
- keyType- class type for the key serialization
- valueType- class type for the value serialization
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- options- Kafka producer options
- keySerializer- key serializer
- valueSerializer- value serializer
- Returns:
- an instance of the KafkaWriteStream
 
 - 
createstatic <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 use
- producer- native Kafka producer instance
 
 - 
createstatic <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 use
- producer- native Kafka producer instance
- options- options used only for tracing settings
 
 - 
exceptionHandlerKafkaWriteStream<K,V> exceptionHandler(Handler<Throwable> handler) Description copied from interface:WriteStreamSet an exception handler on the write stream.- Specified by:
- exceptionHandlerin interface- StreamBase
- Specified by:
- exceptionHandlerin interface- WriteStream<K>
- Parameters:
- handler- the exception handler
- Returns:
- a reference to this, so the API can be used fluently
 
 - 
setWriteQueueMaxSizeKafkaWriteStream<K,V> setWriteQueueMaxSize(int i) Description copied from interface:WriteStreamSet the maximum size of the write queue tomaxSize. You will still be able to write to the stream even if there is more thanmaxSizeitems in the write queue. This is used as an indicator by classes such asPipeto provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket, etc...- Specified by:
- setWriteQueueMaxSizein interface- WriteStream<K>
- Parameters:
- i- the max size of the write stream
- Returns:
- a reference to this, so the API can be used fluently
 
 - 
drainHandlerKafkaWriteStream<K,V> drainHandler(Handler<Void> handler) Description copied from interface:WriteStreamSet a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. SeePipefor 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.- Specified by:
- drainHandlerin interface- WriteStream<K>
- Parameters:
- handler- the handler
- Returns:
- a reference to this, so the API can be used fluently
 
 - 
initTransactionsFuture<Void> initTransactions() Initializes the underlying kafka transactional producer. SeeKafkaProducer.initTransactions()()}- Returns:
- a future notified with the result
 
 - 
beginTransactionFuture<Void> beginTransaction() Starts a new kafka transaction. SeeKafkaProducer.beginTransaction()- Returns:
- a future notified with the result
 
 - 
commitTransactionFuture<Void> commitTransaction() Commits the ongoing transaction. SeeKafkaProducer.commitTransaction()- Returns:
- a future notified with the result
 
 - 
abortTransactionFuture<Void> abortTransaction() Aborts the ongoing transaction. SeeKafkaProducer.abortTransaction()- Returns:
- a future notified with the result
 
 - 
sendFuture<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
 
 - 
partitionsForFuture<List<org.apache.kafka.common.PartitionInfo>> partitionsFor(String topic) Get the partition metadata for the give topic.- Parameters:
- topic- topic partition for which getting partitions info
- Returns:
- a future notified with the result
 
 - 
flushFuture<Void> flush() Invoking this method makes all buffered records immediately available to write- Returns:
- a future notified with the result
 
 - 
closeFuture<Void> close(long timeout) Close the stream- Parameters:
- timeout- timeout to wait for closing
- Returns:
- a future notified with the result
 
 
- 
 
-