August 2017
Beginner to intermediate
278 pages
6h 40m
English
Again, the producer is the same as we used in Chapter 5, Building Spark Streaming Applications with Kafka, and Chapter 6, Building Storm Application with Kafka, which generates records with random IPs. The producer will auto-create the topic if it does not exist. Here is how the code goes:
package com.packt.Kafka.producer;import com.packt.Kafka.utils.PropertyReader;import org.apache.Kafka.clients.producer.KafkaProducer;import org.apache.Kafka.clients.producer.ProducerRecord;import org.apache.Kafka.clients.producer.RecordMetadata;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.*;import java.util.concurrent.Future;public class IPLogProducer extends TimerTask { public ...
Read now
Unlock full access