class

Kafka::Producer

Inherits Reference / Object

Constants

DEFAULT_POLL_INTERVAL_SECONDS = 5

Constructors

new(config : Hash(String, String), stats_path = "", poll_interval : Int32 = DEFAULT_POLL_INTERVAL_SECONDS)
Source

Instance methods

finalize

Destroy the Kafka handle.

Calls the rd_kafka_destroy C function.

Source
flush(timeout = 1000)

Wait until all outstanding produce requests, et.al, are completed. This should typically be done prior to destroying a producer instance to make sure all queued and in-flight produce requests are completed before terminating.

Calls the rd_kafka_flush C function.

Source
poll(timeout = 500)

Polls the Kafka handle for events

An application should make sure to call #poll at regular intervals to serve any queued callbacks waiting to be called.

Source
produce(topic : String, key : Bytes, payload : Bytes, timestamp : Int64)

Produce and send a single message to broker.

Raises a Kafka::ProducerException when produce fails. Calls the rd_kafka_producev C function.

Source
produce(topic : String, key : Bytes, payload : Bytes)

Produce and send a single message to broker.

Raises a Kafka::ProducerException when produce fails. Calls the rd_kafka_producev C function.

Source
produce(topic : String, payload : Bytes)

Produce and send a single message to broker.

Raises a Kafka::ProducerException when produce fails. Calls the rd_kafka_producev C function.

Source
produce(topic : String, msg : Message)

Produce and send a single message to broker.

Raises a Kafka::ProducerException when produce fails. Calls the rd_kafka_produce C function.

Source
produce_batch(topic : String, batch : Array(NamedTuple(key: Array(UInt8), msg: Array(UInt8))))

Produce and send multiple messages to broker.

Raises a Kafka::ProducerException when produce fails. Calls the rd_kafka_produce C function.

Source

Nested types