- Read the javadoc of KafkaConsumer to know how to use the Consumer API (to consume messages from Kafka)
- Create a new Scala/sbt project in IntelliJ IDEA
- Define dependency for Kafka Clients API library
- Use mvnrepository to know the proper entry for
kafka-clients
dependency
- Use mvnrepository to know the proper entry for
- Write a Kafka consumer
- Name of the object: KafkaConsumerApp
- Start with an empty
Properties
object and fill out the missing properties per exceptions at runtime - Use ConsumerConfig constants (not string values for properties)
- Don't forget to
close
the consumer (so the messages are actually acknowledged to the broker)
- Run the Kafka consumer
- Use
kafka-console-producer
to produce messages
- Use
- Fix the slf4j logging errors
- Define dependencies for
slf4j-api
andslf4j-log4j12
inbuild.sbt
- Create
src/main/resources/log4j.properties
as the configuration file - Use Apache Kafka's
config/log4j.properties
as the sample (4 first non-comment lines)
- Define dependencies for
Duration: 30 mins