TopicProducer

Writes messages to the topics of a broker: the port of the Kafka transport, which an in-memory transport also implements so the runtime's semantics are tested without a broker.

  • Acknowledged on return: send suspends until the broker has acknowledged every message, durable as the broker is configured to make it (Kafka: acks=all); it throws when one is not. A caller moves its checkpoint only after send returns.

  • Order: the messages of one key in one call reach their partition in the order given, and a later call's after an earlier call's. A retried call may write some messages again: delivery is at least once.

  • Partitions: the producer chooses the partition of a message by its key, unless the message names its own (TopicMessage.partition); the topic must exist (or the broker creates it).

Functions

Link copied to clipboard
abstract suspend fun send(topic: String, messages: List<TopicMessage>)

open suspend fun send(topic: String, message: TopicMessage)

Sends one message to topic, as send does.