项目作者: hands-on-tech

项目描述 :
Kafka streaming with Spark and Flink example
高级语言: Java
项目地址: git://github.com/hands-on-tech/kafka-spark-flink-example.git
创建时间: 2018-04-30T20:06:46Z
项目社区:https://github.com/hands-on-tech/kafka-spark-flink-example

开源协议:MIT License

下载


Kafka streaming with Spark and Flink example

Example project on how to use Apache Kafka and streaming consumers, namely:

  • Producer sending random number words to Kafka
  • Consumer using Kafka to output received messages
  • Streaming Consumer using Apache Spark to count words occurrences
  • Streaming Consumer using Apache Flink to count words occurrences

Requirements

  • Docker
  • Docker Compose
  • Java 8
  • Maven

Build

  1. Build Java project
    1. mvn clean package
  2. Build Docker image
    1. docker build -t kafka-spark-flink-example .

Run

  1. Start docker containers
    1. docker-compose up -d

Check

  1. Check producer logs

    1. docker logs kafka-spark-flink-example_kafka-producer_1 -f

    Output should be similar to:

    1. [main] INFO org.davidcampos.kafka.producer.KafkaProducerExample - Sent (74b23319-084c-4309-80a7-c0d6f107a092, eight) to topic example @ 1525127107909.
  2. Check consumer with Spark logs

    1. docker logs kafka-spark-flink-example_kafka-consumer-spark_1 -f

    Output should be similar to:

    1. (two,3)
    2. (one,3)
    3. (nine,5)
    4. (six,8)
    5. (three,2)
    6. (five,2)
    7. (four,9)
    8. (seven,3)
    9. (eight,6)
    10. (ten,6)
  3. Check consumer with Flink logs

    1. docker logs kafka-spark-flink-example_kafka-consumer-flink_1 -f

    Output should be similar to:

    1. 1> (ten,85)
    2. 4> (nine,104)
    3. 1> (ten,86)
    4. 4> (five,91)
    5. 4> (one,94)
    6. 4> (six,90)
    7. 1> (three,89)
    8. 4> (six,91)
    9. 4> (five,92)

Kafka Web UI

Kafka Manager Web UI available at http://localhost:9000.

Spark Web UI

Spark Web UI available at http://localhost:4040.

Stop

  1. Stop docker containers
    1. docker-compose down