In this step of Get Started Using Amazon MSK, you produce and consume data.
To produce and consume messages
-
Run the following command to start a console producer. Replace
BootstrapServerString
with the plaintext connection string that you obtained in Create a topic. For instructions on how to retrieve this connection string, see Getting the bootstrap brokers for an Amazon MSK cluster.<path-to-your-kafka-installation>
/bin/kafka-console-producer.sh --broker-listBootstrapServerString
--producer.config client.properties --topicMSKTutorialTopic
-
Enter any message that you want, and press Enter. Repeat this step two or three times. Every time you enter a line and press Enter, that line is sent to your Apache Kafka cluster as a separate message.
-
Keep the connection to the client machine open, and then open a second, separate connection to that machine in a new window.
-
In the following command, replace
BootstrapServerString
with the plaintext connection string that you saved earlier. Then, to create a console consumer, run the following command with your second connection to the client machine.<path-to-your-kafka-installation>
/bin/kafka-console-consumer.sh --bootstrap-serverBootstrapServerString
--consumer.config client.properties --topicMSKTutorialTopic
--from-beginningYou start seeing the messages you entered earlier when you used the console producer command.
-
Enter more messages in the producer window, and watch them appear in the consumer window.
Next Step
Step 6: Use Amazon CloudWatch to view Amazon MSK metrics