Kafka-producers

Introductie tot Apache Kafka

Mike Metzger

Data Engineering Consultant

Wat is een producer?

  • Schrijft berichten naar Kafka-topics
    • Ook wel publisher genoemd
  • Berichten van producers worden op Kafka opgeslagen voor later gebruik
  • Je kunt veel producers hebben
  • Producers kunnen naar één of meerdere topics schrijven
Introductie tot Apache Kafka

Typen producers

  • Veel soorten producers
    • Command-line
      • kafka-console-producer.sh
    • Python
    • Java
    • Veel andere talen
    • Kafka Connect
Introductie tot Apache Kafka

kafka-console-producer.sh

  • Te vinden in de map bin/, met andere Kafka-tools
    • bin/kafka-console-producer.sh
  • Diverse command-line-opties; sommige verplicht, andere niet
  • Verplichte opties:
    • --bootstrap-server - Welke server te gebruiken
      • --bootstrap-server localhost:9092
    • --topic
      • --topic phishing-sites
  • Opent standaard een sessie waarin je berichten kunt typen
    • Gebruik Ctrl-C om af te sluiten
  • Je kunt ook het symbool | gebruiken om berichten door te geven
Introductie tot Apache Kafka

Voorbeeld

  • Interactief voorbeeld
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>
  • Niet-interactief
echo "This is the first message" |
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic testing
Introductie tot Apache Kafka

Laten we oefenen!

Introductie tot Apache Kafka

Preparing Video For Download...