

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用身分驗證產生和使用訊息
<a name="msk-authentication-messages"></a>

此程序說明如何使用身分驗證產生和取用訊息。

1. 執行下列命令以建立主題。名為的檔案 `client.properties` 是您在上一個程序中建立的檔案。

   ```
   <path-to-your-kafka-installation>/bin/kafka-topics.sh --create --bootstrap-server BootstrapBroker-String --replication-factor 3 --partitions 1 --topic ExampleTopic --command-config client.properties
   ```

1. 執行下列命令以啟動主控台生產者。名為的檔案 `client.properties` 是您在上一個程序中建立的檔案。

   ```
   <path-to-your-kafka-installation>/bin/kafka-console-producer.sh --bootstrap-server BootstrapBroker-String --topic ExampleTopic --producer.config client.properties
   ```

1. 在用戶端機器的新命令視窗中，執行下列命令以啟動主控台取用者。

   ```
   <path-to-your-kafka-installation>/bin/kafka-console-consumer.sh --bootstrap-server BootstrapBroker-String --topic ExampleTopic --consumer.config client.properties
   ```

1. 在生產者視窗中輸入訊息，並觀看訊息出現在取用者視窗中。