ProducerRecord packages a value with its Kafka destination. A producer stream converts each element into a record, allowing messages to target one or several topics. section 14.2.1
Writing stream elements to Kafka
Configure ProducerSettings with serializers and a bootstrap server, then map stream values to records: Source(1 to 10).map(_.toString).map(elem => new ProducerRecord[String, String]("test", elem)).runWith(Producer.plainSink(producerSettings)). The sink consumes ProducerRecord values and completes with Future[Done]. section 14.2.1
class KafkaSpec ... {
...
Source(1 to 10)
.map(_.toString)
.map(elem => new ProducerRecord[String, String]("test", elem))
.runWith(Producer.plainSink(producerSettings))
...
}
A minimal Akka Streams construction shows the record’s generic key and value types, destination topic, and placement in the producer pipeline. section 14.2.1
Projection handlers use the same type for richer events: serialize a market event to Array[Byte], create a record with the topic, market identifier, and serialized value, then send it through SendProducer. The key supports event routing, while protobuf supplies the serialized payload. section 15.1.2
