This is a sample application for the "Aecor - Purely functional event sourcing in Scala" post series.
Infrastructure for the app includes postgres and kafka, so you'll need either
- docker-compose (recommended)
- or have both postgres and kafka installed locally.
- Launch infrastructure using compose (in the project folder):
docker-compose up -d
- If you are using
docker-compose
on macOS or Windows you should also forward all ports used indocker-compose.yml
file (to be able to reach all Docker containers via localhost address). You can do this viadocker-machine
CLI or by a script such as docker-machine-port-forwarder:
pf 5432
pf 2181
pf 9092
- Run the app
sbt booking/run
There are http endpoints you can call
curl --request POST \
--url http://localhost:9000/clientA/bookings \
--header 'content-type: application/json' \
--data '{
"concertId": "concertA",
"seats": [
{
"row": 1,
"number": 2
},
{
"row": 1,
"number": 3
}
]
}'
curl --request GET \
--url http://localhost:9000/clientA/bookings
Payments are received from another service via PaymentReceived topic, so to emulate a payment we'll need to produce a message:
docker exec -it ticket-booking-aecor_kafka_1 /bin/bash
$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic PaymentReceived
{"clientId":"clientA", "paymentId":"12345", "bookingId": "<your_booking_id>"}