public class ReactiveKafkaProducer<K,V> extends Object implements KafkaProducer<K,V>
Constructor and Description |
---|
ReactiveKafkaProducer(KafkaConnectorOutgoingConfiguration config) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
Map<String,?> |
configuration() |
io.smallrye.mutiny.Uni<Void> |
flush()
Sends all buffered records immediately.
|
String |
get(String attribute) |
io.smallrye.mutiny.Uni<List<org.apache.kafka.common.PartitionInfo>> |
partitionsFor(String topic)
Returns a list of partition metadata for given topic.
|
io.smallrye.mutiny.Uni<Void> |
runOnSendingThread(Consumer<org.apache.kafka.clients.producer.Producer<K,V>> action)
Runs an action on the sending thread.
|
<T> io.smallrye.mutiny.Uni<T> |
runOnSendingThread(Function<org.apache.kafka.clients.producer.Producer<K,V>,T> action)
Runs an action on the sending thread.
|
io.smallrye.mutiny.Uni<org.apache.kafka.clients.producer.RecordMetadata> |
send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
Send a record to a topic.
|
org.apache.kafka.clients.producer.Producer<K,V> |
unwrap() |
public ReactiveKafkaProducer(KafkaConnectorOutgoingConfiguration config)
public <T> io.smallrye.mutiny.Uni<T> runOnSendingThread(Function<org.apache.kafka.clients.producer.Producer<K,V>,T> action)
KafkaProducer
The action is a function taking as parameter the Producer
and that returns a result (potentially null
).
The produced Uni
emits the returned result when the action completes. If the action throws an exception,
the produced Uni
emits the exception as failure.
If the action does not return a result, use KafkaProducer.runOnSendingThread(java.util.function.Consumer)
.
runOnSendingThread
in interface KafkaProducer<K,V>
T
- the type of result, can be Void
action
- the action to execute, must not be null
public io.smallrye.mutiny.Uni<Void> runOnSendingThread(Consumer<org.apache.kafka.clients.producer.Producer<K,V>> action)
KafkaProducer
The action is a consumer receiving the Producer
.
The produced Uni
emits null
when the action completes. If the action throws an exception,
the produced Uni
emits the exception as failure.
runOnSendingThread
in interface KafkaProducer<K,V>
action
- the action, must not be null
null
or the failure when the action completes.public io.smallrye.mutiny.Uni<org.apache.kafka.clients.producer.RecordMetadata> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
KafkaProducer
Uni
completes with RecordMetadata
when the send
has been acknowledged, or with an exception in case of an error.send
in interface KafkaProducer<K,V>
public io.smallrye.mutiny.Uni<Void> flush()
KafkaProducer
Uni
completes when all requests belonging
to the buffered records complete. In other words, when the returned Uni
completes, all
previous KafkaProducer.send(ProducerRecord)
operations are known to be complete as well.
No guarantee is made about the completion of records sent after flush
was called.flush
in interface KafkaProducer<K,V>
public io.smallrye.mutiny.Uni<List<org.apache.kafka.common.PartitionInfo>> partitionsFor(String topic)
KafkaProducer
partitionsFor
in interface KafkaProducer<K,V>
public org.apache.kafka.clients.producer.Producer<K,V> unwrap()
unwrap
in interface KafkaProducer<K,V>
public void close()
Copyright © 2018–2021 SmallRye. All rights reserved.