Skip to content

Commit 5d700bb

Browse files
Use the new workflow api in food ordering
1 parent 48d3139 commit 5d700bb

28 files changed

+358
-445
lines changed

java/food-ordering/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ Restate has a psql interface to query the state of the system.
6161

6262
If you buy some products via the webUI, you can see how the order workflow is executed by querying the state of the order status service:
6363
```shell
64-
watch -n 1 'psql -h localhost -p 9071 -c "select service, service_key_utf8, key, value_utf8 from state s where s.service='"'"'order.OrderStatusService'"'"';"'
64+
watch -n 1 'psql -h localhost -p 9071 -c "select service, service_key_utf8, key, value_utf8 from state s where s.service='"'"'examples.order.OrderStatusService'"'"';"'
6565
```
6666

6767
Or have a look at the state of all the services, except for the driver simulator:
6868
```shell
69-
watch -n 1 'psql -h localhost -p 9071 -c "select service, service_key_utf8, key, value_utf8 from state s where s.service not in ('"'"'order.DriverMobileAppSimulator'"'"');"'
69+
watch -n 1 'psql -h localhost -p 9071 -c "select service, service_key_utf8, key, value_utf8 from state s where s.service not in ('"'"'examples.order.DriverMobileAppSimulator'"'"');"'
7070
```
7171

7272
Or you can check the state of the ongoing invocations via:
@@ -77,7 +77,7 @@ watch -n 1 'psql -h localhost -p 9071 -c "select service, method, service_key_ut
7777
## Exploring the demo
7878

7979
### The order workflow
80-
You can find the implementation of each of the services under `app/restate-app/src/main/java/dev/restate/sdk/examples/`.
80+
You can find the implementation of each of the services under [`app/restate-app/src/main/java/examples/order`](app/restate-app/src/main/java/examples/order).
8181
The flow of an incoming order is as follows:
8282
1. When the customer places an order via the web UI (localhost:3000), an order event is published to Kafka.
8383
2. Restate subscribes to the order topic and triggers the order workflow for each incoming event. This subscription is set up by executing two curl commands, as done in the Docker compose file (`docker-compose.yaml`) by the `runtimesetup` container.

java/food-ordering/app/restate-app/build.gradle.kts

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ plugins {
99

1010
repositories {
1111
mavenCentral()
12+
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
1213
}
1314

14-
val restateVersion = "0.7.0"
15+
val restateVersion = "0.8.0-SNAPSHOT"
1516

1617
dependencies {
1718
// Restate SDK
19+
annotationProcessor("dev.restate:sdk-api-gen:$restateVersion")
1820
implementation("dev.restate:sdk-api:$restateVersion")
21+
implementation("dev.restate:sdk-workflow-api:$restateVersion")
1922
implementation("dev.restate:sdk-http-vertx:$restateVersion")
2023
// To use Jackson to read/write state entries (optional)
2124
implementation("dev.restate:sdk-serde-jackson:$restateVersion")
@@ -29,7 +32,7 @@ dependencies {
2932
compileOnly("org.apache.tomcat:annotations-api:6.0.53")
3033

3134
//Kafka
32-
implementation("org.apache.kafka:kafka-clients:3.0.0")
35+
implementation("org.apache.kafka:kafka-clients:3.6.1")
3336

3437
// Logging (optional)
3538
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
@@ -63,11 +66,11 @@ protobuf {
6366

6467
// Set main class
6568
application {
66-
mainClass.set("dev.restate.sdk.examples.AppMain")
69+
mainClass.set("examples.order.AppMain")
6770
}
6871

6972

7073
jib {
7174
to.image = "restate-app:0.0.1"
72-
container.mainClass = "dev.restate.sdk.examples.AppMain"
75+
container.mainClass = "examples.order.AppMain"
7376
}

java/food-ordering/app/restate-app/src/main/java/dev/restate/sdk/examples/DeliveryManager.java

-172
This file was deleted.

java/food-ordering/app/restate-app/src/main/java/dev/restate/sdk/examples/OrderWorkflow.java

-94
This file was deleted.

java/food-ordering/app/restate-app/src/main/java/dev/restate/sdk/examples/utils/TypeUtils.java

-28
This file was deleted.

java/food-ordering/app/restate-app/src/main/java/dev/restate/sdk/examples/AppMain.java java/food-ordering/app/restate-app/src/main/java/examples/order/AppMain.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
* https://github.com/restatedev/examples/
1010
*/
1111

12-
package dev.restate.sdk.examples;
12+
package examples.order;
1313

14-
import dev.restate.sdk.examples.external.DriverMobileAppSimulator;
14+
import examples.order.external.DriverMobileAppSimulator;
1515
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;
1616

1717
public class AppMain {
1818
public static void main(String[] args) {
1919
RestateHttpEndpointBuilder.builder()
20-
.withService(new OrderWorkflow())
20+
.with(new OrderWorkflow())
21+
.withService(new OrderWorkflowSubmitter())
2122
.withService(new OrderStatusService())
22-
.withService(new DeliveryManager())
2323
.withService(new DriverDeliveryMatcher())
2424
.withService(new DriverDigitalTwin())
2525
.withService(new DriverMobileAppSimulator()) // external mobile app on driver's phone

0 commit comments

Comments
 (0)