Class KafkaProducer<K,V>
- All Implemented Interfaces:
MutinyDelegate,StreamBase,WriteStream<KafkaProducerRecord<K,V>>
The WriteStream.write(Object) provides global control over writing a record.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- See Also:
-
KafkaProducer
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImplNested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.WriteStream
WriteStream.WriteStreamImpl<T> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKafkaProducer(io.vertx.kafka.client.producer.KafkaProducer<K, V> delegate) Create a new instance ofKafkaProducerdelegating to the given (non-null) instance ofKafkaProducer.KafkaProducer(io.vertx.kafka.client.producer.KafkaProducer<K, V> delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1) -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void>Aborts the ongoing transaction.voidAborts the ongoing transaction.Aborts the ongoing transaction.io.smallrye.mutiny.Uni<Void>Starts a new kafka transaction.voidStarts a new kafka transaction.Starts a new kafka transaction.io.smallrye.mutiny.Uni<Void>close()Close the producerio.smallrye.mutiny.Uni<Void>close(long timeout) Close the producervoidClose the producervoidcloseAndAwait(long timeout) Close the producerClose the producercloseAndForget(long timeout) Close the producerio.smallrye.mutiny.Uni<Void>Commits the ongoing transaction.voidCommits the ongoing transaction.Commits 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 nativeProducer.static <K,V> KafkaProducer<K, V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer, io.vertx.kafka.client.common.KafkaClientOptions options) Create a new KafkaProducer instance from a nativeProducer.static <K,V> KafkaProducer<K, V> createShared(Vertx vertx, String name, io.vertx.kafka.client.common.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, io.vertx.kafka.client.common.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(Runnable handler) Set a drain handler on the stream.io.smallrye.mutiny.Uni<Void>end()Ends the stream.io.smallrye.mutiny.Uni<Void>end(KafkaProducerRecord<K, V> data) Same asend()but writes some data to the stream before ending.voidEnds the stream.voidendAndAwait(KafkaProducerRecord<K, V> data) Same asend()but writes some data to the stream before ending.Ends the stream.endAndForget(KafkaProducerRecord<K, V> data) Same asend()but writes some data to the stream before ending.booleanexceptionHandler(Consumer<Throwable> handler) Set an exception handler on the write stream.io.smallrye.mutiny.Uni<Void>flush()Invoking this method makes all buffered records immediately available to writevoidInvoking this method makes all buffered records immediately available to writeInvoking this method makes all buffered records immediately available to writeGet the delegate instance.inthashCode()io.smallrye.mutiny.Uni<Void>Initializes the underlying kafka transactional producer.voidInitializes the underlying kafka transactional producer.Initializes the underlying kafka transactional producer.static <K,V> KafkaProducer<K, V> newInstance(io.vertx.kafka.client.producer.KafkaProducer<K, V> delegate) Creates a new instance of theKafkaProducer.static <K,V> KafkaProducer<K, V> newInstance(io.vertx.kafka.client.producer.KafkaProducer<K, V> delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1) Creates a new instance of theKafkaProducer.io.smallrye.mutiny.Uni<List<io.vertx.kafka.client.common.PartitionInfo>>partitionsFor(String topic) Get the partition metadata for the give topic.List<io.vertx.kafka.client.common.PartitionInfo>partitionsForAndAwait(String topic) Get the partition metadata for the give topic.partitionsForAndForget(String topic) Get the partition metadata for the give topic.io.smallrye.mutiny.Uni<io.vertx.kafka.client.producer.RecordMetadata>send(KafkaProducerRecord<K, V> record) Asynchronously write a record to a topicio.vertx.kafka.client.producer.RecordMetadatasendAndAwait(KafkaProducerRecord<K, V> record) Asynchronously write a record to a topicsendAndForget(KafkaProducerRecord<K, V> record) Asynchronously write a record to a topicsetWriteQueueMaxSize(int i) Set the maximum size of the write queue tomaxSize.toString()Converts the current write stream to a subscriber.io.smallrye.mutiny.Uni<Void>write(KafkaProducerRecord<K, V> data) Write some data to the stream.voidwriteAndAwait(KafkaProducerRecord<K, V> data) Write some data to the stream.writeAndForget(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
Create a new instance ofKafkaProducerdelegating to the given (non-null) instance ofKafkaProducer. -
KafkaProducer
-
KafkaProducer
-
-
Method Details
-
getDelegate
Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<K>- Returns:
- the delegate instance
-
initTransactions
Initializes the underlying kafka transactional producer. SeeinitTransactions()()}Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.initTransactions()
-
initTransactionsAndAwait
public void initTransactionsAndAwait()Initializes the underlying kafka transactional producer. SeeinitTransactions()()}Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.initTransactions()
-
initTransactionsAndForget
Initializes the underlying kafka transactional producer. SeeinitTransactions()()}Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.initTransactions()
-
beginTransaction
Starts a new kafka transaction. SeebeginTransaction()Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.beginTransaction()
-
beginTransactionAndAwait
public void beginTransactionAndAwait()Starts a new kafka transaction. SeebeginTransaction()Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.beginTransaction()
-
beginTransactionAndForget
Starts a new kafka transaction. SeebeginTransaction()Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.beginTransaction()
-
commitTransaction
Commits the ongoing transaction. SeecommitTransaction()Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.commitTransaction()
-
commitTransactionAndAwait
public void commitTransactionAndAwait()Commits the ongoing transaction. SeecommitTransaction()Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.commitTransaction()
-
commitTransactionAndForget
Commits the ongoing transaction. SeecommitTransaction()Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.commitTransaction()
-
abortTransaction
Aborts the ongoing transaction. SeeKafkaProducer.abortTransaction()Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.abortTransaction()
-
abortTransactionAndAwait
public void abortTransactionAndAwait()Aborts the ongoing transaction. SeeKafkaProducer.abortTransaction()Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.abortTransaction()
-
abortTransactionAndForget
Aborts the ongoing transaction. SeeKafkaProducer.abortTransaction()Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.abortTransaction()
-
send
@CheckReturnValue public io.smallrye.mutiny.Uni<io.vertx.kafka.client.producer.RecordMetadata> send(KafkaProducerRecord<K, V> record) Asynchronously write a record to a topicUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
record- record to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.kafka.client.producer.KafkaProducer#send(KafkaProducerRecord)
-
sendAndAwait
Asynchronously write a record to a topicUnlike the bare Vert.x variant, this method returns a
RecordMetadata. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
record- record to write- Returns:
- The operation result
- See Also:
-
io.vertx.kafka.client.producer.KafkaProducer#send(KafkaProducerRecord)
-
sendAndForget
Asynchronously write a record to a topicUnlike the bare Vert.x variant, this method ignores the
RecordMetadataresult or any failure.- Parameters:
record- record to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
io.vertx.kafka.client.producer.KafkaProducer#send(KafkaProducerRecord)
-
partitionsFor
@CheckReturnValue public io.smallrye.mutiny.Uni<List<io.vertx.kafka.client.common.PartitionInfo>> partitionsFor(String topic) Get the partition metadata for the give topic.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
topic- topic partition for which getting partitions info- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.partitionsFor(String)
-
partitionsForAndAwait
Get the partition metadata for the give topic.Unlike the bare Vert.x variant, this method returns a
List<io.vertx.kafka.client.common.PartitionInfo>. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
topic- topic partition for which getting partitions info- Returns:
- The operation result
- See Also:
-
KafkaProducer.partitionsFor(String)
-
partitionsForAndForget
Get the partition metadata for the give topic.Unlike the bare Vert.x variant, this method ignores the
List<io.vertx.kafka.client.common.PartitionInfo>result or any failure.- Parameters:
topic- topic partition for which getting partitions info- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.partitionsFor(String)
-
flush
Invoking this method makes all buffered records immediately available to writeUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.flush()
-
flushAndAwait
public void flushAndAwait()Invoking this method makes all buffered records immediately available to writeUnlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.flush()
-
flushAndForget
Invoking this method makes all buffered records immediately available to writeUnlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.flush()
-
close
Close the producerUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.close()
-
closeAndAwait
public void closeAndAwait()Close the producerUnlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.close()
-
closeAndForget
Close the producerUnlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.close()
-
close
Close the producerUnlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
KafkaProducer.close(long)
-
closeAndAwait
public void closeAndAwait(long timeout) Close the producerUnlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
KafkaProducer.close(long)
-
closeAndForget
Close the producerUnlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
KafkaProducer.close(long)
-
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
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the uni 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.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
writein interfaceWriteStream<K>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.write(T)
-
writeAndAwait
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
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the underlying uni 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.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
data- the data to write- See Also:
-
WriteStream.write(T)
-
writeAndForget
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
writeQueueFull()method before writing. This is done automatically if using aPipe.When the
datais moved from the queue to the actual medium, the returnedFuturewill be completed with the write result, e.g the underlying uni 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.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.write(T)
-
end
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
endin interfaceWriteStream<K>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end(T)
-
endAndAwait
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
data- the data to write- See Also:
-
WriteStream.end(T)
-
endAndForget
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.end(T)
-
end
Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
endin interfaceWriteStream<K>- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end()
-
endAndAwait
public void endAndAwait()Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
WriteStream.end()
-
endAndForget
Ends the stream.Once the stream has ended, it cannot be used any more.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.end()
-
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 nativeProducer.- 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, io.vertx.kafka.client.common.KafkaClientOptions options) Create a new KafkaProducer instance from a nativeProducer.- Parameters:
vertx- Vert.x instance to useproducer- the Kafka producer to wrapoptions- options used only for tracing settings- Returns:
- an instance of the KafkaProducer
-
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
-
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. Can benull.- 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. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
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
-
newInstance
public static <K,V> KafkaProducer<K,V> newInstance(io.vertx.kafka.client.producer.KafkaProducer<K, V> delegate) Creates a new instance of theKafkaProducer. -
newInstance
public static <K,V> KafkaProducer<K,V> newInstance(io.vertx.kafka.client.producer.KafkaProducer<K, V> delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1) Creates a new instance of theKafkaProducer. -
hashCode
public int hashCode() -
equals
-
toString
-
toSubscriber
Converts the current write stream to a subscriber.
-