This is the code repository for the Restate conference talk "The simplest way to write resilient applications".
This presentation was given at:
- JCON 2025
- Spring I/O 2025: YouTube recording
The code base shows 5 different use cases/patterns that can be implemented with Restate:
- Workflows/Sagas: SubscriptionService and SubscriptionSaga
- Concurrent Async Tasks: Email verification
- Long-running workflows on Kafka: ClaimProcessor
- Stateful entities: PackageTracker
Run Restate at the root of this repo. Have a look at the installation docs for the installation options:
restate-server --config-file restate.tomlRegister the service
restate deployments register http://localhost:9080Send a request:
curl localhost:8080/SubscriptionService/add \
--json '{
"creditCard": "1111-2222-3333-4444",
"subscriptions": [
"Prime", "Hulu", "Netflix"
],
"userId": "giselle"
}'Check the retries in the UI at localhost:9070.
Remove the RuntimeException in the SubscriptionClient to see the invocation succeed.
Send a request
curl localhost:8080/SubscriptionSaga/add \
--json '{
"creditCard": "1111-2222-3333-4444",
"subscriptions": [
"Prime", "Hulu", "Disney"
],
"userId": "eric"
}'Send a request
curl localhost:8080/EmailVerification/verifyEmail \
--json '{
"email": "[email protected]",
"userId": "giselle"
}'Bring up Kafka with the two topics (claims and package-location-updates):
docker compose up -dLet Restate subscribe to the topic
curl localhost:9070/subscriptions --json '{
"source": "kafka://my-cluster/claims",
"sink": "service://ClaimProcessor/submit",
"options": {"auto.offset.reset": "latest"}
}'
curl localhost:9070/subscriptions --json '{
"source": "kafka://my-cluster/package-location-updates",
"sink": "service://PackageTracker/updateLocation",
"options": {"auto.offset.reset": "latest"}
}'Let's submit some posts for two different users:
echo -e 'userid1:{"description": "Fire damage to kitchen", "category": "Property"}' | docker exec -i broker bash -c "kafka-console-producer --bootstrap-server broker:29092 --topic claims --property parse.key=true --property key.separator=:"
echo -e 'userid2:{"description": "Car accident on highway", "category": "Auto"}' | docker exec -i broker bash -c "kafka-console-producer --bootstrap-server broker:29092 --topic claims --property parse.key=true --property key.separator=:"Register a new package via the RPC handler:
curl localhost:8080/PackageTracker/package123/registerPackage \
--json '{"finalDestination": "Bridge 6, Amsterdam"}'echo -e 'package123:{"timestamp": "2024-10-10 13:00", "location": "Pinetree Road 5, Paris"}' | docker exec -i broker bash -c "kafka-console-producer --bootstrap-server broker:29092 --topic package-location-updates --property parse.key=true --property key.separator=:"
echo -e 'package123:{"timestamp": "2024-10-10 14:00", "location": "Mountain Road 155, Brussels"}' | docker exec -i broker bash -c "kafka-console-producer --bootstrap-server broker:29092 --topic package-location-updates --property parse.key=true --property key.separator=:"Query the package location via the RPC handler:
curl localhost:8080/PackageTracker/package123/getPackageInfo | jq .