📖 Scenario: You work at a company that uses Apache Kafka to handle real-time data streams. The company wants to move its Kafka deployment to the cloud to improve scalability and reliability.
🎯 Goal: Build a simple Kafka producer and consumer setup that simulates sending and receiving messages in a cloud-native environment.
📋 What You'll Learn
Create a Kafka topic named cloud_native_topic
Create a Kafka producer that sends 3 messages to cloud_native_topic
Create a Kafka consumer that reads messages from cloud_native_topic
Print the received messages to show the flow of data
💡 Why This Matters
🌍 Real World
Cloud-native Kafka deployments allow companies to handle large-scale, real-time data streams with flexibility and reliability.
💼 Career
Understanding Kafka and cloud-native deployment is valuable for roles in data engineering, cloud architecture, and real-time analytics.
Progress0 / 4 steps
1
Create Kafka topic
Create a Kafka topic named cloud_native_topic using the Kafka admin client.
Kafka
Hint
Use KafkaAdminClient and NewTopic to create the topic.
2
Create Kafka producer
Create a Kafka producer named producer that connects to localhost:9092 and sends these messages to cloud_native_topic: 'Message 1', 'Message 2', 'Message 3'.
Kafka
Hint
Use KafkaProducer and the send method to send messages.
3
Create Kafka consumer
Create a Kafka consumer named consumer that connects to localhost:9092 and subscribes to cloud_native_topic.
Kafka
Hint
Use KafkaConsumer and subscribe to 'cloud_native_topic'.
4
Print received messages
Use a for loop to read messages from consumer and print each message's value decoded as UTF-8.
Kafka
Hint
Use a for loop over consumer and decode each message's value.
Practice
(1/5)
1. Why is cloud-native deployment important for Kafka?
easy
A. It limits Kafka to single-node setups.
B. It requires Kafka to run only on physical servers.
C. It removes the need for any monitoring tools.
D. It makes Kafka easier to manage and scale in the cloud.