Class KafkaProducer<K,​V>

    • Constructor Detail

      • KafkaProducer

        public KafkaProducer​(io.vertx.kafka.client.producer.KafkaProducer delegate)
      • KafkaProducer

        public KafkaProducer​(io.vertx.kafka.client.producer.KafkaProducer delegate,
                             TypeArg<K> typeArg_0,
                             TypeArg<V> typeArg_1)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • write

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> write​(KafkaProducerRecord<K,​V> arg0)
        Description copied from interface: WriteStream
        Same as but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        write in interface WriteStream<K>
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • writeAndAwait

        public Void writeAndAwait​(KafkaProducerRecord<K,​V> arg0)
        Description copied from interface: WriteStream
        Blocking variant of io.vertx.mutiny.core.streams.WriteStream#write(T).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        writeAndAwait in interface WriteStream<K>
        Returns:
        the Void instance produced by the operation.
      • writeAndForget

        public void writeAndForget​(KafkaProducerRecord<K,​V> arg0)
        Description copied from interface: WriteStream
        Variant of io.vertx.mutiny.core.streams.WriteStream#write(T) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.WriteStream#write(T), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.WriteStream#write(T) but you don't need to compose it with other operations.

        Specified by:
        writeAndForget in interface WriteStream<K>
      • end

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> end()
        Description copied from interface: WriteStream
        Same as WriteStream.end() but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        end in interface WriteStream<K>
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • endAndAwait

        public Void endAndAwait()
        Description copied from interface: WriteStream
        Blocking variant of WriteStream.end().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        endAndAwait in interface WriteStream<K>
        Returns:
        the Void instance produced by the operation.
      • endAndForget

        public void endAndForget()
        Description copied from interface: WriteStream
        Variant of WriteStream.end() that ignores the result of the operation.

        This method subscribes on the result of WriteStream.end(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from WriteStream.end() but you don't need to compose it with other operations.

        Specified by:
        endAndForget in interface WriteStream<K>
      • end

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> end​(KafkaProducerRecord<K,​V> data)
        Description copied from interface: WriteStream
        Same as but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        end in interface WriteStream<K>
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • endAndAwait

        public Void endAndAwait​(KafkaProducerRecord<K,​V> data)
        Description copied from interface: WriteStream
        Blocking variant of io.vertx.mutiny.core.streams.WriteStream#end(T).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        endAndAwait in interface WriteStream<K>
        Returns:
        the Void instance produced by the operation.
      • endAndForget

        public void endAndForget​(KafkaProducerRecord<K,​V> data)
        Description copied from interface: WriteStream
        Variant of io.vertx.mutiny.core.streams.WriteStream#end(T) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.WriteStream#end(T), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.WriteStream#end(T) but you don't need to compose it with other operations.

        Specified by:
        endAndForget in interface WriteStream<K>
      • writeQueueFull

        public boolean writeQueueFull()
        Specified by:
        writeQueueFull in interface WriteStream<K>
        Returns:
        true if write queue is full
      • createShared

        public static <K,​V> KafkaProducer<K,​V> createShared​(Vertx vertx,
                                                                        String name,
                                                                        Map<String,​String> config)
        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,
                                                                        io.vertx.kafka.client.common.KafkaClientOptions options)
        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)
        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,
                                                                        io.vertx.kafka.client.common.KafkaClientOptions options,
                                                                        Class<K> keyType,
                                                                        Class<V> valueType)
        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)
        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)
        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

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> initTransactions()
        Initializes the underlying kafka transactional producer. See initTransactions() ()}

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • initTransactionsAndAwait

        public Void initTransactionsAndAwait()
        Blocking variant of initTransactions().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • initTransactionsAndForget

        public KafkaProducer<K,​V> initTransactionsAndForget()
        Variant of initTransactions() that ignores the result of the operation.

        This method subscribes on the result of initTransactions(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from initTransactions() but you don't need to compose it with other operations.

        Returns:
        the instance of KafkaProducer to chain method calls.
      • beginTransaction

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> beginTransaction()
        Starts a new kafka transaction. See beginTransaction()

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • beginTransactionAndAwait

        public Void beginTransactionAndAwait()
        Blocking variant of beginTransaction().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • beginTransactionAndForget

        public KafkaProducer<K,​V> beginTransactionAndForget()
        Variant of beginTransaction() that ignores the result of the operation.

        This method subscribes on the result of beginTransaction(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from beginTransaction() but you don't need to compose it with other operations.

        Returns:
        the instance of KafkaProducer to chain method calls.
      • commitTransaction

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> commitTransaction()
        Commits the ongoing transaction. See commitTransaction()

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • commitTransactionAndAwait

        public Void commitTransactionAndAwait()
        Blocking variant of commitTransaction().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • commitTransactionAndForget

        public KafkaProducer<K,​V> commitTransactionAndForget()
        Variant of commitTransaction() that ignores the result of the operation.

        This method subscribes on the result of commitTransaction(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from commitTransaction() but you don't need to compose it with other operations.

        Returns:
        the instance of KafkaProducer to chain method calls.
      • abortTransaction

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> abortTransaction()
        Aborts the ongoing transaction. See KafkaProducer

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • abortTransactionAndAwait

        public Void abortTransactionAndAwait()
        Blocking variant of abortTransaction().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • abortTransactionAndForget

        public KafkaProducer<K,​V> abortTransactionAndForget()
        Variant of abortTransaction() that ignores the result of the operation.

        This method subscribes on the result of abortTransaction(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from abortTransaction() but you don't need to compose it with other operations.

        Returns:
        the instance of KafkaProducer to chain method calls.
      • setWriteQueueMaxSize

        public KafkaProducer<K,​V> setWriteQueueMaxSize​(int i)
        Specified by:
        setWriteQueueMaxSize in interface WriteStream<K>
        Parameters:
        i - the max size of the write stream
        Returns:
        a reference to this, so the API can be used fluently
      • send

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.kafka.client.producer.RecordMetadata> send​(KafkaProducerRecord<K,​V> record)
        Asynchronously write a record to a topic

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        record - record to write
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • sendAndAwait

        public io.vertx.kafka.client.producer.RecordMetadata sendAndAwait​(KafkaProducerRecord<K,​V> record)
        Blocking variant of send(io.vertx.mutiny.kafka.client.producer.KafkaProducerRecord).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        record - record to write
        Returns:
        the RecordMetadata instance produced by the operation.
      • partitionsFor

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<List<io.vertx.kafka.client.common.PartitionInfo>> partitionsFor​(String topic)
        Get the partition metadata for the give topic.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        topic - topic partition for which getting partitions info
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • partitionsForAndAwait

        public List<io.vertx.kafka.client.common.PartitionInfo> partitionsForAndAwait​(String topic)
        Blocking variant of partitionsFor(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        topic - topic partition for which getting partitions info
        Returns:
        the List instance produced by the operation.
      • partitionsForAndForget

        public KafkaProducer<K,​V> partitionsForAndForget​(String topic)
        Variant of partitionsFor(String) that ignores the result of the operation.

        This method subscribes on the result of partitionsFor(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from partitionsFor(String) but you don't need to compose it with other operations.

        Parameters:
        topic - topic partition for which getting partitions info
        Returns:
        the instance of KafkaProducer to chain method calls.
      • flush

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> flush()
        Invoking this method makes all buffered records immediately available to write

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • flushAndAwait

        public Void flushAndAwait()
        Blocking variant of flush().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • flushAndForget

        public KafkaProducer<K,​V> flushAndForget()
        Variant of flush() that ignores the result of the operation.

        This method subscribes on the result of flush(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from flush() but you don't need to compose it with other operations.

        Returns:
        the instance of KafkaProducer to chain method calls.
      • close

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> close()
        Close the producer

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • closeAndAwait

        public Void closeAndAwait()
        Blocking variant of close().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • closeAndForget

        public void closeAndForget()
        Variant of close() that ignores the result of the operation.

        This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

      • close

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> close​(long timeout)
        Close the producer

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        timeout - timeout to wait for closing
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • closeAndAwait

        public Void closeAndAwait​(long timeout)
        Blocking variant of close(long).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        timeout - timeout to wait for closing
        Returns:
        the Void instance produced by the operation.
      • closeAndForget

        public void closeAndForget​(long timeout)
        Variant of close(long) that ignores the result of the operation.

        This method subscribes on the result of close(long), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close(long) but you don't need to compose it with other operations.

        Parameters:
        timeout - timeout to wait for closing
      • newInstance

        public static <K,​V> KafkaProducer<K,​V> newInstance​(io.vertx.kafka.client.producer.KafkaProducer arg)
      • newInstance

        public static <K,​V> KafkaProducer<K,​V> newInstance​(io.vertx.kafka.client.producer.KafkaProducer arg,
                                                                       TypeArg<K> __typeArg_K,
                                                                       TypeArg<V> __typeArg_V)