Produce and consume data in MSK Serverless
In this step, you produce and consume data using the topic that you created in the previous step.
To produce and consume messages
-
Run the following command to create a console producer.
<path-to-your-kafka-installation>
/bin/kafka-console-producer.sh --broker-list $BS --producer.config client.properties --topic msk-serverless-tutorial -
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 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.
-
Use your second connection to the client machine to create a console consumer with the following command. Replace
my-endpoint
with the bootstrap server string that you saved after you created the cluster.<path-to-your-kafka-installation>
/bin/kafka-console-consumer.sh --bootstrap-servermy-endpoint
--consumer.config client.properties --topic msk-serverless-tutorial --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
Delete resources that you created for MSK Serverless