Class KafkaProducer<K,V>
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate, StreamBase, WriteStream<KafkaProducerRecord<K,V>>
The WriteStream.write(T) provides global control over writing a record.
NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.vertx.lang.rx.TypeArg<KafkaProducer> final io.vertx.lang.rx.TypeArg<K> final io.vertx.lang.rx.TypeArg<V> -
Constructor Summary
ConstructorsConstructorDescriptionKafkaProducer(KafkaProducer delegate) KafkaProducer(Object delegate, io.vertx.lang.rx.TypeArg<K> typeArg_0, io.vertx.lang.rx.TypeArg<V> typeArg_1) -
Method Summary
Modifier and TypeMethodDescriptionAborts the ongoing transaction.Starts a new kafka transaction.close()Close the producerclose(long timeout) Close the producerCommits the ongoing transaction.static <K,V> KafkaProducer <K, V> Create a new KafkaProducer instancestatic <K,V> KafkaProducer <K, V> Create a new KafkaProducer instancestatic <K,V> KafkaProducer <K, V> Create a new KafkaProducer instance from a native .static <K,V> KafkaProducer <K, V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer, KafkaClientOptions options) Create a new KafkaProducer instance from a native .static <K,V> KafkaProducer <K, V> createShared(Vertx vertx, String name, KafkaClientOptions options) Get or create a KafkaProducer instance which shares its stream with any other KafkaProducer created with the samenamestatic <K,V> KafkaProducer <K, V> createShared(Vertx vertx, String name, KafkaClientOptions options, Class<K> keyType, Class<V> valueType) Get or create a KafkaProducer instance which shares its stream with any other KafkaProducer created with the samenamestatic <K,V> KafkaProducer <K, V> Get or create a KafkaProducer instance which shares its stream with any other KafkaProducer created with the samenamestatic <K,V> KafkaProducer <K, V> createShared(Vertx vertx, String name, Map<String, String> config, Class<K> keyType, Class<V> valueType) Get or create a KafkaProducer instance which shares its stream with any other KafkaProducer created with the samenamedrainHandler(Handler<Void> handler) Set a drain handler on the stream.end()Ends the stream.end(KafkaProducerRecord<K, V> data) Same asWriteStream.end()but writes some data to the stream before ending.booleanexceptionHandler(Handler<Throwable> handler) Set an exception handler on the write stream.flush()Invoking this method makes all buffered records immediately available to writeinthashCode()Initializes the underlying kafka transactional producer.static <K,V> KafkaProducer <K, V> newInstance(KafkaProducer arg) static <K,V> KafkaProducer <K, V> newInstance(KafkaProducer arg, io.vertx.lang.rx.TypeArg<K> __typeArg_K, io.vertx.lang.rx.TypeArg<V> __typeArg_V) partitionsFor(String topic) Get the partition metadata for the give topic.Aborts the ongoing transaction.Starts a new kafka transaction.rxClose()Close the producerrxClose(long timeout) Close the producerCommits the ongoing transaction.rxEnd()Ends the stream.rxEnd(KafkaProducerRecord<K, V> data) Same asWriteStream.end()but writes some data to the stream before ending.rxFlush()Invoking this method makes all buffered records immediately available to writeInitializes the underlying kafka transactional producer.rxPartitionsFor(String topic) Get the partition metadata for the give topic.rxSend(KafkaProducerRecord<K, V> record) Asynchronously write a record to a topicrxWrite(KafkaProducerRecord<K, V> data) Write some data to the stream.send(KafkaProducerRecord<K, V> record) Asynchronously write a record to a topicsetWriteQueueMaxSize(int i) Set the maximum size of the write queue tomaxSize.toString()write(KafkaProducerRecord<K, V> data) Write some data to the stream.booleanThis will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
Field Details
-
__TYPE_ARG
-
__typeArg_0
-
__typeArg_1
-
-
Constructor Details
-
KafkaProducer
-
KafkaProducer
-
-
Method Details
-
toString
-
equals
-
hashCode
-
getDelegate
- Specified by:
getDelegatein interfaceio.vertx.lang.rx.RxDelegate- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<K>
-
toObserver
- Specified by:
toObserverin interfaceWriteStream<K>
-
toSubscriber
- Specified by:
toSubscriberin interfaceWriteStream<K>
-
write
Write some data to the stream.The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the
WriteStream.writeQueueFull()method before writing. This is done automatically if using a .When the
datais moved from the queue to the actual medium, the returned will be completed with the write result, e.g the future is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.- Specified by:
writein interfaceWriteStream<K>- Parameters:
data- the data to write- Returns:
- a future completed with the write result
-
rxWrite
Write some data to the stream.The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the
WriteStream.writeQueueFull()method before writing. This is done automatically if using a .When the
datais moved from the queue to the actual medium, the returned will be completed with the write result, e.g the future is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.- Specified by:
rxWritein interfaceWriteStream<K>- Parameters:
data- the data to write- Returns:
- a future completed with the write result
-
end
Ends the stream.Once the stream has ended, it cannot be used any more.
- Specified by:
endin interfaceWriteStream<K>- Returns:
- a future completed with the result
-
rxEnd
Ends the stream.Once the stream has ended, it cannot be used any more.
- Specified by:
rxEndin interfaceWriteStream<K>- Returns:
- a future completed with the result
-
end
Same asWriteStream.end()but writes some data to the stream before ending.- Specified by:
endin interfaceWriteStream<K>- Parameters:
data- the data to write- Returns:
- a future completed with the result
-
rxEnd
Same asWriteStream.end()but writes some data to the stream before ending.- Specified by:
rxEndin interfaceWriteStream<K>- Parameters:
data- the data to write- Returns:
- a future completed with the result
-
writeQueueFull
public boolean writeQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)- Specified by:
writeQueueFullin interfaceWriteStream<K>- Returns:
trueif write queue is full
-
create
Create a new KafkaProducer instance- Parameters:
vertx- Vert.x instance to useconfig- Kafka producer configuration- Returns:
- an instance of the KafkaProducer
-
create
public static <K,V> KafkaProducer<K,V> create(Vertx vertx, Map<String, String> config, Class<K> keyType, Class<V> valueType) Create a new KafkaProducer 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 KafkaProducer
-
initTransactions
Initializes the underlying kafka transactional producer. SeeinitTransactions()()}- Returns:
- a future notified with the result
-
rxInitTransactions
Initializes the underlying kafka transactional producer. SeeinitTransactions()()}- Returns:
- a future notified with the result
-
beginTransaction
Starts a new kafka transaction. SeebeginTransaction()- Returns:
- a future notified with the result
-
rxBeginTransaction
Starts a new kafka transaction. SeebeginTransaction()- Returns:
- a future notified with the result
-
commitTransaction
Commits the ongoing transaction. SeecommitTransaction()- Returns:
- a future notified with the result
-
rxCommitTransaction
Commits the ongoing transaction. SeecommitTransaction()- Returns:
- a future notified with the result
-
abortTransaction
-
rxAbortTransaction
Aborts the ongoing transaction. SeeKafkaProducer- Returns:
- a future notified with the result
-
exceptionHandler
Description copied from interface:WriteStreamSet an exception handler on the write stream.- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<K>- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
setWriteQueueMaxSize
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 interfaceWriteStream<K>- Parameters:
i- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
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 interfaceWriteStream<K>- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
send
Asynchronously write a record to a topic- Parameters:
record- record to write- Returns:
- a
Futurecompleted with the record metadata
-
rxSend
Asynchronously write a record to a topic- Parameters:
record- record to write- Returns:
- a
Futurecompleted with the record metadata
-
partitionsFor
Get the partition metadata for the give topic.- Parameters:
topic- topic partition for which getting partitions info- Returns:
- a future notified with the result
-
rxPartitionsFor
Get the partition metadata for the give topic.- Parameters:
topic- topic partition for which getting partitions info- Returns:
- a future notified with the result
-
flush
-
rxFlush
Invoking this method makes all buffered records immediately available to write- Returns:
- a future notified with the result
-
close
-
rxClose
Close the producer- Returns:
- a
Futurecompleted with the operation result
-
close
-
rxClose
Close the producer- Parameters:
timeout-- Returns:
- a future notified with the result
-
create
public static <K,V> KafkaProducer<K,V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer) Create a new KafkaProducer instance from a native .- Parameters:
vertx- Vert.x instance to useproducer- the Kafka producer to wrap- Returns:
- an instance of the KafkaProducer
-
create
public static <K,V> KafkaProducer<K,V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer, KafkaClientOptions options) Create a new KafkaProducer instance from a native .- Parameters:
vertx- Vert.x instance to useproducer- the Kafka producer to wrapoptions- options used only for tracing settings- Returns:
- an instance of the KafkaProducer
-
newInstance
-
newInstance
public static <K,V> KafkaProducer<K,V> newInstance(KafkaProducer arg, io.vertx.lang.rx.TypeArg<K> __typeArg_K, io.vertx.lang.rx.TypeArg<V> __typeArg_V)
-