As we already know, to build a Kafka message consumer, we use the Java client library—in particular, the consumer API (in the following chapters, we will see how to use Kafka Streams and KSQL).
Let's create a Kafka consumer that we will use to receive the input messages.
As we already know, there are two requisites that all of the Kafka consumers should have: to be a KafkaConsumer and to set the specific properties, such as those shown in Listing 4.8.
The following is the content of Listing 4.8, the constructor method for plain consumer:
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.common.serialization.StringSerializer;
public final class PlainConsumer {
private Consumer<String, String> consumer;
public PlainConsumer(String brokers) {
Properties props...