io.vertx.kafka.client.producer

## Interface KafkaWriteStream<K,V>

- All Superinterfaces:
    StreamBase, WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>

      public interface KafkaWriteStream<K,V>
      extends WriteStream<org.apache.kafka.clients.producer.ProducerRecord<K,V>>

  A `WriteStream` for writing to Kafka `ProducerRecord`.

  The `WriteStream.write(Object)` provides global control over writing a record.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAX_SIZE`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the stream
    `void` | `close(Handler<AsyncResult<Void>> completionHandler)` Close the stream
    `void` | `close(long timeout, Handler<AsyncResult<Void>> completionHandler)` Close the stream
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, Map<String,Object> config)` Create a new KafkaWriteStream instance
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, Map<String,Object> config, Class<K> keyType, Class<V> valueType)` Create a new KafkaWriteStream instance
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, Map<String,Object> config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer)` Create a new KafkaWriteStream instance
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, org.apache.kafka.clients.producer.Producer<K,V> producer)` Create a new KafkaWriteStream instance
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, Properties config)` Create a new KafkaWriteStream instance
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, Properties config, Class<K> keyType, Class<V> valueType)` Create a new KafkaWriteStream instance
    `static <K,V> KafkaWriteStream<K,V>` | `create(Vertx vertx, Properties config, org.apache.kafka.common.serialization.Serializer<K> keySerializer, org.apache.kafka.common.serialization.Serializer<V> valueSerializer)` Create a new KafkaWriteStream instance
    `KafkaWriteStream<K,V>` | `flush(Handler<Void> completionHandler)` Invoking this method makes all buffered records immediately available to write
    `KafkaWriteStream<K,V>` | `partitionsFor(String topic, Handler<AsyncResult<List<org.apache.kafka.common.PartitionInfo>>> handler)` Get the partition metadata for the give topic.
    `KafkaWriteStream<K,V>` | `send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)` Asynchronously write a record to a topic
    `KafkaWriteStream<K,V>` | `send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record, Handler<AsyncResult<org.apache.kafka.clients.producer.RecordMetadata>> handler)` Asynchronously write a record to a topic
    `org.apache.kafka.clients.producer.Producer<K,V>` | `unwrap()`

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

      `drainHandler, end, end, end, end, exceptionHandler, setWriteQueueMaxSize, write, write, writeQueueFull`

- - ### Field Detail

    - #### DEFAULT_MAX_SIZE

          static final int DEFAULT_MAX_SIZE

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    Properties config)

      Create a new KafkaWriteStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - Kafka producer configuration
      Returns:
        an instance of the KafkaWriteStream

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    Properties config,
                                                    Class<K> keyType,
                                                    Class<V> valueType)

      Create a new KafkaWriteStream 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 KafkaWriteStream

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    Properties config,
                                                    org.apache.kafka.common.serialization.Serializer<K> keySerializer,
                                                    org.apache.kafka.common.serialization.Serializer<V> valueSerializer)

      Create a new KafkaWriteStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - Kafka producer configuration
        `keySerializer` - key serializer
        `valueSerializer` - value serializer
      Returns:
        an instance of the KafkaWriteStream

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    Map<String,Object> config)

      Create a new KafkaWriteStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - Kafka producer configuration
      Returns:
        an instance of the KafkaWriteStream

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    Map<String,Object> config,
                                                    Class<K> keyType,
                                                    Class<V> valueType)

      Create a new KafkaWriteStream 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 KafkaWriteStream

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    Map<String,Object> config,
                                                    org.apache.kafka.common.serialization.Serializer<K> keySerializer,
                                                    org.apache.kafka.common.serialization.Serializer<V> valueSerializer)

      Create a new KafkaWriteStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `config` - Kafka producer configuration
        `keySerializer` - key serializer
        `valueSerializer` - value serializer
      Returns:
        an instance of the KafkaWriteStream

    - #### create

          static <K,V> KafkaWriteStream<K,V> create(Vertx vertx,
                                                    org.apache.kafka.clients.producer.Producer<K,V> producer)

      Create a new KafkaWriteStream instance
      Parameters:
        `vertx` - Vert.x instance to use
        `producer` - native Kafka producer instance

    - #### send

          KafkaWriteStream<K,V> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)

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

    - #### send

          KafkaWriteStream<K,V> send(org.apache.kafka.clients.producer.ProducerRecord<K,V> record,
                                     Handler<AsyncResult<org.apache.kafka.clients.producer.RecordMetadata>> handler)

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

    - #### partitionsFor

          KafkaWriteStream<K,V> partitionsFor(String topic,
                                              Handler<AsyncResult<List<org.apache.kafka.common.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 KafkaWriteStream instance

    - #### flush

          KafkaWriteStream<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 KafkaWriteStream instance

    - #### close

          void close()

      Close the stream

    - #### close

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

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

    - #### close

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

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

    - #### unwrap

          org.apache.kafka.clients.producer.Producer<K,V> unwrap()

      Returns:
        the underlying producer

Copyright © 2019 Eclipse. All rights reserved.