- Download kafka
https://kafka.apache.org/downloads
- Start Zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
- Start Kafka
bin/kafka-server-start.sh config/server.properties
- Create Topic
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic orchestrator
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic orchestrator.response
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic payment
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic payment.success
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic payment.dlt
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic payment.compensation
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic stock
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic stock.success
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic stock.dlt
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --topic stock.compensation
// check topic
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
- Create Database
// Use same DB Instance.
create database order_orchestratordb;
create database orderdb;
create database stockdb;
create database paymentdb;
- Start Spring boot
order-orchestrator(8080)
order-service(8081)
payment-service(8082)
stock-service(8083)
answer: Logic to run periodically rather than immediately responding. For example, suppose Compensation. Compensation for Payment is executed in two cases.
- payment-service(success) -> stock-service(fail) --> payment compensation.
- stock-service(fail) -> payment-service(success) --> payment compensation.
A duplicate message may be issued instantaneously according to a stock-service failure time point.