Infrastructure
(cd 001_fragile_data_integrations/business_transactions/before && docker compose up -d)
Database
cockroach sql --insecure < 001_fragile_data_integrations/business_transactions/before/create.sql
Start app
go run 001_fragile_data_integrations/business_transactions/before/main.go
Successful order
curl 'localhost:3000/orders' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": false, "reservations": false, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa')"
Error during order creation
curl 'localhost:3000/orders' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": true, "payments": false, "reservations": false, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb')"
Error during payment
curl 'localhost:3000/orders' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "cccccccc-cccc-cccc-cccc-cccccccccccc",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": true, "reservations": false, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('cccccccc-cccc-cccc-cccc-cccccccccccc')"
Error during reservation
curl 'localhost:3000/orders' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "dddddddd-dddd-dddd-dddd-dddddddddddd",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": false, "reservations": true, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('dddddddd-dddd-dddd-dddd-dddddddddddd')"
Error during shipment
curl 'localhost:3000/orders' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": false, "reservations": false, "shipments": true }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee')"
Infrastructure
(cd 001_fragile_data_integrations/business_transactions/after && docker compose up -d)
Database
enterprise --url "postgres://root@localhost:26257/?sslmode=disable"
cockroach sql --insecure < 001_fragile_data_integrations/business_transactions/after/create.sql
Create topic
kafkactl create topic sagas
Start app
go run 001_fragile_data_integrations/business_transactions/after/main.go
Successful saga
curl 'localhost:3000/sagas' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": false, "reservations": false, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa')"
Error during order creation
curl 'localhost:3000/sagas' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": true, "payments": false, "reservations": false, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb')"
Error during payment
curl 'localhost:3000/sagas' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "cccccccc-cccc-cccc-cccc-cccccccccccc",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": true, "reservations": false, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('cccccccc-cccc-cccc-cccc-cccccccccccc')"
Error during reservation
curl 'localhost:3000/sagas' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "dddddddd-dddd-dddd-dddd-dddddddddddd",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": false, "reservations": true, "shipments": false }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('dddddddd-dddd-dddd-dddd-dddddddddddd')"
Error during shipment
curl 'localhost:3000/sagas' \
-H 'Content-Type:application/json' \
-d '{
"order_id": "eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee",
"payment": 26.97,
"products": [
{ "id": "acd43cb9-2e14-4036-9e9d-d3ff9e89a9b7", "quantity": 1 },
{ "id": "b4fc9665-2ac5-4580-a618-ddb8b0440ebe", "quantity": 2 }
],
"failures": { "orders": false, "payments": false, "reservations": false, "shipments": true }
}'
Check database
cockroach sql --insecure -e "SELECT check_order('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee')"
Clear down all tables
cockroach sql --insecure -e "DELETE FROM shipments WHERE true; DELETE FROM reservations WHERE true; DELETE FROM payments WHERE true; DELETE FROM orders WHERE true;"