diff --git a/pub_sub/csharp/sdk/README.md b/pub_sub/csharp/sdk/README.md index fac26e173..3cca55ba7 100644 --- a/pub_sub/csharp/sdk/README.md +++ b/pub_sub/csharp/sdk/README.md @@ -62,7 +62,7 @@ The terminal console output should look similar to this: == APP - order-processor == Subscriber received : Order { OrderId = 10 } ``` -3. Stop and clean up application processes +2. Stop and clean up application processes ```bash dapr stop -f . diff --git a/pub_sub/go/http/README.md b/pub_sub/go/http/README.md index 8f8aeaab0..e58354409 100644 --- a/pub_sub/go/http/README.md +++ b/pub_sub/go/http/README.md @@ -10,6 +10,65 @@ This quickstart includes one publisher: Go client message generator `checkout`. And one subscriber: Go subscriber `order-processor`. +## 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. 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-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 - order-processor-http == Subscriber received: {"orderId":7} +== APP - checkout-http == Published data: {"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: @@ -27,7 +86,7 @@ sleep: 15 ```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 --app-port 6003 --app-id order-processor --app-protocol http --dapr-http-port 3501 --resources-path ../../../components -- go run . ``` diff --git a/pub_sub/go/http/dapr.yaml b/pub_sub/go/http/dapr.yaml index c8c9a161e..e6b04c161 100644 --- a/pub_sub/go/http/dapr.yaml +++ b/pub_sub/go/http/dapr.yaml @@ -2,9 +2,9 @@ version: 1 common: resourcesPath: ../../components/ apps: - - appDirPath: ./order-processor/ - appID: order-processor - appPort: 6002 + - appID: order-processor-http + appDirPath: ./order-processor/ + appPort: 6003 command: ["go", "run", "."] - appID: checkout-http appDirPath: ./checkout/ diff --git a/pub_sub/go/sdk/README.md b/pub_sub/go/sdk/README.md index 5b4f22ef7..3728ea454 100644 --- a/pub_sub/go/sdk/README.md +++ b/pub_sub/go/sdk/README.md @@ -10,6 +10,65 @@ This quickstart includes one publisher: Go client message generator `checkout` And one subscriber: Go subscriber `order-processor` +## 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. 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 == 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 - order-processor == Subscriber received: map[orderId:4] +== APP - checkout-sdk == Published data: {"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 - order-processor == Subscriber received: map[orderId:7] +== APP - checkout-sdk == Published data: {"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: 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..3b574e001 100644 --- a/pub_sub/java/http/README.md +++ b/pub_sub/java/http/README.md @@ -23,6 +23,80 @@ And one subscriber: * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. +## 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: + + +```bash +cd ./order-processor +mvn clean install +cd .. +cd ./checkout +mvn clean install +cd .. +``` + + +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: 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..098e705b1 --- /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: 8081 + 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..306cda368 100644 --- a/pub_sub/java/sdk/README.md +++ b/pub_sub/java/sdk/README.md @@ -23,6 +23,80 @@ And one subscriber: * [OpenJDK 11](https://jdk.java.net/11/) * [Apache Maven](https://maven.apache.org/install.html) version 3.x. +## 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: + + +```bash +cd ./order-processor +mvn clean install +cd .. +cd ./checkout +mvn clean install +cd .. +``` + + +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: 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 720325569..5856e51a3 100644 --- a/pub_sub/javascript/http/README.md +++ b/pub_sub/javascript/http/README.md @@ -18,7 +18,22 @@ And one subscriber: 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: +1. Install dependencies: + + + +```bash +cd ./order-processor +npm install +cd .. +cd ./checkout +npm install +``` + + +2. Open a new terminal window and run the multi app run template: + +```bash +cd ./order-processor +npm install +cd .. +cd ./checkout +npm install +``` +2. Open a new terminal window and run the multi app run template: