io.vertx.rxjava3.kafka.client.producer

## Class KafkaProducer<K,V>

- java.lang.Object
- - io.vertx.rxjava3.kafka.client.producer.KafkaProducer<K,V>

- All Implemented Interfaces:
    StreamBase, WriteStream<KafkaProducerRecord<K,V>>

      public class KafkaProducer<K,V>
      extends Object
      implements WriteStream<KafkaProducerRecord<K,V>>

  Vert.x Kafka producer.

  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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.vertx.lang.rx.TypeArg<KafkaProducer>` | `__TYPE_ARG`
    `io.vertx.lang.rx.TypeArg<K>` | `__typeArg_0`
    `io.vertx.lang.rx.TypeArg<V>` | `__typeArg_1`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KafkaProducer(KafkaProducer delegate)`
    `KafkaProducer(Object delegate, io.vertx.lang.rx.TypeArg<K> typeArg_0, io.vertx.lang.rx.TypeArg<V> typeArg_1)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Completable` | `abortTransaction()` Aborts the ongoing transaction.
    `Completable` | `beginTransaction()` Starts a new kafka transaction.
    `Completable` | `close()` Close the producer
    `Completable` | `close(long timeout)` Close the producer
    `Completable` | `commitTransaction()` Commits the ongoing transaction.
    `static <K,V> KafkaProducer<K,V>` | `create(Vertx vertx, Map<String,String> config)` Create a new KafkaProducer instance
    `static <K,V> KafkaProducer<K,V>` | `create(Vertx vertx, Map<String,String> config, Class<K> keyType, Class<V> valueType)` Create a new KafkaProducer instance
    `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 .
    `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 same `name`
    `static <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 same `name`
    `static <K,V> KafkaProducer<K,V>` | `createShared(Vertx vertx, String name, Map<String,String> config)` Get or create a KafkaProducer instance which shares its stream with any other KafkaProducer created with the same `name`
    `static <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 same `name`
    `KafkaProducer<K,V>` | `drainHandler(Handler<Void> handler)` Set a drain handler on the stream.
    `Completable` | `end()` Same as `WriteStream.end()` but with an `handler` called when the operation completes
    `Completable` | `end(KafkaProducerRecord<K,V> data)` Same as but with an `handler` called when the operation completes
    `boolean` | `equals(Object o)`
    `KafkaProducer<K,V>` | `exceptionHandler(Handler<Throwable> handler)` Set an exception handler on the write stream.
    `Completable` | `flush()` Invoking this method makes all buffered records immediately available to write
    `KafkaProducer` | `getDelegate()`
    `int` | `hashCode()`
    `Completable` | `initTransactions()` 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)`
    `Single<List<PartitionInfo>>` | `partitionsFor(String topic)` Get the partition metadata for the give topic.
    `Completable` | `rxAbortTransaction()` Aborts the ongoing transaction.
    `Completable` | `rxBeginTransaction()` Starts a new kafka transaction.
    `Completable` | `rxClose()` Close the producer
    `Completable` | `rxClose(long timeout)` Close the producer
    `Completable` | `rxCommitTransaction()` Commits the ongoing transaction.
    `Completable` | `rxEnd()` Same as `WriteStream.end()` but with an `handler` called when the operation completes
    `Completable` | `rxEnd(KafkaProducerRecord<K,V> data)` Same as but with an `handler` called when the operation completes
    `Completable` | `rxFlush()` Invoking this method makes all buffered records immediately available to write
    `Completable` | `rxInitTransactions()` Initializes the underlying kafka transactional producer.
    `Single<List<PartitionInfo>>` | `rxPartitionsFor(String topic)` Get the partition metadata for the give topic.
    `Single<RecordMetadata>` | `rxSend(KafkaProducerRecord<K,V> record)` Asynchronously write a record to a topic
    `Completable` | `rxWrite(KafkaProducerRecord<K,V> data)` Same as but with an `handler` called when the operation completes
    `Single<RecordMetadata>` | `send(KafkaProducerRecord<K,V> record)` Asynchronously write a record to a topic
    `KafkaProducer<K,V>` | `setWriteQueueMaxSize(int i)` Set the maximum size of the write queue to `maxSize`.
    `WriteStreamObserver<KafkaProducerRecord<K,V>>` | `toObserver()`
    `String` | `toString()`
    `WriteStreamSubscriber<KafkaProducerRecord<K,V>>` | `toSubscriber()`
    `Completable` | `write(KafkaProducerRecord<K,V> data)` Same as but with an `handler` called when the operation completes
    `boolean` | `writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using `setWriteQueueMaxSize(int)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface io.vertx.rxjava3.core.streams.WriteStream

      `newInstance, newInstance`

    - ### Methods inherited from interface io.vertx.rxjava3.core.streams.StreamBase

      `newInstance`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<KafkaProducer> __TYPE_ARG

    - #### __typeArg_0

          public final io.vertx.lang.rx.TypeArg<K> __typeArg_0

    - #### __typeArg_1

          public final io.vertx.lang.rx.TypeArg<V> __typeArg_1

  - ### Constructor Detail

    - #### KafkaProducer

          public KafkaProducer(KafkaProducer delegate)

    - #### KafkaProducer

          public KafkaProducer(Object delegate,
                               io.vertx.lang.rx.TypeArg<K> typeArg_0,
                               io.vertx.lang.rx.TypeArg<V> typeArg_1)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public KafkaProducer getDelegate()

      Specified by:
        `getDelegate` in interface `StreamBase`
      Specified by:
        `getDelegate` in interface `WriteStream<KafkaProducerRecord<K,V>>`

    - #### toObserver

          public WriteStreamObserver<KafkaProducerRecord<K,V>> toObserver()

    - #### toSubscriber

          public WriteStreamSubscriber<KafkaProducerRecord<K,V>> toSubscriber()

    - #### write

          public Completable write(KafkaProducerRecord<K,V> data)

      Same as but with an `handler` called when the operation completes
      Specified by:
        `write` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `data` -
      Returns:

    - #### rxWrite

          public Completable rxWrite(KafkaProducerRecord<K,V> data)

      Same as but with an `handler` called when the operation completes
      Specified by:
        `rxWrite` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `data` -
      Returns:

    - #### end

          public Completable end()

      Same as `WriteStream.end()` but with an `handler` called when the operation completes
      Specified by:
        `end` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Returns:

    - #### rxEnd

          public Completable rxEnd()

      Same as `WriteStream.end()` but with an `handler` called when the operation completes
      Specified by:
        `rxEnd` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Returns:

    - #### end

          public Completable end(KafkaProducerRecord<K,V> data)

      Same as but with an `handler` called when the operation completes
      Specified by:
        `end` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `data` -
      Returns:

    - #### rxEnd

          public Completable rxEnd(KafkaProducerRecord<K,V> data)

      Same as but with an `handler` called when the operation completes
      Specified by:
        `rxEnd` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `data` -
      Returns:

    - #### writeQueueFull

          public boolean writeQueueFull()

      This will return `true` if there are more bytes in the write queue than the value set using `setWriteQueueMaxSize(int)`
      Specified by:
        `writeQueueFull` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Returns:
        `true` if write queue is full

    - #### createShared

          public static <K,V> KafkaProducer<K,V> createShared(Vertx vertx,
                                                              String name,
                                                              Map<String,String> config)

      Get or create a KafkaProducer instance which shares its stream with any other KafkaProducer created with the same `name`

      When `close` has been called for each shared producer the resources will be released. Calling `end` closes all shared producers.

      Parameters:
        `vertx` - Vert.x instance to use
        `name` - the producer name to identify it
        `config` - Kafka producer configuration
      Returns:
        an instance of the KafkaProducer

    - #### createShared

          public 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 same `name`

      When `close` has been called for each shared producer the resources will be released. Calling `end` closes all shared producers.

      Parameters:
        `vertx` - Vert.x instance to use
        `name` - the producer name to identify it
        `options` - Kafka producer options
      Returns:
        an instance of the KafkaProducer

    - #### createShared

          public static <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 same `name`

      When `close` has been called for each shared producer the resources will be released. Calling `end` closes all shared producers.

      Parameters:
        `vertx` - Vert.x instance to use
        `name` - the producer name to identify it
        `config` - Kafka producer configuration
        `keyType` - class type for the key serialization
        `valueType` - class type for the value serialization
      Returns:
        an instance of the KafkaProducer

    - #### createShared

          public static <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 same `name`

      When `close` has been called for each shared producer the resources will be released. Calling `end` closes all shared producers.

      Parameters:
        `vertx` - Vert.x instance to use
        `name` - the producer name to identify it
        `options` - Kafka producer options
        `keyType` - class type for the key serialization
        `valueType` - class type for the value serialization
      Returns:
        an instance of the KafkaProducer

    - #### create

          public static <K,V> KafkaProducer<K,V> create(Vertx vertx,
                                                        Map<String,String> config)

      Create a new KafkaProducer instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - 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 use
        `config` - Kafka producer configuration
        `keyType` - class type for the key serialization
        `valueType` - class type for the value serialization
      Returns:
        an instance of the KafkaProducer

    - #### initTransactions

          public Completable initTransactions()

      Initializes the underlying kafka transactional producer. See `initTransactions()` ()}
      Returns:
        current KafkaWriteStream instance

    - #### rxInitTransactions

          public Completable rxInitTransactions()

      Initializes the underlying kafka transactional producer. See `initTransactions()` ()}
      Returns:
        current KafkaWriteStream instance

    - #### beginTransaction

          public Completable beginTransaction()

      Starts a new kafka transaction. See `beginTransaction()`
      Returns:
        current KafkaWriteStream instance

    - #### rxBeginTransaction

          public Completable rxBeginTransaction()

      Starts a new kafka transaction. See `beginTransaction()`
      Returns:
        current KafkaWriteStream instance

    - #### commitTransaction

          public Completable commitTransaction()

      Commits the ongoing transaction. See `commitTransaction()`
      Returns:
        current KafkaWriteStream instance

    - #### rxCommitTransaction

          public Completable rxCommitTransaction()

      Commits the ongoing transaction. See `commitTransaction()`
      Returns:
        current KafkaWriteStream instance

    - #### abortTransaction

          public Completable abortTransaction()

      Aborts the ongoing transaction. See `KafkaProducer`
      Returns:
        current KafkaWriteStream instance

    - #### rxAbortTransaction

          public Completable rxAbortTransaction()

      Aborts the ongoing transaction. See `KafkaProducer`
      Returns:
        current KafkaWriteStream instance

    - #### exceptionHandler

          public KafkaProducer<K,V> exceptionHandler(Handler<Throwable> handler)

      Description copied from interface: `WriteStream`
      Set an exception handler on the write stream.
      Specified by:
        `exceptionHandler` in interface `StreamBase`
      Specified by:
        `exceptionHandler` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `handler` - the exception handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### setWriteQueueMaxSize

          public KafkaProducer<K,V> setWriteQueueMaxSize(int i)

      Description copied from interface: `WriteStream`
      Set the maximum size of the write queue to `maxSize`. You will still be able to write to the stream even if there is more than `maxSize` items in the write queue. This is used as an indicator by classes such as `Pipe` to provide flow control.

      The value is defined by the implementation of the stream, e.g in bytes for a `NetSocket`, etc...
      Specified by:
        `setWriteQueueMaxSize` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `i` - the max size of the write stream
      Returns:
        a reference to this, so the API can be used fluently

    - #### drainHandler

          public KafkaProducer<K,V> drainHandler(Handler<Void> handler)

      Description copied from interface: `WriteStream`
      Set 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. See `Pipe` for 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:
        `drainHandler` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### send

          public Single<RecordMetadata> send(KafkaProducerRecord<K,V> record)

      Asynchronously write a record to a topic
      Parameters:
        `record` - record to write
      Returns:
        current KafkaWriteStream instance

    - #### rxSend

          public Single<RecordMetadata> rxSend(KafkaProducerRecord<K,V> record)

      Asynchronously write a record to a topic
      Parameters:
        `record` - record to write
      Returns:
        current KafkaWriteStream instance

    - #### partitionsFor

          public Single<List<PartitionInfo>> partitionsFor(String topic)

      Get the partition metadata for the give topic.
      Parameters:
        `topic` - topic partition for which getting partitions info
      Returns:
        current KafkaProducer instance

    - #### rxPartitionsFor

          public Single<List<PartitionInfo>> rxPartitionsFor(String topic)

      Get the partition metadata for the give topic.
      Parameters:
        `topic` - topic partition for which getting partitions info
      Returns:
        current KafkaProducer instance

    - #### flush

          public Completable flush()

      Invoking this method makes all buffered records immediately available to write
      Returns:
        current KafkaProducer instance

    - #### rxFlush

          public Completable rxFlush()

      Invoking this method makes all buffered records immediately available to write
      Returns:
        current KafkaProducer instance

    - #### close

          public Completable close()

      Close the producer
      Returns:

    - #### rxClose

          public Completable rxClose()

      Close the producer
      Returns:

    - #### close

          public Completable close(long timeout)

      Close the producer
      Parameters:
        `timeout` - timeout to wait for closing
      Returns:

    - #### rxClose

          public Completable rxClose(long timeout)

      Close the producer
      Parameters:
        `timeout` - timeout to wait for closing
      Returns:

    - #### 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 use
        `producer` - 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 use
        `producer` - the Kafka producer to wrap
        `options` - options used only for tracing settings
      Returns:
        an instance of the KafkaProducer

    - #### newInstance

          public static <K,V> KafkaProducer<K,V> newInstance(KafkaProducer arg)

    - #### 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)

Copyright © 2024 Eclipse. All rights reserved.