quickstarts/pub_sub/java/http
Paul Yuknewicz dcd97eeeeb
Updating Readme's to default to `dapr run -f .` (#874)
* Updating Invoke readme in C# to favor dapr run -f

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local>

* Adding back single app run steps and tests, but to the end.

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>

* Update service_invocation/csharp/http/README.md

Co-authored-by: Mark Fussell <markfussell@gmail.com>
Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com>

* Updated and hardened test

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>

* Invoke * and partial PubSub with multi-run files & readmes & tests

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>

* Multi run done for Pubsub C#, Python and Node (http, sdk)

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local>

* Added Pubsub support for Go, Java

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local>

* updating readmes with correct appid

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local>

* Updating tests for PubSub and Service invoke to Paas with multiapp run

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>

* More fine tuning of pubsub tests (timeouts, step ends)

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>

* Fixing Python FastAPI and C# Pubsub tests

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>

---------

Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local>
Signed-off-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>
Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com>
Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MacBook-Pro-2.local>
Co-authored-by: Paul Yuknewicz <paulyuk@Pauls-MBP-2.lan>
Co-authored-by: Mark Fussell <markfussell@gmail.com>
2023-09-22 10:02:07 -07:00
..
checkout Updating Readme's to default to `dapr run -f .` (#874) 2023-09-22 10:02:07 -07:00
order-processor change order_pub_sub to orderpubsub (#654) 2022-04-26 16:10:19 -07:00
README.md Updating Readme's to default to `dapr run -f .` (#874) 2023-09-22 10:02:07 -07:00
dapr.yaml Updating Readme's to default to `dapr run -f .` (#874) 2023-09-22 10:02:07 -07:00
makefile Removed docker image prefix addition step 2022-07-25 12:28:57 -07:00

README.md

Dapr pub/sub

In this quickstart, there is a publisher microservice checkout and a subscriber microservice order-processor to demonstrate how Dapr enables a publish-subscribe pattern. checkout generates messages and publishes to a specific orders topic, and order-processor subscribers listen for messages of topic orders.

Visit this link for more information about Dapr and Pub-Sub.

Note: This example leverages HTTPClient only. If you are looking for the example using the Dapr Client SDK (recommended) click here.

This quickstart includes one publisher:

  • Java client message generator checkout

And one subscriber:

  • Java subscriber order-processor

Pre-requisites

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 with dapr run -f .. This enables to you test the interactions between multiple applications.

  1. Install dependencies:
cd ./order-processor
mvn clean install
cd ..
cd ./checkout
mvn clean install
cd ..
  1. Open a new terminal window and run the multi app run template:
dapr run -f .

The terminal console output should look similar to this:

== 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
  1. Stop and clean up application processes
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:
cd ./order-processor
mvn clean install
  1. Run the Java subscriber app with Dapr:
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:
cd ./checkout
mvn clean install
  1. Run the Java publisher app with Dapr:
cd ./checkout
 dapr run --app-id checkout-http --resources-path ../../../components -- java -jar target/CheckoutService-0.0.1-SNAPSHOT.jar
dapr stop --app-id checkout-http
dapr stop --app-id order-processor-http