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.

    • 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,
                                                              KafkaClientOptions options)
        Create a new KafkaWriteStream instance
        Parameters:
        vertx - Vert.x instance to use
        options - Kafka producer options
        Returns:
        an instance of the KafkaWriteStream
      • create

        static <K,​V> KafkaWriteStream<K,​V> create​(Vertx vertx,
                                                              KafkaClientOptions options,
                                                              Class<K> keyType,
                                                              Class<V> valueType)
        Create a new KafkaWriteStream instance
        Parameters:
        vertx - Vert.x instance to use
        options - Kafka producer options
        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,
                                                              KafkaClientOptions options,
                                                              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
        options - Kafka producer options
        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
      • create

        static <K,​V> KafkaWriteStream<K,​V> create​(Vertx vertx,
                                                              org.apache.kafka.clients.producer.Producer<K,​V> producer,
                                                              KafkaClientOptions options)
        Create a new KafkaWriteStream instance.
        Parameters:
        vertx - Vert.x instance to use
        producer - native Kafka producer instance
        options - options used only for tracing settings
      • abortTransaction

        Future<Void> abortTransaction()
        Aborts the ongoing transaction. See KafkaProducer.abortTransaction()
        Returns:
        a future notified with the result
      • send

        Future<org.apache.kafka.clients.producer.RecordMetadata> send​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> record)
        Asynchronously write a record to a topic
        Parameters:
        record - record to write
        Returns:
        a Future completed with the record metadata
      • partitionsFor

        Future<List<org.apache.kafka.common.PartitionInfo>> partitionsFor​(String topic)
        Get the partition metadata for the give topic.
        Parameters:
        topic - topic partition for which getting partitions info
        Returns:
        a future notified with the result
      • flush

        Future<Void> flush()
        Invoking this method makes all buffered records immediately available to write
        Returns:
        a future notified with the result
      • close

        Future<Void> close​(long timeout)
        Close the stream
        Parameters:
        timeout - timeout to wait for closing
        Returns:
        a future notified with the result
      • unwrap

        org.apache.kafka.clients.producer.Producer<K,​V> unwrap()
        Returns:
        the underlying producer