Class KafkaProducer<K,V>
- All Implemented Interfaces:
MutinyDelegate
,StreamBase
,WriteStream<KafkaProducerRecord<K,
V>>
The WriteStream.write(T)
provides global control over writing a record.
original
non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKafkaProducer
(io.vertx.kafka.client.producer.KafkaProducer delegate) KafkaProducer
(io.vertx.kafka.client.producer.KafkaProducer delegate, TypeArg<K> typeArg_0, TypeArg<V> typeArg_1) -
Method Summary
Modifier and TypeMethodDescriptionio.smallrye.mutiny.Uni<Void>
Aborts the ongoing transaction.Blocking variant ofabortTransaction()
.Variant ofabortTransaction()
that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>
Starts a new kafka transaction.Blocking variant ofbeginTransaction()
.Variant ofbeginTransaction()
that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>
close()
Close the producerio.smallrye.mutiny.Uni<Void>
close
(long timeout) Close the producerBlocking variant ofclose()
.closeAndAwait
(long timeout) Blocking variant ofclose(long)
.void
Variant ofclose()
that ignores the result of the operation.void
closeAndForget
(long timeout) Variant ofclose(long)
that ignores the result of the operation.io.smallrye.mutiny.Uni<Void>
Commits the ongoing transaction.Blocking variant ofcommitTransaction()
.Variant ofcommitTransaction()
that ignores the result of the operation.static <K,
V> KafkaProducer<K, V> static <K,
V> KafkaProducer<K, V> static <K,
V> KafkaProducer<K, V> 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) static <K,
V> KafkaProducer<K, V> createShared
(Vertx vertx, String name, io.vertx.kafka.client.common.KafkaClientOptions options) static <K,
V> KafkaProducer<K, V> createShared
(Vertx vertx, String name, io.vertx.kafka.client.common.KafkaClientOptions options, Class<K> keyType, Class<V> valueType) static <K,
V> KafkaProducer<K, V> static <K,
V> KafkaProducer<K, V> createShared
(Vertx vertx, String name, Map<String, String> config, Class<K> keyType, Class<V> valueType) drainHandler
(Runnable handler) io.smallrye.mutiny.Uni<Void>
end()
Same asWriteStream.end()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
end
(KafkaProducerRecord<K, V> data) Same as but with anhandler
called when the operation completesBlocking variant ofWriteStream.end()
.endAndAwait
(KafkaProducerRecord<K, V> data) Blocking variant ofWriteStream.end(T)
.void
Variant ofWriteStream.end()
that ignores the result of the operation.void
endAndForget
(KafkaProducerRecord<K, V> data) Variant ofWriteStream.end(T)
that ignores the result of the operation.boolean
exceptionHandler
(Consumer<Throwable> handler) io.smallrye.mutiny.Uni<Void>
flush()
Invoking this method makes all buffered records immediately available to writeBlocking variant offlush()
.Variant offlush()
that ignores the result of the operation.io.vertx.kafka.client.producer.KafkaProducer
int
hashCode()
io.smallrye.mutiny.Uni<Void>
Initializes the underlying kafka transactional producer.Blocking variant ofinitTransactions()
.Variant ofinitTransactions()
that ignores the result of the operation.static <K,
V> KafkaProducer<K, V> newInstance
(io.vertx.kafka.client.producer.KafkaProducer arg) static <K,
V> KafkaProducer<K, V> newInstance
(io.vertx.kafka.client.producer.KafkaProducer arg, TypeArg<K> __typeArg_K, TypeArg<V> __typeArg_V) 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) Blocking variant ofpartitionsFor(String)
.partitionsForAndForget
(String topic) Variant ofpartitionsFor(String)
that ignores the result of the operation.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.RecordMetadata
sendAndAwait
(KafkaProducerRecord<K, V> record) Blocking variant ofsend(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord)
.sendAndForget
(KafkaProducerRecord<K, V> record) Variant ofsend(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord)
that ignores the result of the operation.setWriteQueueMaxSize
(int i) toString()
io.smallrye.mutiny.Uni<Void>
write
(KafkaProducerRecord<K, V> arg0) Same as but with anhandler
called when the operation completeswriteAndAwait
(KafkaProducerRecord<K, V> arg0) Blocking variant ofWriteStream.write(T)
.void
writeAndForget
(KafkaProducerRecord<K, V> arg0) Variant ofWriteStream.write(T)
that ignores the result of the operation.boolean
-
Field Details
-
__TYPE_ARG
-
__typeArg_0
-
__typeArg_1
-
-
Constructor Details
-
KafkaProducer
public KafkaProducer(io.vertx.kafka.client.producer.KafkaProducer delegate) -
KafkaProducer
-
KafkaProducer
-
-
Method Details
-
getDelegate
public io.vertx.kafka.client.producer.KafkaProducer getDelegate()- Specified by:
getDelegate
in interfaceMutinyDelegate
- Specified by:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in interfaceWriteStream<K>
- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
toSubscriber
-
write
Description copied from interface:WriteStream
Same as but with anhandler
called when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
write
in interfaceWriteStream<K>
- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
writeAndAwait
Description copied from interface:WriteStream
Blocking variant ofWriteStream.write(T)
.This method waits 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 a RuntimeException).
- Specified by:
writeAndAwait
in interfaceWriteStream<K>
- Returns:
- the Void instance produced by the operation.
-
writeAndForget
Description copied from interface:WriteStream
Variant ofWriteStream.write(T)
that ignores the result of the operation.This method subscribes on the result of
WriteStream.write(T)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromWriteStream.write(T)
but you don't need to compose it with other operations.- Specified by:
writeAndForget
in interfaceWriteStream<K>
-
end
Description copied from interface:WriteStream
Same asWriteStream.end()
but with anhandler
called when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
end
in interfaceWriteStream<K>
- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Description copied from interface:WriteStream
Blocking variant ofWriteStream.end()
.This method waits 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 a RuntimeException).
- Specified by:
endAndAwait
in interfaceWriteStream<K>
- Returns:
- the Void instance produced by the operation.
-
endAndForget
public void endAndForget()Description copied from interface:WriteStream
Variant ofWriteStream.end()
that ignores the result of the operation.This method subscribes on the result of
WriteStream.end()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromWriteStream.end()
but you don't need to compose it with other operations.- Specified by:
endAndForget
in interfaceWriteStream<K>
-
end
Description copied from interface:WriteStream
Same as but with anhandler
called when the operation completesUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
end
in interfaceWriteStream<K>
- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
endAndAwait
Description copied from interface:WriteStream
Blocking variant ofWriteStream.end(T)
.This method waits 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 a RuntimeException).
- Specified by:
endAndAwait
in interfaceWriteStream<K>
- Returns:
- the Void instance produced by the operation.
-
endAndForget
Description copied from interface:WriteStream
Variant ofWriteStream.end(T)
that ignores the result of the operation.This method subscribes on the result of
WriteStream.end(T)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromWriteStream.end(T)
but you don't need to compose it with other operations.- Specified by:
endAndForget
in interfaceWriteStream<K>
-
writeQueueFull
public boolean writeQueueFull()- Specified by:
writeQueueFull
in interfaceWriteStream<K>
- Returns:
true
if write queue is full
-
create
- 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) - 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()
()}Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
initTransactionsAndAwait
Blocking variant ofinitTransactions()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
initTransactionsAndForget
Variant ofinitTransactions()
that ignores the result of the operation.This method subscribes on the result of
initTransactions()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frominitTransactions()
but you don't need to compose it with other operations.- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
beginTransaction
Starts a new kafka transaction. SeebeginTransaction()
Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
beginTransactionAndAwait
Blocking variant ofbeginTransaction()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
beginTransactionAndForget
Variant ofbeginTransaction()
that ignores the result of the operation.This method subscribes on the result of
beginTransaction()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frombeginTransaction()
but you don't need to compose it with other operations.- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
commitTransaction
Commits the ongoing transaction. SeecommitTransaction()
Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
commitTransactionAndAwait
Blocking variant ofcommitTransaction()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
commitTransactionAndForget
Variant ofcommitTransaction()
that ignores the result of the operation.This method subscribes on the result of
commitTransaction()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromcommitTransaction()
but you don't need to compose it with other operations.- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
abortTransaction
Aborts the ongoing transaction. SeeKafkaProducer
Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
abortTransactionAndAwait
Blocking variant ofabortTransaction()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
abortTransactionAndForget
Variant ofabortTransaction()
that ignores the result of the operation.This method subscribes on the result of
abortTransaction()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromabortTransaction()
but you don't need to compose it with other operations.- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
exceptionHandler
- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in interfaceWriteStream<K>
- Parameters:
handler
- the exception handler- Returns:
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSize
in interfaceWriteStream<K>
- Parameters:
i
- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
- Specified by:
drainHandler
in interfaceWriteStream<K>
- Parameters:
handler
- the handler- Returns:
-
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
. Don't forget to subscribe on it to trigger the operation.- Parameters:
record
- record to write- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
sendAndAwait
Blocking variant ofsend(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord)
.This method waits 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 a RuntimeException).
- Parameters:
record
- record to write- Returns:
- the RecordMetadata instance produced by the operation.
-
sendAndForget
Variant ofsend(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord)
that ignores the result of the operation.This method subscribes on the result of
send(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromsend(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord)
but you don't need to compose it with other operations.- Parameters:
record
- record to write- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
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
. Don't forget to subscribe on it to trigger the operation.- Parameters:
topic
- topic partition for which getting partitions info- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
partitionsForAndAwait
Blocking variant ofpartitionsFor(String)
.This method waits 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 a RuntimeException).
- Parameters:
topic
- topic partition for which getting partitions info- Returns:
- the List
instance produced by the operation.
-
partitionsForAndForget
Variant ofpartitionsFor(String)
that ignores the result of the operation.This method subscribes on the result of
partitionsFor(String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation frompartitionsFor(String)
but you don't need to compose it with other operations.- Parameters:
topic
- topic partition for which getting partitions info- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
flush
Invoking this method makes all buffered records immediately available to writeUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
flushAndAwait
Blocking variant offlush()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
flushAndForget
Variant offlush()
that ignores the result of the operation.This method subscribes on the result of
flush()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromflush()
but you don't need to compose it with other operations.- Returns:
- the instance of KafkaProducer<K,V> to chain method calls.
-
close
Close the producerUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
closeAndAwait
Blocking variant ofclose()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
closeAndForget
public void closeAndForget() -
close
Close the producerUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
timeout
- timeout to wait for closing- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
closeAndAwait
Blocking variant ofclose(long)
.This method waits 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 a RuntimeException).
- Parameters:
timeout
- timeout to wait for closing- Returns:
- the Void instance produced by the operation.
-
closeAndForget
public void closeAndForget(long timeout) Variant ofclose(long)
that ignores the result of the operation.This method subscribes on the result of
close(long)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromclose(long)
but you don't need to compose it with other operations.- Parameters:
timeout
- timeout to wait for closing
-
create
public static <K,V> KafkaProducer<K,V> create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer) - 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) - 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
public static <K,V> KafkaProducer<K,V> newInstance(io.vertx.kafka.client.producer.KafkaProducer arg) -
newInstance
public static <K,V> KafkaProducer<K,V> newInstance(io.vertx.kafka.client.producer.KafkaProducer arg, TypeArg<K> __typeArg_K, TypeArg<V> __typeArg_V)
-