At-most-once delivery sends each record zero or one time. The sender does not wait for an acknowledgment, so a record may be lost but is not redelivered. section 3.2.1
The guarantee becomes visible in two practical cases:
- Actor messages sent to dead letters receive only best-effort delivery; a stopped recipient cannot process them. section 3.2.1
- Kafka production through Producer.plainSink writes records without the stronger commit or transactional guarantees provided by other sinks. section 14.5
- A failed worker may produce no response, while a manager observes a timeout rather than a duplicate response. section 3.2.1
Producing records to Kafka
Create ProducerSettings with StringSerializer instances and a bootstrap server, wrap values in ProducerRecord objects, and run the stream with Producer.plainSink. A listener such as kcat can observe the records written to the topic. section 14.2.1
Listing 14.2 plainSink producing to Kafka from the KafkaSpec test
import org.apache.kafka.common.serialization.StringSerializer
import org.apache.kafka.clients.producer.ProducerRecord
class KafkaSpec ... {
...
"a producer" should "write to Kafka" in {
val config =
system.settings.config.getConfig("akka.kafka.producer") #1
val topicDest =
system.settings.config.getString("kafka.test.topic") #2
val producerSettings = ProducerSettings( #3
config, #3
new StringSerializer(), #3
new StringSerializer()).withBootstrapServers("127.0.0.1:9092") #3
val done: Future[Done] = Source(1 to 10)
.map(_.toString)
.map(elem => new ProducerRecord[String, String](topicDest, elem)) #4
.runWith(Producer.plainSink(producerSettings)) #5
Await.ready(done, 3.second)
}
...
}
The producer test shows the complete path from Kafka configuration and ProducerRecord construction to running a source with plainSink. section 14.2.1




