About this task
In the real-world practice, the system that produces messages to Kafka is completely decoupled. While in this scenario, Kafka itself is used to produce the sample messages. You need to perform the following operations to produce these messages:
Create the Kafka topic to be used to categorize the messages. The
following command is used for demonstration purposes only. If you need
further information about the creation of a Kafka topic, see Apache's
/usr/lib/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic activities --partitions 1 --replication-factor 1This command creates a topic named activities, using the Kafka brokers managed by the Zookeeper service on the localhost machine.
Publish the message you want to analyze to the activities topic you have just created. In this scenario,
Kafka is used to perform this publication using, for example, the following
This command publishes 10 simple messages
echo 'Ryan|M|Pool Remy|M|Drink Remy|M|Hiking Irene|F|Drink Pierre|M|Movie Irene|F|Pool Thomas|M|Drink Ryan|M|Cooking Wang|F|Cooking Chen|M|Drink | /usr/lib/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic activities
Ryan|M|Pool Remy|M|Drink Remy|M|Hiking Irene|F|Drink Pierre|M|Movie Irene|F|Pool Thomas|M|Drink Ryan|M|Cooking Wang|F|Cooking Chen|M|DrinkAs explained previously, you can use your actual message producer system instead to perform the publication.