Kafka のプロデューサー

Apache Kafka 入門

Mike Metzger

Data Engineering Consultant

プロデューサーとは

  • メッセージを Kafka のトピックに書き込みます
    • パブリッシャーとも呼ばれます
  • 送信されたメッセージは後で使えるよう Kafka に保存されます
  • プロデューサーは多数存在可能
  • 1 つまたは複数のトピックに書き込み可能
Apache Kafka 入門

プロデューサーの種類

  • さまざまな種類のプロデューサー
    • コマンドライン
      • kafka-console-producer.sh
    • Python
    • Java
    • その他多くの言語
    • Kafka Connect
Apache Kafka 入門

kafka-console-producer.sh

  • 他の Kafka ツールと同じ bin/ フォルダにあります
    • bin/kafka-console-producer.sh
  • 必須と任意のコマンドラインオプションがあります
  • 必須オプション:
    • --bootstrap-server - 使用するサーバーを指定
      • --bootstrap-server localhost:9092
    • --topic
      • --topic phishing-sites
  • 既定ではメッセージを入力できる対話型接続を開きます
    • 終了は Ctrl-C
  • | 記号でメッセージを渡すことも可能
Apache Kafka 入門

  • 対話型の例
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic testing
>This is the first message
>This is the second message
>This is the third message
<ctrl+c to exit>
  • 非対話型
echo "This is the first message" |
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic testing
Apache Kafka 入門

演習に進みましょう

Apache Kafka 入門

Preparing Video For Download...