Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use the new workflow api in food ordering #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions java/food-ordering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ Restate has a psql interface to query the state of the system.

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:
```shell
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'"'"';"'
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'"'"';"'
```

Or have a look at the state of all the services, except for the driver simulator:
```shell
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'"'"');"'
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'"'"');"'
```

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

### The order workflow
You can find the implementation of each of the services under `app/restate-app/src/main/java/dev/restate/sdk/examples/`.
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).
The flow of an incoming order is as follows:
1. When the customer places an order via the web UI (localhost:3000), an order event is published to Kafka.
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.
Expand Down
11 changes: 7 additions & 4 deletions java/food-ordering/app/restate-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ plugins {

repositories {
mavenCentral()
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

val restateVersion = "0.7.0"
val restateVersion = "0.8.0-SNAPSHOT"

dependencies {
// Restate SDK
annotationProcessor("dev.restate:sdk-api-gen:$restateVersion")
implementation("dev.restate:sdk-api:$restateVersion")
implementation("dev.restate:sdk-workflow-api:$restateVersion")
implementation("dev.restate:sdk-http-vertx:$restateVersion")
// To use Jackson to read/write state entries (optional)
implementation("dev.restate:sdk-serde-jackson:$restateVersion")
Expand All @@ -29,7 +32,7 @@ dependencies {
compileOnly("org.apache.tomcat:annotations-api:6.0.53")

//Kafka
implementation("org.apache.kafka:kafka-clients:3.0.0")
implementation("org.apache.kafka:kafka-clients:3.6.1")

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

// Set main class
application {
mainClass.set("dev.restate.sdk.examples.AppMain")
mainClass.set("examples.order.AppMain")
}


jib {
to.image = "restate-app:0.0.1"
container.mainClass = "dev.restate.sdk.examples.AppMain"
container.mainClass = "examples.order.AppMain"
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
* https://github.com/restatedev/examples/
*/

package dev.restate.sdk.examples;
package examples.order;

import dev.restate.sdk.examples.external.DriverMobileAppSimulator;
import examples.order.external.DriverMobileAppSimulator;
import dev.restate.sdk.http.vertx.RestateHttpEndpointBuilder;

public class AppMain {
public static void main(String[] args) {
RestateHttpEndpointBuilder.builder()
.withService(new OrderWorkflow())
.with(new OrderWorkflow())
.withService(new OrderWorkflowSubmitter())
.withService(new OrderStatusService())
.withService(new DeliveryManager())
.withService(new DriverDeliveryMatcher())
.withService(new DriverDigitalTwin())
.withService(new DriverMobileAppSimulator()) // external mobile app on driver's phone
Expand Down
Loading
Loading