Produced — Metadata for Producing Records¶
Produced<K, V> describes how to produce records in a topology in the High-Level KStream DSL for the following high-level operators:
Produced<K, V> is a NamedOperation.
Demo¶
import org.apache.kafka.common.serialization.Serdes
import org.apache.kafka.streams.kstream.Produced
val produced = Produced.`with`(Serdes.Long, Serdes.String)
scala> :type produced
org.apache.kafka.streams.kstream.Produced[Long,String]
Creating Instance¶
Produced takes the following to be created:
-
Serde<K>of keys (Apache Kafka) -
Serde<V>of values (Apache Kafka) - StreamPartitioner
- Processor Name
Produced is created using the factories.
Creating Consumed¶
as¶
Produced<K, V> as(
String processorName)
with¶
Produced<K, V> with(
Serde<K> keySerde,
Serde<V> valueSerde)
Produced<K, V> with(
Serde<K> keySerde,
Serde<V> valueSerde,
StreamPartitioner<? super K, ? super V> partitioner)
keySerde¶
Produced<K, V> keySerde(
Serde<K> keySerde)
valueSerde¶
Produced<K, V> valueSerde(
Serde<V> valueSerde)
streamPartitioner¶
Produced<K, V> streamPartitioner(
StreamPartitioner<? super K, ? super V> partitioner)
Scala API¶
Scala API for Kafka Streams makes the optional Produced metadata an implicit parameter in the KStream API.
Moreover, ImplicitConversions object defines producedFromSerde implicit method that creates a Produced instance with the key and value Serde objects available in implicit scope.
And the last but not least, Scala API for Kafka Streams defines Produced object with with factory methods that use implicit key and value Serde objects.