KafkaProducer

abstract class KafkaProducer[F[_], K, V]

KafkaProducer represents a producer of Kafka records, with the ability to produce ProducerRecords using produce. Records are wrapped in ProducerRecords which allow an arbitrary value, that is a passthrough, to be included in the result. Most often this is used for keeping the CommittableOffsets, in order to commit offsets, but any value can be used as passthrough value.

Companion:
object
Source:
KafkaProducer.scala
class Object
trait Matchable
class Any
class Metrics[F, K, V]

Value members

Abstract methods

def produce[P](records: ProducerRecords[P, K, V]): F[F[ProducerResult[P, K, V]]]

Produces the specified ProducerRecords in two steps: the first effect puts the records in the buffer of the producer, and the second effect waits for the records to send.

Produces the specified ProducerRecords in two steps: the first effect puts the records in the buffer of the producer, and the second effect waits for the records to send.

It's possible to flatten the result from this function to have an effect which both sends the records and waits for them to finish sending.

Waiting for individual records to send can substantially limit performance. In some cases, this is necessary, and so we might want to consider the following alternatives.

  • Wait for the produced records in batches, improving the rate at which records are produced, but loosing the guarantee where produce >> otherAction means otherAction executes after the record has been sent.
  • Run several produce.flatten >> otherAction concurrently, improving the rate at which records are produced, and still have otherAction execute after records have been sent, but losing the order of produced records.
Source:
KafkaProducer.scala

Concrete methods

def produceOne[P](topic: String, key: K, value: V, passthrough: P): F[F[ProducerResult[P, K, V]]]
Implicitly added by ProducerOps

Produce a single record to the specified topic using the provided key and value, see KafkaProducer.produce for general semantics.

Produce a single record to the specified topic using the provided key and value, see KafkaProducer.produce for general semantics.

Source:
KafkaProducer.scala
def produceOne[P](record: ProducerRecord[K, V], passthrough: P): F[F[ProducerResult[P, K, V]]]
Implicitly added by ProducerOps

Produce a single ProducerRecord, see KafkaProducer.produce for general semantics.

Produce a single ProducerRecord, see KafkaProducer.produce for general semantics.

Source:
KafkaProducer.scala
def produceOne_(record: ProducerRecord[K, V])(implicit F: Functor[F]): F[F[RecordMetadata]]
Implicitly added by ProducerOps

Produce a single ProducerRecord without a passthrough value, see KafkaProducer.produce for general semantics.

Produce a single ProducerRecord without a passthrough value, see KafkaProducer.produce for general semantics.

Source:
KafkaProducer.scala
def produceOne_(topic: String, key: K, value: V)(implicit F: Functor[F]): F[F[RecordMetadata]]
Implicitly added by ProducerOps

Produce a single record to the specified topic using the provided key and value without a passthrough value, see KafkaProducer.produce for general semantics.

Produce a single record to the specified topic using the provided key and value without a passthrough value, see KafkaProducer.produce for general semantics.

Source:
KafkaProducer.scala
def produce_(records: ProducerRecords[_, K, V])(implicit F: Functor[F]): F[F[Chunk[(ProducerRecord[K, V], RecordMetadata)]]]
Implicitly added by ProducerOps

Produces the specified ProducerRecords without a passthrough value, see KafkaProducer.produce for general semantics.

Produces the specified ProducerRecords without a passthrough value, see KafkaProducer.produce for general semantics.

Source:
KafkaProducer.scala