Class KafkaProducer<K,V>
- All Implemented Interfaces:
io.vertx.mutiny.core.streams.StreamBase,io.vertx.mutiny.core.streams.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
FieldsModifier and TypeFieldDescriptionstatic final io.smallrye.mutiny.vertx.TypeArg<KafkaProducer> final io.smallrye.mutiny.vertx.TypeArg<K> final io.smallrye.mutiny.vertx.TypeArg<V> -
Constructor Summary
ConstructorsConstructorDescriptionKafkaProducer(io.vertx.kafka.client.producer.KafkaProducer delegate) KafkaProducer(io.vertx.kafka.client.producer.KafkaProducer delegate, io.smallrye.mutiny.vertx.TypeArg<K> typeArg_0, io.smallrye.mutiny.vertx.TypeArg<V> typeArg_1) KafkaProducer(Object delegate, io.smallrye.mutiny.vertx.TypeArg<K> typeArg_0, io.smallrye.mutiny.vertx.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).voidVariant ofclose()that ignores the result of the operation.voidcloseAndForget(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> create(io.vertx.mutiny.core.Vertx vertx, Map<String, String> config, Class<K> keyType, Class<V> valueType) static <K,V> KafkaProducer <K, V> create(io.vertx.mutiny.core.Vertx vertx, org.apache.kafka.clients.producer.Producer<K, V> producer) static <K,V> KafkaProducer <K, V> create(io.vertx.mutiny.core.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(io.vertx.mutiny.core.Vertx vertx, String name, io.vertx.kafka.client.common.KafkaClientOptions options) static <K,V> KafkaProducer <K, V> createShared(io.vertx.mutiny.core.Vertx vertx, String name, io.vertx.kafka.client.common.KafkaClientOptions options, Class<K> keyType, Class<V> valueType) static <K,V> KafkaProducer <K, V> createShared(io.vertx.mutiny.core.Vertx vertx, String name, Map<String, String> config) static <K,V> KafkaProducer <K, V> createShared(io.vertx.mutiny.core.Vertx vertx, String name, Map<String, String> config, Class<K> keyType, Class<V> valueType) drainHandler(Runnable handler) io.smallrye.mutiny.Uni<Void> end()io.smallrye.mutiny.Uni<Void> end(KafkaProducerRecord<K, V> data) endAndAwait(KafkaProducerRecord<K, V> data) voidvoidendAndForget(KafkaProducerRecord<K, V> data) booleanexceptionHandler(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.KafkaProducerinthashCode()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, io.smallrye.mutiny.vertx.TypeArg<K> __typeArg_K, io.smallrye.mutiny.vertx.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.RecordMetadatasendAndAwait(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.vertx.WriteStreamSubscriber<KafkaProducerRecord<K, V>> io.smallrye.mutiny.Uni<Void> write(KafkaProducerRecord<K, V> arg0) writeAndAwait(KafkaProducerRecord<K, V> arg0) voidwriteAndForget(KafkaProducerRecord<K, V> arg0) 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:
getDelegatein interfaceio.vertx.mutiny.core.streams.StreamBase- Specified by:
getDelegatein interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
toString
-
equals
-
hashCode
public int hashCode() -
toSubscriber
@CheckReturnValue public io.smallrye.mutiny.vertx.WriteStreamSubscriber<KafkaProducerRecord<K,V>> toSubscriber() -
write
- Specified by:
writein interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
writeAndAwait
- Specified by:
writeAndAwaitin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
writeAndForget
- Specified by:
writeAndForgetin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
end
- Specified by:
endin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
endAndAwait
- Specified by:
endAndAwaitin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
endAndForget
public void endAndForget()- Specified by:
endAndForgetin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
end
- Specified by:
endin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
endAndAwait
- Specified by:
endAndAwaitin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
endAndForget
- Specified by:
endAndForgetin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
writeQueueFull
public boolean writeQueueFull()- Specified by:
writeQueueFullin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
create
public static <K,V> KafkaProducer<K,V> create(io.vertx.mutiny.core.Vertx vertx, Map<String, String> config) - 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(io.vertx.mutiny.core.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
unifiring 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 KafkaProducerinvalid input: '<'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
unifiring 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 KafkaProducerinvalid input: '<'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
unifiring 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 KafkaProducerinvalid input: '<'K,V> to chain method calls.
-
abortTransaction
Aborts the ongoing transaction. SeeKafkaProducerUnlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring 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 KafkaProducerinvalid input: '<'K,V> to chain method calls.
-
exceptionHandler
- Specified by:
exceptionHandlerin interfaceio.vertx.mutiny.core.streams.StreamBase- Specified by:
exceptionHandlerin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
setWriteQueueMaxSize
- Specified by:
setWriteQueueMaxSizein interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
drainHandler
- Specified by:
drainHandlerin interfaceio.vertx.mutiny.core.streams.WriteStream<K>
-
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
unifiring 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 KafkaProducerinvalid input: '<'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
unifiring 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 KafkaProducerinvalid input: '<'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
unifiring 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 KafkaProducerinvalid input: '<'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
unifiring 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
unifiring 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(io.vertx.mutiny.core.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(io.vertx.mutiny.core.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, io.smallrye.mutiny.vertx.TypeArg<K> __typeArg_K, io.smallrye.mutiny.vertx.TypeArg<V> __typeArg_V)
-