项目作者: piomin

项目描述 :
implementation of partitioning mechanism on Apache Kafka and asynchronous communication between Vert.x microservices
高级语言: Java
项目地址: git://github.com/piomin/sample-vertx-kafka-messaging.git
创建时间: 2018-01-26T09:37:10Z
项目社区:https://github.com/piomin/sample-vertx-kafka-messaging

开源协议:

下载


Partitioning with Apache Kafka and Vert.x

Detailed description can be found here: Partitioning with Apache Kafka and Vert.x

Vert.x + Kafka — Order Processing Demo

A demonstration of using Eclipse Vert.x with Apache Kafka for an order processing pipeline. The order-service module exposes a REST endpoint to submit orders, which are sent to a Kafka topic; multiple consumer verticles process orders from different partitions to illustrate ordered and parallel consumption.

🗂️ Modules

Path Description
order-service REST API → produces to orders-out
order-processor Consumes partition 0
multiple-order-processor Consumes partition 1
all-order-processor Consumes all partitions

✅ Prerequisites

  • Java 21
  • Maven 3.9+
  • Running Kafka broker (defaults to 192.168.99.100:9092)

⚡ Quick Start

  1. # Start Zookeeper (if needed)
  2. docker run -d --name zookeeper -p 2181:2181 zookeeper:3.5
  3. # Start single-node Kafka
  4. docker run -d --name kafka -p 9092:9092 \
  5. --link zookeeper:zookeeper \
  6. -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
  7. -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.99.100:9092 \
  8. -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
  9. confluentinc/cp-kafka:latest
  10. # Build all modules
  11. mvn clean package
  12. # Run verticles
  13. java -jar order-service/target/order-service-*.jar
  14. java -jar order-processor/target/order-processor-*.jar
  15. java -jar multiple-order-processor/target/multiple-order-processor-*.jar
  16. java -jar all-order-processor/target/all-order-processor-*.jar

🏗️ Architecture

  1. flowchart LR
  2. Client --> OS[order-service]
  3. OS -->|JSON order| KT["Kafka<br/>orders-out"]
  4. subgraph Consumers
  5. SOP["order-processor<br/>partition 0"]
  6. MOP["multiple-order-processor<br/>partition 1"]
  7. AOP["all-order-processor<br/>all partitions"]
  8. end
  9. KT --> SOP
  10. KT --> MOP
  11. KT --> AOP

🔧 Configuration

Key Default How to override
bootstrap.servers 192.168.99.100:9092 env KAFKA_BOOTSTRAP_SERVERS
topic orders-out env KAFKA_TOPIC

🔍 Testing

Consume messages from the orders-out topic using the Kafka console consumer:

  1. kafka-console-consumer --bootstrap-server 192.168.99.100:9092 \
  2. --topic orders-out --from-beginning

📜 License

MIT © Piotr Mińkowski