io.vertx.reactivex.kafka.client.producer

## Class KafkaProducer<K,V>

- java.lang.Object
- - io.vertx.reactivex.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 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 <any>` | `__TYPE_ARG`
    `<any>` | `__typeArg_0`
    `<any>` | `__typeArg_1`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KafkaProducer(KafkaProducer delegate)`
    `KafkaProducer(KafkaProducer delegate, <any> typeArg_0, <any> typeArg_1)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the producer
    `void` | `close(Handler<AsyncResult<Void>> completionHandler)` Close the producer
    `void` | `close(long timeout, Handler<AsyncResult<Void>> completionHandler)` Close the producer
    `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>` | `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.
    `void` | `end()` Ends the stream.
    `void` | `end(KafkaProducerRecord<K,V> kafkaProducerRecord)` Same as `WriteStream.end()` but writes some data to the stream before ending.
    `boolean` | `equals(Object o)`
    `KafkaProducer<K,V>` | `exceptionHandler(Handler<Throwable> handler)` Set an exception handler on the write stream.
    `KafkaProducer<K,V>` | `flush(Handler<Void> completionHandler)` Invoking this method makes all buffered records immediately available to write
    `KafkaProducer` | `getDelegate()`
    `int` | `hashCode()`
    `static <K,V> KafkaProducer<K,V>` | `newInstance(KafkaProducer arg)`
    `static <K,V> KafkaProducer<K,V>` | `newInstance(KafkaProducer arg, <any> __typeArg_K, <any> __typeArg_V)`
    `KafkaProducer<K,V>` | `partitionsFor(String topic, Handler<AsyncResult<List<PartitionInfo>>> handler)` Get the partition metadata for the give topic.
    `Completable` | `rxClose()` Close the producer
    `Completable` | `rxClose(long timeout)` Close the producer
    `Single<List<PartitionInfo>>` | `rxPartitionsFor(String topic)` Get the partition metadata for the give topic.
    `Single<RecordMetadata>` | `rxWrite(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`.
    `io.vertx.reactivex.WriteStreamObserver<KafkaProducerRecord<K,V>>` | `toObserver()`
    `String` | `toString()`
    `io.vertx.reactivex.WriteStreamSubscriber<KafkaProducerRecord<K,V>>` | `toSubscriber()`
    `KafkaProducer<K,V>` | `write(KafkaProducerRecord<K,V> kafkaProducerRecord)` Write some data to the stream.
    `KafkaProducer<K,V>` | `write(KafkaProducerRecord<K,V> record, Handler<AsyncResult<RecordMetadata>> handler)` Asynchronously write a record to a topic
    `boolean` | `writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using `WriteStream.setWriteQueueMaxSize(int)`

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

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

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

      `newInstance, newInstance`

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

      `newInstance`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final <any> __TYPE_ARG

    - #### __typeArg_0

          public final <any> __typeArg_0

    - #### __typeArg_1

          public final <any> __typeArg_1

  - ### Constructor Detail

    - #### KafkaProducer

          public KafkaProducer(KafkaProducer delegate)

    - #### KafkaProducer

          public KafkaProducer(KafkaProducer delegate,
                               <any> typeArg_0,
                               <any> 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 io.vertx.reactivex.WriteStreamObserver<KafkaProducerRecord<K,V>> toObserver()

    - #### toSubscriber

          public io.vertx.reactivex.WriteStreamSubscriber<KafkaProducerRecord<K,V>> toSubscriber()

    - #### 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`
      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,
                                                              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`
      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

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

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

    - #### write

          public KafkaProducer<K,V> write(KafkaProducerRecord<K,V> kafkaProducerRecord)

      Description copied from interface: `WriteStream`
      Write some data to the stream. The data is 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 `WriteStream.writeQueueFull()` method before writing. This is done automatically if using a `Pump`.
      Specified by:
        `write` in interface `WriteStream<KafkaProducerRecord<K,V>>`
      Parameters:
        `kafkaProducerRecord` - the data to write
      Returns:
        a reference to this, so the API can be used fluently

    - #### end

          public void end()

      Description copied from interface: `WriteStream`
      Ends the stream.

      Once the stream has ended, it cannot be used any more.

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

    - #### end

          public void end(KafkaProducerRecord<K,V> kafkaProducerRecord)

      Description copied from interface: `WriteStream`
      Same as `WriteStream.end()` but writes some data to the stream before ending.
      Specified by:
        `end` in interface `WriteStream<KafkaProducerRecord<K,V>>`

    - #### 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 `Pump` to provide flow control.

      The value is defined by the implementation of the stream, e.g in bytes for a `NetSocket`, the number of `Message` for a `MessageProducer`, 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

    - #### writeQueueFull

          public boolean writeQueueFull()

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

    - #### 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 `Pump` 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

    - #### write

          public KafkaProducer<K,V> write(KafkaProducerRecord<K,V> record,
                                          Handler<AsyncResult<RecordMetadata>> handler)

      Asynchronously write a record to a topic
      Parameters:
        `record` - record to write
        `handler` - handler called on operation completed
      Returns:
        current KafkaWriteStream instance

    - #### rxWrite

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

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

    - #### partitionsFor

          public KafkaProducer<K,V> partitionsFor(String topic,
                                                  Handler<AsyncResult<List<PartitionInfo>>> handler)

      Get the partition metadata for the give topic.
      Parameters:
        `topic` - topic partition for which getting partitions info
        `handler` - handler called on operation completed
      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 KafkaProducer<K,V> flush(Handler<Void> completionHandler)

      Invoking this method makes all buffered records immediately available to write
      Parameters:
        `completionHandler` - handler called on operation completed
      Returns:
        current KafkaProducer instance

    - #### close

          public void close()

      Close the producer

    - #### close

          public void close(Handler<AsyncResult<Void>> completionHandler)

      Close the producer
      Parameters:
        `completionHandler` - handler called on operation completed

    - #### rxClose

          public Completable rxClose()

      Close the producer
      Returns:

    - #### close

          public void close(long timeout,
                            Handler<AsyncResult<Void>> completionHandler)

      Close the producer
      Parameters:
        `timeout` - timeout to wait for closing
        `completionHandler` - handler called on operation completed

    - #### rxClose

          public Completable rxClose(long timeout)

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

    - #### newInstance

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

    - #### newInstance

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

Copyright © 2018 Eclipse. All rights reserved.