Skip to content

Commit 2dc12db

Browse files
committed
fixing comments from Javi
Signed-off-by: salaboy <[email protected]>
1 parent bdcb6a6 commit 2dc12db

File tree

6 files changed

+28
-36
lines changed

6 files changed

+28
-36
lines changed

spring-boot-examples/workflows/multi-app/README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,53 @@ performs the following orchestration when a new workflow instance is created:
4545

4646
- Call the `RegisterCustomerActivity` activity which can be found inside the `worker-one` application.
4747
- You can find in the workflow definition the configuration to make reference to an Activity that is hosted by a different Dapr application.
48-
```
49-
customer = ctx.callActivity("io.dapr.springboot.examples.workerone.RegisterCustomerActivity",
50-
customer,
51-
new WorkflowTaskOptions("worker-one"),
52-
Customer.class).
53-
await();
48+
```java
49+
customer = ctx.callActivity("io.dapr.springboot.examples.workerone.RegisterCustomerActivity",
50+
customer,
51+
new WorkflowTaskOptions("worker-one"),
52+
Customer.class).
53+
await();
5454
```
5555
- Wait for an external event of type `CustomerReachOut` with a timeout of 5 minutes:
56+
```java
57+
ctx.waitForExternalEvent("CustomerReachOut", Duration.ofMinutes(5), Customer.class).await();
5658
```
57-
ctx.waitForExternalEvent("CustomerReachOut", Duration.ofMinutes(5), Customer.class).await();
58-
```
59-
You can call the following endpoint on the `orchestrator` app to raise the external event:
60-
```
61-
curl -X POST localhost:8080/customers/followup -H 'Content-Type: application/json' -d '{ "customerName": "salaboy" }'
59+
- You can check the status of the workflow for a given customer by sending the following request:
60+
```shell
61+
curl -X POST localhost:8080/customers/status -H 'Content-Type: application/json' -d '{ "customerName": "salaboy" }'
62+
```
63+
- You can call the following endpoint on the `orchestrator` app to raise the external event:
64+
```shell
65+
curl -X POST localhost:8080/customers/followup -H 'Content-Type: application/json' -d '{ "customerName": "salaboy" }'
6266
```
6367
- When the event is received, the workflow move forward to the last activity called `CustomerFollowUpActivity`, that can be found on the `worker-two` app.
64-
```
65-
customer = ctx.callActivity("io.dapr.springboot.examples.workertwo.CustomerFollowupActivity",
68+
```java
69+
customer = ctx.callActivity("io.dapr.springboot.examples.workertwo.CustomerFollowupActivity",
6670
customer,
6771
new WorkflowTaskOptions("worker-two"),
6872
Customer.class).
6973
await();
7074
```
7175
- The workflow completes by handing out the final version of the `Customer` object that has been modified the workflow activities. You can retrieve the `Customer` payload
7276
by running the following command:
73-
```
74-
curl -X POST localhost:8080/customers/output -H 'Content-Type: application/json' -d '{ "customerName": "salaboy" }'
77+
```shell
78+
curl -X POST localhost:8080/customers/output -H 'Content-Type: application/json' -d '{ "customerName": "salaboy" }'
7579
```
7680

7781
## Testing Multi App Workflows
7882

7983
Testing becomes a complex task when you are dealing with multiple Spring Boot applications. For testing this workflow,
8084
we rely on [Testcontainers](https://testcontainers.com) to create the entire setup which enable us to run the workflow end to end.
8185

82-
You can find the end-to-end test in the [OrchestratorAppTestsIT.java]() class inside the `orchestrator` application.
86+
You can find the end-to-end test in the [`OrchestratorAppIT.java`](orchestrator/src/test/java/io/dapr/springboot/examples/orchestrator/OrchestratorAppIT.java) class inside the `orchestrator` application.
8387
This test interact with the application REST endpoints to validate their correct execution.
8488

85-
But the magic behind the test can be located in the `DaprTestContainersConfig.class` which defines the configuration for
86-
all the Dapr containers and the `worker-one` and `worker-two` applications.
89+
But the magic behind the test can be located in the [`DaprTestContainersConfig.class`](orchestrator/src/test/java/io/dapr/springboot/examples/orchestrator/DaprTestContainersConfig.java) which defines the configuration for
90+
all the Dapr containers and the `worker-one` and `worker-two` applications. Check this class to gain a deeper understand how to configure
91+
multiple Dapr-enabled applications.
92+
93+
94+
8795

8896

8997

spring-boot-examples/workflows/multi-app/orchestrator/src/main/java/io/dapr/springboot/examples/orchestrator/CustomersRestController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.Map;
2929

3030
@RestController
31-
@EnableDaprWorkflows
3231
public class CustomersRestController {
3332

3433
private final Logger logger = LoggerFactory.getLogger(CustomersRestController.class);

spring-boot-examples/workflows/multi-app/orchestrator/src/main/java/io/dapr/springboot/examples/orchestrator/OrchestratorApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
package io.dapr.springboot.examples.orchestrator;
1515

16+
import io.dapr.spring.workflows.config.EnableDaprWorkflows;
1617
import org.springframework.boot.SpringApplication;
1718
import org.springframework.boot.autoconfigure.SpringBootApplication;
1819

1920

2021
@SpringBootApplication
22+
@EnableDaprWorkflows
2123
public class OrchestratorApplication {
2224

2325
public static void main(String[] args) {

spring-boot-examples/workflows/multi-app/orchestrator/src/test/java/io/dapr/springboot/examples/orchestrator/DaprTestContainersConfig.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.testcontainers.containers.GenericContainer;
2828
import org.testcontainers.containers.Network;
2929
import org.testcontainers.containers.wait.strategy.Wait;
30-
import org.testcontainers.shaded.org.checkerframework.checker.nullness.qual.Nullable;
3130
import org.testcontainers.utility.DockerImageName;
3231
import org.testcontainers.utility.MountableFile;
3332

@@ -113,11 +112,6 @@ public DaprContainer workerOneDapr(Network daprNetwork, RedisContainer redisCont
113112
.withPlacementContainer(daprPlacementContainer)
114113
.withSchedulerContainer(daprSchedulerContainer)
115114
.withComponent(new Component("kvstore", "state.redis", "v1", getRedisProps()))
116-
// .withDaprLogLevel(DaprLogLevel.DEBUG)
117-
// .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
118-
// .withAppPort(8081)
119-
// .withAppHealthCheckPath("/actuator/health")
120-
// .withAppChannelAddress("host.testcontainers.internal")
121115
.dependsOn(daprPlacementContainer)
122116
.dependsOn(daprSchedulerContainer)
123117
.dependsOn(redisContainer);
@@ -159,11 +153,6 @@ public DaprContainer workerTwoDapr(Network daprNetwork, RedisContainer redisCont
159153
.withPlacementContainer(daprPlacementContainer)
160154
.withSchedulerContainer(daprSchedulerContainer)
161155
.withComponent(new Component("kvstore", "state.redis", "v1", getRedisProps()))
162-
// .withDaprLogLevel(DaprLogLevel.DEBUG)
163-
// .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
164-
// .withAppPort(8082)
165-
// .withAppHealthCheckPath("/actuator/health")
166-
// .withAppChannelAddress("host.testcontainers.internal")
167156
.dependsOn(daprPlacementContainer)
168157
.dependsOn(daprSchedulerContainer)
169158
.dependsOn(redisContainer);
@@ -214,8 +203,6 @@ public DaprContainer daprContainer(Network daprNetwork, RedisContainer redisCont
214203
.withPlacementContainer(daprPlacementContainer)
215204
.withSchedulerContainer(daprSchedulerContainer)
216205
.withComponent(new Component("kvstore", "state.redis", "v1", getRedisProps()))
217-
//.withDaprLogLevel(DaprLogLevel.DEBUG)
218-
//.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
219206
.withAppPort(8080)
220207
.withAppHealthCheckPath("/actuator/health")
221208
.withAppChannelAddress("host.testcontainers.internal")

spring-boot-examples/workflows/multi-app/worker-one/src/test/java/io/dapr/springboot/examples/workerone/DaprTestContainersConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ public DaprContainer daprContainer(Network daprNetwork, RedisContainer redisCont
9595
.withReusablePlacement(reuse)
9696
.withReusableScheduler(reuse)
9797
.withComponent(new Component("kvstore", "state.redis", "v1", redisProps))
98-
// .withDaprLogLevel(DaprLogLevel.DEBUG)
99-
// .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
10098
.withAppPort(8081)
10199
.withAppHealthCheckPath("/actuator/health")
102100
.withAppChannelAddress("host.testcontainers.internal")

spring-boot-examples/workflows/multi-app/worker-two/src/test/java/io/dapr/springboot/examples/workertwo/DaprTestContainersConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ public DaprContainer daprContainer(Network daprNetwork, RedisContainer redisCont
9494
.withReusablePlacement(reuse)
9595
.withReusableScheduler(reuse)
9696
.withComponent(new Component("kvstore", "state.redis", "v1", redisProps))
97-
// .withDaprLogLevel(DaprLogLevel.DEBUG)
98-
// .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
9997
.withAppPort(8082)
10098
.withAppHealthCheckPath("/actuator/health")
10199
.withAppChannelAddress("host.testcontainers.internal")

0 commit comments

Comments
 (0)