Producer

trait Producer
Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def flush: Task[Unit]

Flushes the producer's internal buffer. This will guarantee that all records currently buffered will be transmitted to the broker.

Flushes the producer's internal buffer. This will guarantee that all records currently buffered will be transmitted to the broker.

def metrics: Task[Map[MetricName, Metric]]

Expose internal producer metrics

Expose internal producer metrics

def produce[R, K, V](record: ProducerRecord[K, V], keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): RIO[R, RecordMetadata]

Produces a single record and await broker acknowledgement. See produceAsync for version that allows to avoid round-trip-time penalty for each record.

Produces a single record and await broker acknowledgement. See produceAsync for version that allows to avoid round-trip-time penalty for each record.

def produce[R, K, V](topic: String, key: K, value: V, keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): RIO[R, RecordMetadata]

Produces a single record and await broker acknowledgement. See produceAsync for version that allows to avoid round-trip-time penalty for each record.

Produces a single record and await broker acknowledgement. See produceAsync for version that allows to avoid round-trip-time penalty for each record.

def produceAsync[R, K, V](record: ProducerRecord[K, V], keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): RIO[R, Task[RecordMetadata]]

Produces a single record. The effect returned from this method has two layers and describes the completion of two actions:

Produces a single record. The effect returned from this method has two layers and describes the completion of two actions:

  1. The outer layer describes the enqueueing of the record to the Producer's internal buffer. 2. The inner layer describes receiving an acknowledgement from the broker for the transmission of the record.

It is usually recommended to not await the inner layer of every individual record, but enqueue a batch of records and await all of their acknowledgements at once. That amortizes the cost of sending requests to Kafka and increases throughput. See produce for version that awaits broker acknowledgement.

def produceAsync[R, K, V](topic: String, key: K, value: V, keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): RIO[R, Task[RecordMetadata]]

Produces a single record. The effect returned from this method has two layers and describes the completion of two actions:

Produces a single record. The effect returned from this method has two layers and describes the completion of two actions:

  1. The outer layer describes the enqueueing of the record to the Producer's internal buffer. 2. The inner layer describes receiving an acknowledgement from the broker for the transmission of the record.

It is usually recommended to not await the inner layer of every individual record, but enqueue a batch of records and await all of their acknowledgements at once. That amortizes the cost of sending requests to Kafka and increases throughput. See produce for version that awaits broker acknowledgement.

def produceChunk[R, K, V](records: Chunk[ProducerRecord[K, V]], keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): RIO[R, Chunk[RecordMetadata]]

Produces a chunk of records. See produceChunkAsync for version that allows to avoid round-trip-time penalty for each chunk.

Produces a chunk of records. See produceChunkAsync for version that allows to avoid round-trip-time penalty for each chunk.

def produceChunkAsync[R, K, V](records: Chunk[ProducerRecord[K, V]], keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): RIO[R, Task[Chunk[RecordMetadata]]]

Produces a chunk of records. The effect returned from this method has two layers and describes the completion of two actions:

Produces a chunk of records. The effect returned from this method has two layers and describes the completion of two actions:

  1. The outer layer describes the enqueueing of all the records to the Producer's internal buffer. 2. The inner layer describes receiving an acknowledgement from the broker for the transmission of the records.

It is possible that for chunks that exceed the producer's internal buffer size, the outer layer will also signal the transmission of part of the chunk. Regardless, awaiting the inner layer guarantees the transmission of the entire chunk.

Concrete methods

def produceAll[R, K, V](keySerializer: Serializer[R, K], valueSerializer: Serializer[R, V]): ZTransducer[R, Throwable, ProducerRecord[K, V], RecordMetadata]

A stream transducer that produces all records from the stream.

A stream transducer that produces all records from the stream.