December 2018
Beginner
186 pages
4h 10m
English
Now, to incorporate the serializer in our producer, there are two requisites that all Kafka producers should fulfill: to be a KafkaProducer, and to set the specific properties, such as Listing 4.12.
The following is the content of Listing 4.12, the constructor method for CustomProducer:
import kioto.serde.HealthCheckSerializer;import org.apache.kafka.clients.producer.KafkaProducer;import org.apache.kafka.clients.producer.Producer;import org.apache.kafka.common.serialization.StringSerializer;public final class CustomProducer { private final Producer<String, HealthCheck> producer; public CustomProducer(String brokers) { Properties props = new Properties(); props.put("bootstrap.servers", brokers); //1 props.put("key.serializer", ...Read now
Unlock full access