刘凡 3282579ec1 first commit | 2 jaren geleden | |
---|---|---|
.. | ||
detector | 2 jaren geleden | |
generator | 2 jaren geleden | |
.gitignore | 2 jaren geleden | |
LICENSE | 2 jaren geleden | |
README.md | 2 jaren geleden | |
docker-compose.kafka.yml | 2 jaren geleden | |
docker-compose.yml | 2 jaren geleden |
This is the supporting repository for my blog post: Building A Streaming Fraud Detection System With Kafka And Python.
This fraud detection system is fully containerised. You will need Docker and Docker Compose to run it.
You simply need to create a Docker network called kafka-network
to enable communication between the Kafka cluster and the apps:
$ docker network create kafka-network
All set!
$ docker-compose -f docker-compose.kafka.yml up -d
$ docker-compose -f docker-compose.kafka.yml logs -f broker | grep "started"
$ docker-compose up -d
Show a stream of transactions in the topic T
(optionally add --from-beginning
):
$ docker-compose -f docker-compose.kafka.yml exec broker kafka-console-consumer --bootstrap-server localhost:9092 --topic T
Topics:
queuing.transactions
: raw generated transactionsstreaming.transactions.legit
: legit transactionsstreaming.transactions.fraud
: suspicious transactionsExample transaction message:
{"source": "yGfZ1Xa6k1r0", "target": "N5RvY7RO5sQF", "amount": 217.46, "currency": "EUR"}
To stop the transaction generator and fraud detector:
$ docker-compose down
To stop the Kafka cluster (use down
instead to also remove contents of the topics):
$ docker-compose -f docker-compose.kafka.yml stop
To remove the Docker network:
$ docker network rm kafka-network