diff --git a/.github/holopin.yml b/.github/holopin.yml new file mode 100644 index 000000000..44a7f0c8a --- /dev/null +++ b/.github/holopin.yml @@ -0,0 +1,6 @@ +organization: dapr +defaultSticker: clmjkxscc122740fl0mkmb7egi +stickers: + - + id: clmjkxscc122740fl0mkmb7egi + alias: ghc2023 diff --git a/.github/workflows/validate_python_quicstarts.yaml b/.github/workflows/validate_python_quicstarts.yaml index 58c021aa3..447d4f0cc 100644 --- a/.github/workflows/validate_python_quicstarts.yaml +++ b/.github/workflows/validate_python_quicstarts.yaml @@ -99,6 +99,7 @@ jobs: echo "PATH=$PATH:$HOME/.local/bin" >> $GITHUB_ENV pip3 install setuptools wheel pip3 install mechanical-markdown + pip3 install fastapi uvicorn - name: Validate building blocks with Python run: | variants=("http" "sdk") diff --git a/pub_sub/csharp/http/README.md b/pub_sub/csharp/http/README.md index 32f59e953..155084255 100644 --- a/pub_sub/csharp/http/README.md +++ b/pub_sub/csharp/http/README.md @@ -14,78 +14,87 @@ And one subscriber: - Dotnet subscriber `order-processor` -### Run Dotnet message subscriber with Dapr +## Run all apps with multi-app run template file: -1. Navigate to the directory and install dependencies: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. - - -```bash -cd ./order-processor -dotnet restore -dotnet build -``` - -2. Run the Dotnet subscriber app with Dapr: +1. Open a new terminal window and run `order-processor` and `checkout` using the multi app run template defined in [dapr.yaml](./dapr.yaml): - ```bash -dapr run --app-id order-processor-http --resources-path ../../../components/ --app-port 7005 -- dotnet run --project . +dapr run -f . ``` +The terminal console output should look similar to this: + +```text +== APP - checkout-http == Published data: Order { OrderId = 1 } +== APP - order-processor-http == Subscriber received : 1 +== APP - checkout-http == Published data: Order { OrderId = 2 } +== APP - order-processor-http == Subscriber received : 2 +== APP - checkout-http == Published data: Order { OrderId = 3 } +== APP - order-processor-http == Subscriber received : 3 +== APP - checkout-http == Published data: Order { OrderId = 4 } +== APP - order-processor-http == Subscriber received : 4 +== APP - checkout-http == Published data: Order { OrderId = 5 } +== APP - order-processor-http == Subscriber received : 5 +== APP - checkout-http == Published data: Order { OrderId = 6 } +== APP - order-processor-http == Subscriber received : 6 +== APP - checkout-http == Published data: Order { OrderId = 7 } +== APP - order-processor-http == Subscriber received : 7 +== APP - checkout-http == Published data: Order { OrderId = 8 } +== APP - order-processor-http == Subscriber received : 8 +== APP - checkout-http == Published data: Order { OrderId = 9 } +== APP - order-processor-http == Subscriber received : 9 +== APP - checkout-http == Published data: Order { OrderId = 10 } +== APP - order-processor-http == Subscriber received : 10 +``` + +2. Stop and clean up application processes + +```bash +dapr stop -f . +``` -### Run Dotnet message publisher with Dapr -1. Navigate to the directory and install dependencies: +## Run a single app at a time with Dapr (Optional) - +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + +### Run Dotnet message subscriber with Dapr + +1. Run the Dotnet subscriber app with Dapr: ```bash -cd ./checkout -dotnet restore -dotnet build +cd ./order-processor +dapr run --app-id order-processor-http --resources-path ../../../components/ --app-port 7005 -- dotnet run ``` - -2. Run the Dotnet publisher app with Dapr: - - +### Run Dotnet message publisher with Dapr + +1. Run the Dotnet publisher app with Dapr: + + ```bash -dapr run --app-id checkout-http --resources-path ../../../components/ -- dotnet run --project . +cd ./checkout +dapr run --app-id checkout-http --resources-path ../../../components/ -- dotnet run ``` - +2. Stop and clean up application processes ```bash dapr stop --app-id order-processor-http diff --git a/pub_sub/csharp/http/dapr.yaml b/pub_sub/csharp/http/dapr.yaml new file mode 100644 index 000000000..25d7770ff --- /dev/null +++ b/pub_sub/csharp/http/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-http + appDirPath: ./order-processor/ + appPort: 7005 + command: ["dotnet", "run"] + - appID: checkout-http + appDirPath: ./checkout/ + command: ["dotnet", "run"] diff --git a/pub_sub/csharp/sdk/README.md b/pub_sub/csharp/sdk/README.md index 04f3010a2..199b72af3 100644 --- a/pub_sub/csharp/sdk/README.md +++ b/pub_sub/csharp/sdk/README.md @@ -14,78 +14,87 @@ And one subscriber: - Dotnet subscriber `order-processor` -### Run Dotnet message subscriber with Dapr +## Run all apps with multi-app run template file: -1. Navigate to the directory and install dependencies: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. - - -```bash -cd ./order-processor -dotnet restore -dotnet build -``` - -2. Run the Dotnet subscriber app with Dapr: +1. Open a new terminal window and run the multi app run template: - ```bash -dapr run --app-id order-processor --resources-path ../../../components/ --app-port 7006 -- dotnet run --project . +dapr run -f . ``` +The terminal console output should look similar to this: + +```text +== APP - checkout-sdk == Published data: Order { OrderId = 1 } +== APP - order-processor == Subscriber received : Order { OrderId = 1 } +== APP - checkout-sdk == Published data: Order { OrderId = 2 } +== APP - order-processor == Subscriber received : Order { OrderId = 2 } +== APP - checkout-sdk == Published data: Order { OrderId = 3 } +== APP - order-processor == Subscriber received : Order { OrderId = 3 } +== APP - checkout-sdk == Published data: Order { OrderId = 4 } +== APP - order-processor == Subscriber received : Order { OrderId = 4 } +== APP - checkout-sdk == Published data: Order { OrderId = 5 } +== APP - order-processor == Subscriber received : Order { OrderId = 5 } +== APP - checkout-sdk == Published data: Order { OrderId = 6 } +== APP - order-processor == Subscriber received : Order { OrderId = 6 } +== APP - checkout-sdk == Published data: Order { OrderId = 7 } +== APP - order-processor == Subscriber received : Order { OrderId = 7 } +== APP - checkout-sdk == Published data: Order { OrderId = 8 } +== APP - order-processor == Subscriber received : Order { OrderId = 8 } +== APP - checkout-sdk == Published data: Order { OrderId = 9 } +== APP - order-processor == Subscriber received : Order { OrderId = 9 } +== APP - checkout-sdk == Published data: Order { OrderId = 10 } +== APP - order-processor == Subscriber received : Order { OrderId = 10 } +``` + +2. Stop and clean up application processes + +```bash +dapr stop -f . +``` -### Run Dotnet message publisher with Dapr -1. Navigate to the directory and install dependencies: +## Run a single app at a time with Dapr (Optional) - +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + +### Run Dotnet message subscriber with Dapr + +1. Run the Dotnet subscriber app with Dapr: ```bash -cd ./checkout -dotnet restore -dotnet build +cd ./order-processor +dapr run --app-id order-processor --resources-path ../../../components/ --app-port 7006 -- dotnet run ``` - -2. Run the Dotnet publisher app with Dapr: - - +### Run Dotnet message publisher with Dapr + +1. Run the Dotnet publisher app with Dapr: + + ```bash -dapr run --app-id checkout-sdk --resources-path ../../../components/ -- dotnet run --project . +cd ./checkout +dapr run --app-id checkout-sdk --resources-path ../../../components/ -- dotnet run ``` - +2. Stop and clean up application processes ```bash dapr stop --app-id order-processor diff --git a/pub_sub/csharp/sdk/dapr.yaml b/pub_sub/csharp/sdk/dapr.yaml new file mode 100644 index 000000000..5d026f7a2 --- /dev/null +++ b/pub_sub/csharp/sdk/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor + appDirPath: ./order-processor/ + appPort: 7006 + command: ["dotnet", "run"] + - appID: checkout-sdk + appDirPath: ./checkout/ + command: ["dotnet", "run"] diff --git a/pub_sub/go/http/README.md b/pub_sub/go/http/README.md index 8f8aeaab0..6a4ec529e 100644 --- a/pub_sub/go/http/README.md +++ b/pub_sub/go/http/README.md @@ -10,51 +10,85 @@ This quickstart includes one publisher: Go client message generator `checkout`. And one subscriber: Go subscriber `order-processor`. -### Run Go message subscriber with Dapr +## Run all apps with multi-app run template file: -1. Run the Go subscriber app with Dapr in the `order-processor` folder: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Open a new terminal window and run the multi app run template: ```bash -cd ./order-processor -dapr run --app-port 6002 --app-id order-processor --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- go run . +dapr run -f . ``` +The terminal console output should look similar to this: + +```text +== APP - checkout-http == Published data: {"orderId":1} +== APP - order-processor-http == Subscriber received: {"orderId":1} +== APP - checkout-http == Published data: {"orderId":2} +== APP - order-processor-http == Subscriber received: {"orderId":2} +== APP - checkout-http == Published data: {"orderId":3} +== APP - order-processor-http == Subscriber received: {"orderId":3} +== APP - checkout-http == Published data: {"orderId":4} +== APP - order-processor-http == Subscriber received: {"orderId":4} +== APP - checkout-http == Published data: {"orderId":5} +== APP - order-processor-http == Subscriber received: {"orderId":5} +== APP - checkout-http == Published data: {"orderId":6} +== APP - order-processor-http == Subscriber received: {"orderId":6} +== APP - checkout-http == Published data: {"orderId":7} +== APP - order-processor-http == Subscriber received: {"orderId":7} +== APP - checkout-http == Published data: {"orderId":8} +== APP - order-processor-http == Subscriber received: {"orderId":8} +== APP - checkout-http == Published data: {"orderId":9} +== APP - order-processor-http == Subscriber received: {"orderId":9} +== APP - checkout-http == Published data: {"orderId":10} +== APP - order-processor-http == Subscriber received: {"orderId":10} +``` + +2. Stop and clean up application processes + +```bash +dapr stop -f . +``` +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + +### Run Go message subscriber with Dapr + +1. Run the Go subscriber app with Dapr in the `order-processor` folder: + +```bash +cd ./order-processor +dapr run --app-port 6003 --app-id order-processor-http --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- go run . +``` + ### Run Go message publisher with Dapr 1. Run the Go publisher app with Dapr in the `checkout` folder: - - ```bash cd ./checkout dapr run --app-id checkout-http --app-protocol http --dapr-http-port 3500 --resources-path ../../../components -- go run . ``` - - To stop: ```bash diff --git a/pub_sub/go/http/dapr.yaml b/pub_sub/go/http/dapr.yaml new file mode 100644 index 000000000..e6b04c161 --- /dev/null +++ b/pub_sub/go/http/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-http + appDirPath: ./order-processor/ + appPort: 6003 + command: ["go", "run", "."] + - appID: checkout-http + appDirPath: ./checkout/ + command: ["go", "run", "."] diff --git a/pub_sub/go/sdk/README.md b/pub_sub/go/sdk/README.md index 5b4f22ef7..1ebfaf9ca 100644 --- a/pub_sub/go/sdk/README.md +++ b/pub_sub/go/sdk/README.md @@ -10,51 +10,86 @@ This quickstart includes one publisher: Go client message generator `checkout` And one subscriber: Go subscriber `order-processor` -### Run Go message subscriber with Dapr +## Run all apps with multi-app run template file: -1. Run the Go subscriber app with Dapr in the `order-processor` folder: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Open a new terminal window and run the multi app run template: ```bash -cd ./order-processor -dapr run --app-port 6005 --app-id order-processor-sdk --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- go run . +dapr run -f . +``` + +The terminal console output should look similar to this: + +```text +== APP - checkout-sdk == Published data: {"orderId":1} +== APP - order-processor == Subscriber received: map[orderId:1] +== APP - checkout-sdk == Published data: {"orderId":2} +== APP - order-processor == Subscriber received: map[orderId:2] +== APP - checkout-sdk == Published data: {"orderId":3} +== APP - order-processor == Subscriber received: map[orderId:3] +== APP - checkout-sdk == Published data: {"orderId":4} +== APP - order-processor == Subscriber received: map[orderId:4] +== APP - checkout-sdk == Published data: {"orderId":5} +== APP - order-processor == Subscriber received: map[orderId:5] +== APP - checkout-sdk == Published data: {"orderId":6} +== APP - order-processor == Subscriber received: map[orderId:6] +== APP - checkout-sdk == Published data: {"orderId":7} +== APP - order-processor == Subscriber received: map[orderId:7] +== APP - checkout-sdk == Published data: {"orderId":8} +== APP - order-processor == Subscriber received: map[orderId:8] +== APP - checkout-sdk == Published data: {"orderId":9} +== APP - order-processor == Subscriber received: map[orderId:9] +== APP - checkout-sdk == Published data: {"orderId":10} +== APP - order-processor == Subscriber received: map[orderId:10] ``` +2. Stop and clean up application processes + +```bash +dapr stop -f . +``` +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + +### Run Go message subscriber with Dapr + +1. Run the Go subscriber app with Dapr in the `order-processor` folder: + + +```bash +cd ./order-processor +dapr run --app-port 6005 --app-id order-processor-sdk --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- go run . +``` + ### Run Go message publisher with Dapr 1 Run the Go publisher app with Dapr in the `checkout` folder: - - ```bash cd ./checkout dapr run --app-id checkout-sdk --app-protocol http --dapr-http-port 3500 --resources-path ../../../components -- go run . ``` - - To stop: ```bash diff --git a/pub_sub/go/sdk/dapr.yaml b/pub_sub/go/sdk/dapr.yaml new file mode 100644 index 000000000..2290474b3 --- /dev/null +++ b/pub_sub/go/sdk/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor + appDirPath: ./order-processor/ + appPort: 6005 + command: ["go", "run", "."] + - appID: checkout-sdk + appDirPath: ./checkout/ + command: ["go", "run", "."] diff --git a/pub_sub/java/http/README.md b/pub_sub/java/http/README.md index 8d0a8673f..1324d7967 100644 --- a/pub_sub/java/http/README.md +++ b/pub_sub/java/http/README.md @@ -23,69 +23,113 @@ And one subscriber: * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. -### Run Java message subscriber app with Dapr +## Run all apps with multi-app run template file: + +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Install dependencies: -1. Navigate to directory and install dependencies: - ```bash cd ./order-processor mvn clean install +cd .. +cd ./checkout +mvn clean install +cd .. ``` -2. Run the Java subscriber app with Dapr: +2. Open a new terminal window and run the multi app run template: + + +```bash +dapr run -f . +``` + +The terminal console output should look similar to this: + +```text +== APP - order-processor-http == 2023-09-04 14:25:37.624 INFO 88784 --- [nio-8080-exec-1] c.s.c.OrderProcessingServiceController : Subscriber received: 1 +== APP - checkout-http == 1175 [main] INFO com.service.CheckoutServiceApplication - Published data: 2 +== APP - order-processor-http == 2023-09-04 14:25:38.558 INFO 88784 --- [nio-8080-exec-2] c.s.c.OrderProcessingServiceController : Subscriber received: 2 +== APP - checkout-http == 2184 [main] INFO com.service.CheckoutServiceApplication - Published data: 3 +== APP - order-processor-http == 2023-09-04 14:25:39.567 INFO 88784 --- [nio-8080-exec-3] c.s.c.OrderProcessingServiceController : Subscriber received: 3 +== APP - checkout-http == 3195 [main] INFO com.service.CheckoutServiceApplication - Published data: 4 +== APP - order-processor-http == 2023-09-04 14:25:40.578 INFO 88784 --- [nio-8080-exec-4] c.s.c.OrderProcessingServiceController : Subscriber received: 4 +== APP - checkout-http == 4203 [main] INFO com.service.CheckoutServiceApplication - Published data: 5 +== APP - order-processor-http == 2023-09-04 14:25:41.586 INFO 88784 --- [nio-8080-exec-5] c.s.c.OrderProcessingServiceController : Subscriber received: 5 +== APP - checkout-http == 5215 [main] INFO com.service.CheckoutServiceApplication - Published data: 6 +== APP - order-processor-http == 2023-09-04 14:25:42.600 INFO 88784 --- [nio-8080-exec-6] c.s.c.OrderProcessingServiceController : Subscriber received: 6 +== APP - checkout-http == 6219 [main] INFO com.service.CheckoutServiceApplication - Published data: 7 +== APP - order-processor-http == 2023-09-04 14:25:43.601 INFO 88784 --- [nio-8080-exec-7] c.s.c.OrderProcessingServiceController : Subscriber received: 7 +== APP - checkout-http == 7224 [main] INFO com.service.CheckoutServiceApplication - Published data: 8 +== APP - order-processor-http == 2023-09-04 14:25:44.607 INFO 88784 --- [nio-8080-exec-8] c.s.c.OrderProcessingServiceController : Subscriber received: 8 +== APP - checkout-http == 8229 [main] INFO com.service.CheckoutServiceApplication - Published data: 9 +== APP - order-processor-http == 2023-09-04 14:25:45.612 INFO 88784 --- [nio-8080-exec-9] c.s.c.OrderProcessingServiceController : Subscriber received: 9 +== APP - checkout-http == 9237 [main] INFO com.service.CheckoutServiceApplication - Published data: 10 +== APP - order-processor-http == 2023-09-04 14:25:46.620 INFO 88784 --- [io-8080-exec-10] c.s.c.OrderProcessingServiceController : Subscriber received: 10 +``` + +3. Stop and clean up application processes + +```bash +dapr stop -f . +``` + + +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + + +### Run Java message subscriber app with Dapr + +1. Navigate to directory and install dependencies: + +```bash +cd ./order-processor +mvn clean install +``` + +2. Run the Java subscriber app with Dapr: + ```bash cd ./order-processor dapr run --app-port 8080 --app-id order-processor-http --resources-path ../../../components -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar ``` - + ### Run Java message publisher app with Dapr 1. Navigate to the directory and install dependencies: - - ```bash cd ./checkout mvn clean install ``` - 2. Run the Java publisher app with Dapr: - ```bash cd ./checkout dapr run --app-id checkout-http --resources-path ../../../components -- java -jar target/CheckoutService-0.0.1-SNAPSHOT.jar ``` - ```bash dapr stop --app-id checkout-http diff --git a/pub_sub/java/http/checkout/src/main/java/com/service/CheckoutServiceApplication.java b/pub_sub/java/http/checkout/src/main/java/com/service/CheckoutServiceApplication.java index 73008cad7..277928297 100644 --- a/pub_sub/java/http/checkout/src/main/java/com/service/CheckoutServiceApplication.java +++ b/pub_sub/java/http/checkout/src/main/java/com/service/CheckoutServiceApplication.java @@ -26,7 +26,7 @@ public class CheckoutServiceApplication { public static void main(String[] args) throws InterruptedException, IOException { String uri = DAPR_HOST + ":" + DAPR_HTTP_PORT + "/v1.0/publish/" + PUBSUB_NAME + "/" + TOPIC; - for (int i = 0; i <= 10; i++) { + for (int i = 1; i <= 10; i++) { int orderId = i; JSONObject obj = new JSONObject(); obj.put("orderId", orderId); @@ -40,7 +40,7 @@ public static void main(String[] args) throws InterruptedException, IOException HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); logger.info("Published data: {}", orderId); - TimeUnit.MILLISECONDS.sleep(3000); + TimeUnit.MILLISECONDS.sleep(1000); } } } diff --git a/pub_sub/java/http/dapr.yaml b/pub_sub/java/http/dapr.yaml new file mode 100644 index 000000000..dfcf0a889 --- /dev/null +++ b/pub_sub/java/http/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-http + appDirPath: ./order-processor/target/ + appPort: 8080 + command: ["java", "-jar", "OrderProcessingService-0.0.1-SNAPSHOT.jar"] + - appID: checkout-http + appDirPath: ./checkout/target/ + command: ["java", "-jar", "CheckoutService-0.0.1-SNAPSHOT.jar"] diff --git a/pub_sub/java/sdk/README.md b/pub_sub/java/sdk/README.md index e71852c63..b023a35fa 100644 --- a/pub_sub/java/sdk/README.md +++ b/pub_sub/java/sdk/README.md @@ -23,70 +23,113 @@ And one subscriber: * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. -### Run Java message subscriber app with Dapr +## Run all apps with multi-app run template file: + +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Install dependencies: -1. Navigate to directory and install dependencies: - ```bash cd ./order-processor mvn clean install +cd .. +cd ./checkout +mvn clean install +cd .. ``` -2. Run the Java subscriber app with Dapr: +2. Open a new terminal window and run the multi app run template: + + +```bash +dapr run -f . +``` + +The terminal console output should look similar to this: + +```text +== APP - checkout-sdk == 563 [main] INFO com.service.CheckoutServiceApplication - Published data: 1 +== APP - order-processor-sdk == 2023-09-04 13:57:18.434 INFO 82828 --- [nio-8080-exec-3] c.s.c.OrderProcessingServiceController : Subscriber received: 1 +== APP - checkout-sdk == 1576 [main] INFO com.service.CheckoutServiceApplication - Published data: 2 +== APP - order-processor-sdk == 2023-09-04 13:57:19.419 INFO 82828 --- [nio-8080-exec-4] c.s.c.OrderProcessingServiceController : Subscriber received: 2 +== APP - checkout-sdk == 2587 [main] INFO com.service.CheckoutServiceApplication - Published data: 3 +== APP - order-processor-sdk == 2023-09-04 13:57:20.431 INFO 82828 --- [nio-8080-exec-5] c.s.c.OrderProcessingServiceController : Subscriber received: 3 +== APP - checkout-sdk == 3602 [main] INFO com.service.CheckoutServiceApplication - Published data: 4 +== APP - order-processor-sdk == 2023-09-04 13:57:21.447 INFO 82828 --- [nio-8080-exec-6] c.s.c.OrderProcessingServiceController : Subscriber received: 4 +== APP - checkout-sdk == 4612 [main] INFO com.service.CheckoutServiceApplication - Published data: 5 +== APP - order-processor-sdk == 2023-09-04 13:57:22.455 INFO 82828 --- [nio-8080-exec-7] c.s.c.OrderProcessingServiceController : Subscriber received: 5 +== APP - checkout-sdk == 5624 [main] INFO com.service.CheckoutServiceApplication - Published data: 6 +== APP - order-processor-sdk == 2023-09-04 13:57:23.468 INFO 82828 --- [nio-8080-exec-8] c.s.c.OrderProcessingServiceController : Subscriber received: 6 +== APP - checkout-sdk == 6631 [main] INFO com.service.CheckoutServiceApplication - Published data: 7 +== APP - order-processor-sdk == 2023-09-04 13:57:24.474 INFO 82828 --- [nio-8080-exec-9] c.s.c.OrderProcessingServiceController : Subscriber received: 7 +== APP - checkout-sdk == 7643 [main] INFO com.service.CheckoutServiceApplication - Published data: 8 +== APP - order-processor-sdk == 2023-09-04 13:57:25.487 INFO 82828 --- [io-8080-exec-10] c.s.c.OrderProcessingServiceController : Subscriber received: 8 +== APP - checkout-sdk == 8649 [main] INFO com.service.CheckoutServiceApplication - Published data: 9 +== APP - order-processor-sdk == 2023-09-04 13:57:26.492 INFO 82828 --- [nio-8080-exec-2] c.s.c.OrderProcessingServiceController : Subscriber received: 9 +== APP - checkout-sdk == 9662 [main] INFO com.service.CheckoutServiceApplication - Published data: 10 +== APP - order-processor-sdk == 2023-09-04 13:57:27.504 INFO 82828 --- [nio-8080-exec-1] c.s.c.OrderProcessingServiceController : Subscriber received: 10 +``` + +3. Stop and clean up application processes + +```bash +dapr stop -f . +``` + + +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + +### Run Java message subscriber app with Dapr + +1. Navigate to directory and install dependencies: + +```bash +cd ./order-processor +mvn clean install +``` + +2. Run the Java subscriber app with Dapr: + ```bash cd ./order-processor dapr run --app-port 8080 --app-id order-processor-sdk --resources-path ../../../components -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar ``` - ### Run Java message publisher app with Dapr 1. Navigate to the directory and install dependencies: - - ```bash cd ./checkout mvn clean install ``` - 2. Run the Java publisher app with Dapr: - ```bash cd ./checkout dapr run --app-id checkout-sdk --resources-path ../../../components -- java -jar target/CheckoutService-0.0.1-SNAPSHOT.jar ``` - ```bash dapr stop --app-id checkout-sdk diff --git a/pub_sub/java/sdk/checkout/src/main/java/com/service/CheckoutServiceApplication.java b/pub_sub/java/sdk/checkout/src/main/java/com/service/CheckoutServiceApplication.java index db8dfab2d..66eead410 100644 --- a/pub_sub/java/sdk/checkout/src/main/java/com/service/CheckoutServiceApplication.java +++ b/pub_sub/java/sdk/checkout/src/main/java/com/service/CheckoutServiceApplication.java @@ -16,7 +16,7 @@ public static void main(String[] args) throws InterruptedException{ String PUBSUB_NAME = "orderpubsub"; DaprClient client = new DaprClientBuilder().build(); - for (int i = 0; i <= 10; i++) { + for (int i = 1; i <= 10; i++) { int orderId = i; Order order = new Order(orderId); @@ -26,7 +26,7 @@ public static void main(String[] args) throws InterruptedException{ TOPIC_NAME, order).block(); logger.info("Published data: " + order.getOrderId()); - TimeUnit.MILLISECONDS.sleep(5000); + TimeUnit.MILLISECONDS.sleep(1000); } } } diff --git a/pub_sub/java/sdk/dapr.yaml b/pub_sub/java/sdk/dapr.yaml new file mode 100644 index 000000000..f9407f562 --- /dev/null +++ b/pub_sub/java/sdk/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-sdk + appDirPath: ./order-processor/target/ + appPort: 8080 + command: ["java", "-jar", "OrderProcessingService-0.0.1-SNAPSHOT.jar"] + - appID: checkout-sdk + appDirPath: ./checkout/target/ + command: ["java", "-jar", "CheckoutService-0.0.1-SNAPSHOT.jar"] diff --git a/pub_sub/javascript/http/README.md b/pub_sub/javascript/http/README.md index 5ce0d9b79..0e527f603 100644 --- a/pub_sub/javascript/http/README.md +++ b/pub_sub/javascript/http/README.md @@ -14,7 +14,9 @@ And one subscriber: - Node subscriber `order-processor` -### Run Node message subscriber with Dapr +## Run all apps with multi-app run template file: + +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. 1. Install dependencies: @@ -25,61 +27,100 @@ name: Install Node dependencies ```bash cd ./order-processor npm install +cd .. +cd ./checkout +npm install ``` -2. Run the Node publisher app with Dapr: + +2. Open a new terminal window and run the multi app run template: - + ```bash -dapr run --app-id order-processor-http --resources-path ../../../components/ --app-port 5003 -- node . +dapr run -f . ``` +The terminal console output should look similar to this: + +```text +== APP - checkout-sdk-http == Published data: {"orderId":1} +== APP - order-processor-http == Subscriber received: { orderId: 1 } +== APP - checkout-sdk-http == Published data: {"orderId":2} +== APP - order-processor-http == Subscriber received: { orderId: 2 } +== APP - checkout-sdk-http == Published data: {"orderId":3} +== APP - order-processor-http == Subscriber received: { orderId: 3 } +== APP - checkout-sdk-http == Published data: {"orderId":4} +== APP - order-processor-http == Subscriber received: { orderId: 4 } +== APP - checkout-sdk-http == Published data: {"orderId":5} +== APP - order-processor-http == Subscriber received: { orderId: 5 } +== APP - checkout-sdk-http == Published data: {"orderId":6} +== APP - order-processor-http == Subscriber received: { orderId: 6 } +== APP - checkout-sdk-http == Published data: {"orderId":7} +== APP - order-processor-http == Subscriber received: { orderId: 7 } +== APP - checkout-sdk-http == Published data: {"orderId":8} +== APP - order-processor-http == Subscriber received: { orderId: 8 } +== APP - checkout-sdk-http == Published data: {"orderId":9} +== APP - order-processor-http == Subscriber received: { orderId: 9 } +== APP - checkout-sdk-http == Published data: {"orderId":10} +== APP - order-processor-http == Subscriber received: { orderId: 10 } +``` + +3. Stop and clean up application processes + +```bash +dapr stop -f . +``` -### Run Node message publisher with Dapr +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- npm run start` commands. This next section covers how to do this. + +### Run Node message subscriber with Dapr 1. Install dependencies: - +```bash +cd ./order-processor +npm install +``` + +2. Run the Node publisher app with Dapr: + +```bash +dapr run --app-port 5003 --app-id order-processing-http --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- npm run start +``` + +### Run Node message publisher with Dapr + +1. Install dependencies: ```bash cd ./checkout npm install ``` - -2. Run the Node publisher app with Dapr: - +2. Run the Node publisher app with Dapr: ```bash -dapr run --app-id checkout-http --resources-path ../../../components/ --app-port 5003 -- node . +dapr run --app-id checkout-http --app-protocol http --dapr-http-port 3500 --resources-path ../../../components -- npm run start ``` - +### Stop the apps and clean up ```bash dapr stop --app-id checkout-http diff --git a/pub_sub/javascript/http/checkout/package-lock.json b/pub_sub/javascript/http/checkout/package-lock.json index 35b2a221b..8fa6abdb2 100644 --- a/pub_sub/javascript/http/checkout/package-lock.json +++ b/pub_sub/javascript/http/checkout/package-lock.json @@ -1,21 +1,43 @@ { "name": "checkout", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "axios": { + "packages": { + "": { + "name": "checkout", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "axios": "^0.25.0" + } + }, + "node_modules/axios": { "version": "0.25.0", "resolved": "https://registry.npmjs.org/axios/-/axios-0.25.0.tgz", "integrity": "sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==", - "requires": { + "dependencies": { "follow-redirects": "^1.14.7" } }, - "follow-redirects": { + "node_modules/follow-redirects": { "version": "1.14.7", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", - "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } } } } diff --git a/pub_sub/javascript/http/dapr.yaml b/pub_sub/javascript/http/dapr.yaml new file mode 100644 index 000000000..ecf3e17c9 --- /dev/null +++ b/pub_sub/javascript/http/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-http + appDirPath: ./order-processor/ + appPort: 5003 + command: ["npm", "run", "start"] + - appID: checkout-http + appDirPath: ./checkout/ + command: ["npm", "run", "start"] diff --git a/pub_sub/javascript/http/order-processor/package-lock.json b/pub_sub/javascript/http/order-processor/package-lock.json index 30535e45e..e1f057184 100644 --- a/pub_sub/javascript/http/order-processor/package-lock.json +++ b/pub_sub/javascript/http/order-processor/package-lock.json @@ -1,28 +1,39 @@ { "name": "order-processor", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "accepts": { + "packages": { + "": { + "name": "order-processor", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "express": "^4.17.2" + } + }, + "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", - "requires": { + "dependencies": { "mime-types": "~2.1.34", "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" } }, - "array-flatten": { + "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, - "body-parser": { + "node_modules/body-parser": { "version": "1.19.1", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.1.tgz", "integrity": "sha512-8ljfQi5eBk8EJfECMrgqNGWPEY5jWP+1IzkzkGdFFEwFQZZyaZ21UqdaHktgiMlH0xLHqIFtE/u2OYE5dOtViA==", - "requires": { + "dependencies": { "bytes": "3.1.1", "content-type": "~1.0.4", "debug": "2.6.9", @@ -33,79 +44,103 @@ "qs": "6.9.6", "raw-body": "2.4.2", "type-is": "~1.6.18" + }, + "engines": { + "node": ">= 0.8" } }, - "bytes": { + "node_modules/bytes": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.1.tgz", - "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==" + "integrity": "sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==", + "engines": { + "node": ">= 0.8" + } }, - "content-disposition": { + "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", - "requires": { + "dependencies": { "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" } }, - "content-type": { + "node_modules/content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "engines": { + "node": ">= 0.6" + } }, - "cookie": { + "node_modules/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", - "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==" + "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", + "engines": { + "node": ">= 0.6" + } }, - "cookie-signature": { + "node_modules/cookie-signature": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" }, - "debug": { + "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { + "dependencies": { "ms": "2.0.0" } }, - "depd": { + "node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "engines": { + "node": ">= 0.6" + } }, - "destroy": { + "node_modules/destroy": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, - "ee-first": { + "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, - "encodeurl": { + "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "engines": { + "node": ">= 0.8" + } }, - "escape-html": { + "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, - "etag": { + "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "engines": { + "node": ">= 0.6" + } }, - "express": { + "node_modules/express": { "version": "4.17.2", "resolved": "https://registry.npmjs.org/express/-/express-4.17.2.tgz", "integrity": "sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg==", - "requires": { + "dependencies": { "accepts": "~1.3.7", "array-flatten": "1.1.1", "body-parser": "1.19.1", @@ -136,13 +171,16 @@ "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" } }, - "finalhandler": { + "node_modules/finalhandler": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "requires": { + "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", @@ -150,154 +188,228 @@ "parseurl": "~1.3.3", "statuses": "~1.5.0", "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "forwarded": { + "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } }, - "fresh": { + "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "engines": { + "node": ">= 0.6" + } }, - "http-errors": { + "node_modules/http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "requires": { + "dependencies": { "depd": "~1.1.2", "inherits": "2.0.4", "setprototypeof": "1.2.0", "statuses": ">= 1.5.0 < 2", "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" } }, - "iconv-lite": { + "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { + "dependencies": { "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, - "ipaddr.js": { + "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } }, - "media-typer": { + "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", + "engines": { + "node": ">= 0.6" + } }, - "merge-descriptors": { + "node_modules/merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" }, - "methods": { + "node_modules/methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "engines": { + "node": ">= 0.6" + } }, - "mime": { + "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } }, - "mime-db": { + "node_modules/mime-db": { "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "engines": { + "node": ">= 0.6" + } }, - "mime-types": { + "node_modules/mime-types": { "version": "2.1.34", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", - "requires": { + "dependencies": { "mime-db": "1.51.0" + }, + "engines": { + "node": ">= 0.6" } }, - "ms": { + "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "negotiator": { + "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } }, - "on-finished": { + "node_modules/on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "requires": { + "dependencies": { "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, - "parseurl": { + "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } }, - "path-to-regexp": { + "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, - "proxy-addr": { + "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "requires": { + "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" } }, - "qs": { + "node_modules/qs": { "version": "6.9.6", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.6.tgz", - "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==" + "integrity": "sha512-TIRk4aqYLNoJUbd+g2lEdz5kLWIuTMRagAXxl78Q0RiVjAOugHmeKNGdd3cwo/ktpf9aL9epCfFqWDEKysUlLQ==", + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, - "range-parser": { + "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } }, - "raw-body": { + "node_modules/raw-body": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.2.tgz", "integrity": "sha512-RPMAFUJP19WIet/99ngh6Iv8fzAbqum4Li7AD6DtGaW2RpMB/11xDoalPiJMTbu6I3hkbMVkATvZrqb9EEqeeQ==", - "requires": { + "dependencies": { "bytes": "3.1.1", "http-errors": "1.8.1", "iconv-lite": "0.4.24", "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" } }, - "safe-buffer": { + "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, - "safer-buffer": { + "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "send": { + "node_modules/send": { "version": "0.17.2", "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", - "requires": { + "dependencies": { "debug": "2.6.9", "depd": "~1.1.2", "destroy": "~1.0.4", @@ -312,63 +424,85 @@ "range-parser": "~1.2.1", "statuses": "~1.5.0" }, - "dependencies": { - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - } + "engines": { + "node": ">= 0.8.0" } }, - "serve-static": { + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { "version": "1.14.2", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", - "requires": { + "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", "send": "0.17.2" + }, + "engines": { + "node": ">= 0.8.0" } }, - "setprototypeof": { + "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, - "statuses": { + "node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "engines": { + "node": ">= 0.6" + } }, - "toidentifier": { + "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } }, - "type-is": { + "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "requires": { + "dependencies": { "media-typer": "0.3.0", "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" } }, - "unpipe": { + "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "engines": { + "node": ">= 0.8" + } }, - "utils-merge": { + "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "engines": { + "node": ">= 0.4.0" + } }, - "vary": { + "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "engines": { + "node": ">= 0.8" + } } } } diff --git a/pub_sub/javascript/sdk/README.md b/pub_sub/javascript/sdk/README.md index a81e157b3..a169b0420 100644 --- a/pub_sub/javascript/sdk/README.md +++ b/pub_sub/javascript/sdk/README.md @@ -14,7 +14,9 @@ And one subscriber: - Node subscriber `order-processor` -### Run Node message subscriber with Dapr +## Run all apps with multi-app run template file: + +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. 1. Install dependencies: @@ -25,61 +27,100 @@ name: Install Node dependencies ```bash cd ./order-processor npm install +cd .. +cd ./checkout +npm install ``` -3. Run the Node publisher app with Dapr: + +2. Open a new terminal window and run the multi app run template: - + ```bash -dapr run --app-port 5002 --app-id order-processing-sdk --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- npm run start +dapr run -f . ``` +The terminal console output should look similar to this: + +```text +== APP - checkout-sdk == Published data: {"orderId":1} +== APP - order-processor == Subscriber received: {"orderId":1} +== APP - checkout-sdk == Published data: {"orderId":2} +== APP - order-processor == Subscriber received: {"orderId":2} +== APP - checkout-sdk == Published data: {"orderId":3} +== APP - order-processor == Subscriber received: {"orderId":3} +== APP - checkout-sdk == Published data: {"orderId":4} +== APP - order-processor == Subscriber received: {"orderId":4} +== APP - checkout-sdk == Published data: {"orderId":5} +== APP - order-processor == Subscriber received: {"orderId":5} +== APP - checkout-sdk == Published data: {"orderId":6} +== APP - order-processor == Subscriber received: {"orderId":6} +== APP - checkout-sdk == Published data: {"orderId":7} +== APP - order-processor == Subscriber received: {"orderId":7} +== APP - checkout-sdk == Published data: {"orderId":8} +== APP - order-processor == Subscriber received: {"orderId":8} +== APP - checkout-sdk == Published data: {"orderId":9} +== APP - order-processor == Subscriber received: {"orderId":9} +== APP - checkout-sdk == Published data: {"orderId":10} +== APP - order-processor == Subscriber received: {"orderId":10} +``` + +3. Stop and clean up application processes + +```bash +dapr stop -f . +``` -### Run Node message publisher with Dapr +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. + +### Run Node message subscriber with Dapr 1. Install dependencies: - +```bash +cd ./order-processor +npm install +``` + +2. Run the Node publisher app with Dapr: + +```bash +dapr run --app-port 5002 --app-id order-processing-sdk --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- npm run start +``` + +### Run Node message publisher with Dapr + +1. Install dependencies: ```bash cd ./checkout npm install ``` - -3. Run the Node publisher app with Dapr: - - +2. Run the Node publisher app with Dapr: + ```bash dapr run --app-id checkout-sdk --app-protocol http --dapr-http-port 3500 --resources-path ../../../components -- npm run start ``` - +### Stop the apps and clean up ```bash dapr stop --app-id checkout-sdk diff --git a/pub_sub/javascript/sdk/dapr.yaml b/pub_sub/javascript/sdk/dapr.yaml new file mode 100644 index 000000000..679ef5e8d --- /dev/null +++ b/pub_sub/javascript/sdk/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor + appDirPath: ./order-processor/ + appPort: 5002 + command: ["npm", "run", "start"] + - appID: checkout-sdk + appDirPath: ./checkout/ + command: ["npm", "run", "start"] diff --git a/pub_sub/python/http/README.md b/pub_sub/python/http/README.md index ced8600e5..0bd25647b 100644 --- a/pub_sub/python/http/README.md +++ b/pub_sub/python/http/README.md @@ -14,73 +14,119 @@ And one subscriber: - Python subscriber `order-processor` -### Run Python message subscriber with Dapr +## Run all apps with multi-app run template file: + +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. -2. Install dependencies: +1. Install dependencies: ```bash +cd ./checkout +pip3 install -r requirements.txt +cd .. cd ./order-processor -pip3 install -r requirements.txt +pip3 install -r requirements.txt +cd .. ``` -3. Run the Python subscriber app with Dapr: +2. Open a new terminal window and run the multi app run template: - ```bash -dapr run --app-id order-processor-http --resources-path ../../../components/ --app-port 6001 -- python3 app.py +dapr run -f . +``` + +The terminal console output should look similar to this: + +```text +== APP - order-processor-http == Subscriber received : 1 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:21] "POST /orders HTTP/1.1" 200 - +== APP - checkout-http == INFO:root:Published data: {"orderId": 2} +== APP - order-processor-http == Subscriber received : 2 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:22] "POST /orders HTTP/1.1" 200 - +== APP - checkout-http == INFO:root:Published data: {"orderId": 3} +== APP - order-processor-http == Subscriber received : 3 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:23] "POST /orders HTTP/1.1" 200 - +== APP - checkout-http == INFO:root:Published data: {"orderId": 4} +== APP - order-processor-http == Subscriber received : 4 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:24] "POST /orders HTTP/1.1" 200 - +== APP - checkout-http == INFO:root:Published data: {"orderId": 5} +== APP - order-processor-http == Subscriber received : 5 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:25] "POST /orders HTTP/1.1" 200 - +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:26] "POST /orders HTTP/1.1" 200 - +== APP - order-processor-http == Subscriber received : 6 +== APP - checkout-http == INFO:root:Published data: {"orderId": 6} +== APP - checkout-http == INFO:root:Published data: {"orderId": 7} +== APP - order-processor-http == Subscriber received : 7 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:27] "POST /orders HTTP/1.1" 200 - +== APP - checkout-http == INFO:root:Published data: {"orderId": 8} +== APP - order-processor-http == Subscriber received : 8 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:28] "POST /orders HTTP/1.1" 200 - +== APP - checkout-http == INFO:root:Published data: {"orderId": 9} +== APP - order-processor-http == Subscriber received : 9 +== APP - order-processor-http == 127.0.0.1 - - [04/Sep/2023 11:33:29] "POST /orders HTTP/1.1" 200 - ``` +3. Stop and clean up application processes + +```bash +dapr stop -f . +``` -### Run Python message publisher with Dapr +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- python3 app.py` commands. This next section covers how to do this. + +### Run Python message subscriber with Dapr 1. Install dependencies: - +```bash +cd ./order-processor +pip3 install -r requirements.txt +``` + +2. Run the Python subscriber app with Dapr: + +```bash +dapr run --app-id order-processor-http --resources-path ../../../components/ --app-port 6021 -- uvicorn app:app --port 6002 +``` + +### Run Python message publisher with Dapr + +1. Install dependencies: ```bash cd ./checkout pip3 install -r requirements.txt ``` - -3. Run the Python publisher app with Dapr: - - +2. Run the Python publisher app with Dapr: + ```bash dapr run --app-id checkout-http --resources-path ../../../components/ -- python3 app.py ``` - +### Stop the apps and clean up ```bash dapr stop --app-id checkout-http diff --git a/pub_sub/python/http/dapr.yaml b/pub_sub/python/http/dapr.yaml new file mode 100644 index 000000000..c1d9d1763 --- /dev/null +++ b/pub_sub/python/http/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-http + appDirPath: ./order-processor/ + appPort: 6021 + command: ["uvicorn", "app:app"] + - appID: checkout-http + appDirPath: ./checkout/ + command: ["python3", "app.py"] diff --git a/pub_sub/python/sdk/README.md b/pub_sub/python/sdk/README.md index 17120e067..db98ab869 100644 --- a/pub_sub/python/sdk/README.md +++ b/pub_sub/python/sdk/README.md @@ -14,104 +14,128 @@ And one subscriber: - Python subscriber `order-processor` -### Run Python message subscriber with Dapr +## Run all apps with multi-app run template file: + +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Install dependencies: 1. Run the Python subscriber app (flask version) with Dapr: ```bash +cd ./checkout +pip3 install -r requirements.txt +cd .. cd ./order-processor pip3 install -r requirements.txt +cd .. +cd ./order-processor-fastapi +pip3 install -r requirements.txt +cd .. ``` - +2. Open a new terminal window and run the multi app run template: + + ```bash -dapr run --app-id order-processor-sdk --resources-path ../../../components/ --app-port 6002 -- uvicorn app:app --port 6002 +dapr run -f . ``` - +The terminal console output should look similar to this: + +```text +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 1} +== APP - order-processor-sdk == Subscriber received : 1 +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:19] "POST /orders HTTP/1.1" 200 - +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 2} +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:20] "POST /orders HTTP/1.1" 200 - +== APP - order-processor-sdk == Subscriber received : 2 +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 3} +== APP - order-processor-sdk == Subscriber received : 3 +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:21] "POST /orders HTTP/1.1" 200 - +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 4} +== APP - order-processor-sdk == Subscriber received : 4 +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:22] "POST /orders HTTP/1.1" 200 - +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 5} +== APP - order-processor-sdk == Subscriber received : 5 +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:23] "POST /orders HTTP/1.1" 200 - +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 6} +== APP - order-processor-sdk == Subscriber received : 6 +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:24] "POST /orders HTTP/1.1" 200 - +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 7} +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:25] "POST /orders HTTP/1.1" 200 - +== APP - order-processor-sdk == Subscriber received : 7 +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 8} +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:26] "POST /orders HTTP/1.1" 200 - +== APP - order-processor-sdk == Subscriber received : 8 +== APP - checkout-sdk == INFO:root:Published data: {"orderId": 9} +== APP - order-processor-sdk == 127.0.0.1 - - [04/Sep/2023 11:15:27] "POST /orders HTTP/1.1" 200 - +== APP - order-processor-sdk == Subscriber received : 9 -2. Run the Python subscriber app (fastapi version) with Dapr: +``` - +3. Stop and clean up application processes ```bash -cd ./order-processor-fastapi -pip3 install -r requirements.txt +dapr stop -f . ``` - - +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- python3 app.py` commands. This next section covers how to do this. + +### Run Python message subscriber with Dapr + +1. Install dependencies: ```bash -dapr run --app-id order-processor-sdk-fastapi --resources-path ../../../components/ --app-port 6003 -- uvicorn app:app --port 6003 +cd ./order-processor +pip3 install -r requirements.txt ``` - +2. Run the Python subscriber app with Dapr: + +```bash +dapr run --app-id order-processor-sdk --resources-path ../../../components/ --app-port 6001 -- uvicorn app:app --port 6002 +``` ### Run Python message publisher with Dapr 1. Install dependencies: - - ```bash cd ./checkout pip3 install -r requirements.txt ``` - 2. Run the Python publisher app with Dapr: - - ```bash dapr run --app-id checkout-sdk --resources-path ../../../components/ -- python3 app.py ``` - +### Stop the apps and clean up ```bash dapr stop --app-id checkout-sdk diff --git a/pub_sub/python/sdk/dapr.yaml b/pub_sub/python/sdk/dapr.yaml new file mode 100644 index 000000000..9bf8c57b5 --- /dev/null +++ b/pub_sub/python/sdk/dapr.yaml @@ -0,0 +1,11 @@ +version: 1 +common: + resourcesPath: ../../components/ +apps: + - appID: order-processor-sdk + appDirPath: ./order-processor/ + appPort: 6001 + command: ["uvicorn", "app:app"] + - appID: checkout-sdk + appDirPath: ./checkout/ + command: ["python3", "app.py"] diff --git a/service_invocation/csharp/http/README.md b/service_invocation/csharp/http/README.md index 6ffe82325..f235865f8 100644 --- a/service_invocation/csharp/http/README.md +++ b/service_invocation/csharp/http/README.md @@ -6,132 +6,97 @@ Visit [this](https://docs.dapr.io/developing-applications/building-blocks/servic This quickstart includes one checkout service: -- Dotnet client service `checkout` +- .NET client service `checkout` And one order processor service: -- Dotnet order-processor service `order-processor` +- .NET order-processor service `order-processor` -### Run Dotnet order-processor with Dapr +## Run all apps with multi-app run template file: -1. Open a new terminal window and navigate to `order-processor` directory and install dependencies: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. - - -```bash -cd ./order-processor -dotnet restore -dotnet build -``` - - - -2. Run the Dotnet order-processor app with Dapr: +1. Open a new terminal window and run `order-processor` and `checkout` using the multi app run template defined in [dapr.yaml](./dapr.yaml): ```bash -cd ./order-processor -dapr run --app-port 7001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- dotnet run +dapr run -f . ``` - - -### Run Dotnet checkout with Dapr - -1. Open a new terminal window and navigate to the `checkout` directory and install dependencies: - - - -```bash -cd ./checkout -dotnet restore -dotnet build +The terminal console output should look similar to this: + +```text +== APP - order-processor == Order received : Order { orderId = 1 } +== APP - checkout == Order passed: Order { OrderId = 1 } +== APP - order-processor == Order received : Order { orderId = 2 } +== APP - checkout == Order passed: Order { OrderId = 2 } +== APP - order-processor == Order received : Order { orderId = 3 } +== APP - checkout == Order passed: Order { OrderId = 3 } +== APP - order-processor == Order received : Order { orderId = 4 } +== APP - checkout == Order passed: Order { OrderId = 4 } +== APP - order-processor == Order received : Order { orderId = 5 } +== APP - checkout == Order passed: Order { OrderId = 5 } +== APP - order-processor == Order received : Order { orderId = 6 } +== APP - checkout == Order passed: Order { OrderId = 6 } +== APP - order-processor == Order received : Order { orderId = 7 } +== APP - checkout == Order passed: Order { OrderId = 7 } +== APP - order-processor == Order received : Order { orderId = 8 } +== APP - checkout == Order passed: Order { OrderId = 8 } +== APP - order-processor == Order received : Order { orderId = 9 } +== APP - checkout == Order passed: Order { OrderId = 9 } +== APP - order-processor == Order received : Order { orderId = 10 } +== APP - checkout == Order passed: Order { OrderId = 10 } ``` - +2. Stop and clean up application processes -2. Run the Dotnet checkout app with Dapr: - - - ```bash -cd ./checkout -dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- dotnet run +dapr stop -f . ``` - -```bash -dapr stop --app-id order-processor -``` +## Run a single app at a time with Dapr (Optional) -### Start all apps with multi app run template file: +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this. -1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps: +### Run .NET `order-processor` with Dapr - +1. Open a new terminal window and run the Dotnet order-processor app with Dapr: ```bash cd ./order-processor -dotnet restore -dotnet build -cd ../checkout -dotnet restore -dotnet build +dapr run --app-port 7001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- dotnet run ``` - +### Run .NET `checkout` with Dapr -2. Run the multi app run template: - - +1. Open a new terminal and run the Dotnet checkout app with Dapr: ```bash -dapr run -f . +cd ./checkout +dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- dotnet run ``` - - +### Stop and clean up application processes ```bash -dapr stop -f . -``` \ No newline at end of file +dapr stop --app-id order-processor +dapr stop --app-id checkout +``` diff --git a/service_invocation/go/http/README.md b/service_invocation/go/http/README.md index 7cd9a4bb1..3ab01e0ef 100644 --- a/service_invocation/go/http/README.md +++ b/service_invocation/go/http/README.md @@ -8,21 +8,70 @@ This quickstart includes one checkout service: Go client service `checkout` And one order processor service: Go order-processor service `order-processor` -### Run Go order-processor with Dapr +## Run all apps with multi-app run template file: -1. Run the order-processor app with Dapr in the `order-processor` folder: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Open a new terminal window and run the multi app run template: +```bash +dapr run -f . +``` + +The terminal console output should look similar to this: + +```text +== APP - checkout-http == Published data: {"orderId":1} +== APP - order-processor == Subscriber received: {"orderId":1} +== APP - checkout-http == Published data: {"orderId":2} +== APP - order-processor == Subscriber received: {"orderId":2} +== APP - checkout-http == Published data: {"orderId":3} +== APP - order-processor == Subscriber received: {"orderId":3} +== APP - checkout-http == Published data: {"orderId":4} +== APP - order-processor == Subscriber received: {"orderId":4} +== APP - checkout-http == Published data: {"orderId":5} +== APP - order-processor == Subscriber received: {"orderId":5} +== APP - checkout-http == Published data: {"orderId":6} +== APP - order-processor == Subscriber received: {"orderId":6} +== APP - checkout-http == Published data: {"orderId":7} +== APP - order-processor == Subscriber received: {"orderId":7} +== APP - checkout-http == Published data: {"orderId":8} +== APP - order-processor == Subscriber received: {"orderId":8} +== APP - checkout-http == Published data: {"orderId":9} +== APP - order-processor == Subscriber received: {"orderId":9} +== APP - checkout-http == Published data: {"orderId":10} +== APP - order-processor == Subscriber received: {"orderId":10} +``` + +3. Stop and clean up application processes + +```bash +dapr stop -f . +``` + + +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- go run .` commands. This next section covers how to do this. + +### Run Go order-processor with Dapr + +1. Run the order-processor app with Dapr in the `order-processor` folder: + ```bash cd ./order-processor dapr run \ @@ -33,24 +82,10 @@ dapr run \ -- go run . ``` - - ### Run Go checkout with Dapr 1. Open a new terminal window and navigate to `checkout` directory, then run the Go checkout app with Dapr: - - ```bash cd ./checkout dapr run \ @@ -59,41 +94,9 @@ dapr run \ -- go run . ``` - - -To stop: +### Stop the apps and clean up ```bash dapr stop --app-id checkout dapr stop --app-id order-processor ``` - -### Start all apps with multi app run template file: - -1. Run the multi app run template: - - - -```bash -dapr run -f . -``` - - - -```bash -dapr stop -f . -``` \ No newline at end of file diff --git a/service_invocation/java/http/README.md b/service_invocation/java/http/README.md index 7fa4fe26d..6fa25dbd3 100644 --- a/service_invocation/java/http/README.md +++ b/service_invocation/java/http/README.md @@ -21,120 +21,122 @@ And one order processor service: * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. -### Run Java order-processor with Dapr +## Run all apps with multi-app run template file: -1. Open a new terminal window and navigate to `order-processor` directory and install dependencies: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps: ```bash cd ./order-processor mvn clean install +cd ../checkout +mvn clean install +cd .. ``` + -2. Run the Java order-processor app with Dapr: +2. Run the multi app run template: ```bash -cd ./order-processor -dapr run --app-id order-processor --app-port 9001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar +dapr run -f . ``` - - -### Run Java checkout service with Dapr - -1. Open a new terminal window and navigate to `checkout` directory and install dependencies: +The terminal console output should look similar to this: + +```text +== APP - order-processor == Order received: 1 +== APP - checkout == Order passed: 1 +== APP - order-processor == Order received: 2 +== APP - checkout == Order passed: 2 +== APP - order-processor == Order received: 3 +== APP - checkout == Order passed: 3 +== APP - order-processor == Order received: 4 +== APP - checkout == Order passed: 4 +== APP - order-processor == Order received: 5 +== APP - checkout == Order passed: 5 +== APP - order-processor == Order received: 6 +== APP - checkout == Order passed: 6 +== APP - order-processor == Order received: 7 +== APP - checkout == Order passed: 7 +== APP - order-processor == Order received: 8 +== APP - checkout == Order passed: 8 +== APP - order-processor == Order received: 9 +== APP - checkout == Order passed: 9 +== APP - order-processor == Order received: 10 +== APP - checkout == Order passed: 10 +== APP - order-processor == Order received: 11 +== APP - checkout == Order passed: 11 +== APP - order-processor == Order received: 12 +== APP - checkout == Order passed: 12 +``` - +3. Stop and clean up application processes ```bash -cd ./checkout -mvn clean install +dapr stop -f . ``` -2. Run the Java checkout app with Dapr: +## Run a single app at a time with Dapr (Optional) - +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- java -jar` commands. This next section covers how to do this. + +### Run Java order-processor with Dapr + +1. Open a new terminal window and navigate to `order-processor` directory and install dependencies: ```bash -cd ./checkout -dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- java -jar target/CheckoutService-0.0.1-SNAPSHOT.jar +cd ./order-processor +mvn clean install ``` - +2. Run the Java order-processor app with Dapr: ```bash -dapr stop --app-id checkout -dapr stop --app-id order-processor +dapr run --app-id order-processor --app-port 9001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar ``` -### Start all apps with multi app run template file: - -1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps: +### Run Java checkout service with Dapr - +1. Open a new terminal window and navigate to `checkout` directory and install dependencies: ```bash -cd ./order-processor -mvn clean install -cd ../checkout +cd ./checkout mvn clean install ``` - - -2. Run the multi app run template: - - +2. Run the Java checkout app with Dapr: ```bash -dapr run -f . +dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- java -jar target/CheckoutService-0.0.1-SNAPSHOT.jar ``` - +### Stop and clean up application processes ```bash -dapr stop -f . +dapr stop --app-id checkout +dapr stop --app-id order-processor ``` diff --git a/service_invocation/javascript/http/README.md b/service_invocation/javascript/http/README.md index 16339699e..f33c79a01 100644 --- a/service_invocation/javascript/http/README.md +++ b/service_invocation/javascript/http/README.md @@ -12,123 +12,123 @@ And one order-processor service: - Node order-processor service `order-processor` -### Run Node order-processor with Dapr +## Run all apps with multi-app run template file: -1. Open a new terminal window and navigate to `order-processor` directory and install dependencies: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps: ```bash cd ./order-processor npm install +cd ../checkout +npm install +cd .. ``` -3. Run the Node order-processor app with Dapr: +2. Run the multi app run template: ```bash -cd ./order-processor -dapr run --app-port 5001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- npm start +dapr run -f . ``` - - -### Run Node checkout with Dapr - -1. Open a new terminal window and navigate to `checkout` directory and install dependencies: +The terminal console output should look similar to this: + +```text +== APP - order-processor == Order received: { orderId: 1 } +== APP - checkout == Order passed: {"orderId":1} +== APP - order-processor == Order received: { orderId: 2 } +== APP - checkout == Order passed: {"orderId":2} +== APP - order-processor == Order received: { orderId: 3 } +== APP - checkout == Order passed: {"orderId":3} +== APP - order-processor == Order received: { orderId: 4 } +== APP - checkout == Order passed: {"orderId":4} +== APP - order-processor == Order received: { orderId: 5 } +== APP - checkout == Order passed: {"orderId":5} +== APP - order-processor == Order received: { orderId: 6 } +== APP - checkout == Order passed: {"orderId":6} +== APP - order-processor == Order received: { orderId: 7 } +== APP - checkout == Order passed: {"orderId":7} +== APP - order-processor == Order received: { orderId: 8 } +== APP - checkout == Order passed: {"orderId":8} +== APP - order-processor == Order received: { orderId: 9 } +== APP - checkout == Order passed: {"orderId":9} +== APP - order-processor == Order received: { orderId: 10 } +== APP - checkout == Order passed: {"orderId":10} +== APP - order-processor == Order received: { orderId: 11 } +== APP - checkout == Order passed: {"orderId":11} +== APP - order-processor == Order received: { orderId: 12 } +== APP - checkout == Order passed: {"orderId":12} +``` - +3. Stop and clean up application processes ```bash -cd ./checkout -npm install +dapr stop -f . ``` -2. Run the Node checkout app with Dapr: +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- npm start` commands. This next section covers how to do this. + +### Run Node order-processor with Dapr + +1. Open a new terminal window and navigate to `order-processor` directory and install dependencies: - - ```bash -cd ./checkout -dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- npm start +cd ./order-processor +npm install ``` - +3. Run the Node order-processor app with Dapr: ```bash -dapr stop --app-id checkout -dapr stop --app-id order-processor +dapr run --app-port 5001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- npm start ``` -### Start all apps with multi app run template file: - -1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps: +### Run Node checkout with Dapr - +1. Open a new terminal window and navigate to `checkout` directory and install dependencies: ```bash -cd ./order-processor -npm install -cd ../checkout +cd ./checkout npm install ``` - - -2. Run the multi app run template: - - +2. Run the Node checkout app with Dapr: ```bash -dapr run -f . +dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- npm start ``` - +### Stop and clean up application processes ```bash -dapr stop -f . -``` \ No newline at end of file +dapr stop --app-id checkout +dapr stop --app-id order-processor +``` diff --git a/service_invocation/python/http/README.md b/service_invocation/python/http/README.md index 1020e9b80..989d2f3ba 100644 --- a/service_invocation/python/http/README.md +++ b/service_invocation/python/http/README.md @@ -12,108 +12,127 @@ And one order processor service: - Python order-processor service `order-processor` -### Run Python order-processor with Dapr +## Run all apps with multi-app run template file: -1. Install dependencies for `order-processor` app: +This section shows how to run both applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`. This enables to you test the interactions between multiple applications. + +1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps: ```bash cd ./order-processor pip3 install -r requirements.txt +cd ../checkout +pip3 install -r requirements.txt +cd .. ``` -2. Run the Python order-processor app with Dapr: - +2. Run the multi app run template: ```bash -dapr run --app-port 8001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- python3 order-processor/app.py +dapr run -f . ``` - - -### Run Python checkout with Dapr - -1. Open a new terminal window and install dependencies for `checkout` app: +The terminal console output should look similar to this: + +```text +== APP - order-processor == Order received : {"orderId": 1} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 1} +== APP - order-processor == Order received : {"orderId": 2} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 2} +== APP - order-processor == Order received : {"orderId": 3} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 3} +== APP - order-processor == Order received : {"orderId": 4} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 4} +== APP - order-processor == Order received : {"orderId": 5} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 5} +== APP - order-processor == Order received : {"orderId": 6} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 6} +== APP - order-processor == Order received : {"orderId": 7} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 7} +== APP - order-processor == Order received : {"orderId": 8} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 8} +== APP - order-processor == Order received : {"orderId": 9} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 9} +== APP - order-processor == Order received : {"orderId": 10} +== APP - order-processor == 127.0.0.1 - - [DATE] "POST /orders HTTP/1.1" 200 - +== APP - checkout == Order passed: {"orderId": 10} +``` - +3. Stop and clean up application processes ```bash -cd ./checkout -pip3 install -r requirements.txt +dapr stop -f . ``` - -2. Run the Python checkout app with Dapr: +## Run a single app at a time with Dapr (Optional) + +An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- python3 app.py` commands. This next section covers how to do this. + +### Run Python order-processor with Dapr + +1. Install dependencies for `order-processor` app: - - ```bash -dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- python3 checkout/app.py +cd ./order-processor +pip3 install -r requirements.txt ``` - +2. Run the Python order-processor app with Dapr: ```bash -dapr stop --app-id checkout -dapr stop --app-id order-processor +dapr run --app-port 8001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- python3 app.py ``` -### Start all apps with multi app run template file: - -The dependencies are already installed from previous steps. Simply run the multi app run template. It uses `dapr.yaml` file to determine which applications to run. +### Run Python checkout with Dapr - +1. Open a new terminal window and install dependencies for `checkout` app: ```bash -dapr run -f . +cd ./checkout +pip3 install -r requirements.txt ``` - +2. Run the Python checkout app with Dapr: + +```bash +dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- python3 app.py +``` -Finally, stop all: +### Stop and clean up application processes ```bash -dapr stop -f . -``` \ No newline at end of file +dapr stop --app-id checkout +dapr stop --app-id order-processor +```