mirror of https://github.com/dapr/quickstarts.git
fixing comments
Signed-off-by: salaboy <Salaboy@gmail.com>
This commit is contained in:
parent
2d00335099
commit
4cc708ba91
|
|
@ -43,6 +43,10 @@ public class ExternalEventsRestController {
|
|||
@Autowired
|
||||
private DaprWorkflowClient daprWorkflowClient;
|
||||
|
||||
/*
|
||||
* **Note:** This local variable is used for examples purposes only.
|
||||
* For production scenarios, you will need to map workflowInstanceIds to your business scenarios.
|
||||
*/
|
||||
private String instanceId;
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +58,7 @@ public class ExternalEventsRestController {
|
|||
@PostMapping("start")
|
||||
public String basic(@RequestBody Order order) throws TimeoutException {
|
||||
logger.info("Received order: {}", order);
|
||||
instanceId = daprWorkflowClient.scheduleNewWorkflow(ExternalEventsWorkflow.class, order);
|
||||
instanceId = daprWorkflowClient.scheduleNewWorkflow(ExternalEventsWorkflow.class, order, order.id());
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ package io.dapr.springboot.examples.external;
|
|||
|
||||
import io.dapr.durabletask.TaskCanceledException;
|
||||
import io.dapr.springboot.examples.external.activities.ProcessOrderActivity;
|
||||
import io.dapr.springboot.examples.external.activities.RequestApprovalActivity;
|
||||
import io.dapr.springboot.examples.external.activities.SendNotificationActivity;
|
||||
import io.dapr.workflows.Workflow;
|
||||
import io.dapr.workflows.WorkflowStub;
|
||||
|
|
@ -30,7 +31,10 @@ public class ExternalEventsWorkflow implements Workflow {
|
|||
ctx.getLogger().info("Starting Workflow: {}", ctx.getName());
|
||||
|
||||
var order = ctx.getInput(Order.class);
|
||||
var approvalStatus = new ApprovalStatus(order.id(), true);
|
||||
|
||||
Boolean approved = ctx.callActivity(RequestApprovalActivity.class.getName(), order, Boolean.class).await();
|
||||
|
||||
var approvalStatus = new ApprovalStatus(order.id(), approved);
|
||||
|
||||
if(order.totalPrice() > 250){
|
||||
try{
|
||||
|
|
|
|||
|
|
@ -21,15 +21,11 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
|
||||
* ProcessOrderActivity simulates processing by another system
|
||||
*/
|
||||
@Component
|
||||
public class ProcessOrderActivity implements WorkflowActivity {
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Object run(WorkflowActivityContext ctx) {
|
||||
Logger logger = LoggerFactory.getLogger(ProcessOrderActivity.class);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/*
|
||||
* RequestApprovalActivity simulates requesting for order approval
|
||||
*/
|
||||
@Component
|
||||
public class RequestApprovalActivity implements WorkflowActivity {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ graph LR
|
|||
|
||||
## Run the tutorial
|
||||
|
||||
1. Use a terminal to navigate to the `tutorials/workflow/java/task-chaining` folder.
|
||||
1. Use a terminal to navigate to the `tutorials/workflow/java/fan-out-fan-in` folder.
|
||||
2. Build and run the project using Maven.
|
||||
|
||||
```bash
|
||||
|
|
@ -58,11 +58,12 @@ graph LR
|
|||
The expected app logs are as follows:
|
||||
|
||||
```text
|
||||
== APP - fanoutfanin == GetWordLength: Received input: word.
|
||||
== APP - fanoutfanin == GetWordLength: Received input: is.
|
||||
== APP - fanoutfanin == GetWordLength: Received input: the.
|
||||
== APP - fanoutfanin == GetWordLength: Received input: shortest.
|
||||
== APP - fanoutfanin == GetWordLength: Received input: which.
|
||||
io.dapr.workflows.WorkflowContext : Starting Workflow: io.dapr.springboot.examples.fanoutfanin.FanOutFanInWorkflow
|
||||
i.d.s.e.f.GetWordLengthActivity : io.dapr.springboot.examples.fanoutfanin.GetWordLengthActivity : Received input: which
|
||||
i.d.s.e.f.GetWordLengthActivity : io.dapr.springboot.examples.fanoutfanin.GetWordLengthActivity : Received input: the
|
||||
i.d.s.e.f.GetWordLengthActivity : io.dapr.springboot.examples.fanoutfanin.GetWordLengthActivity : Received input: shortest
|
||||
i.d.s.e.f.GetWordLengthActivity : io.dapr.springboot.examples.fanoutfanin.GetWordLengthActivity : Received input: word
|
||||
i.d.s.e.f.GetWordLengthActivity : io.dapr.springboot.examples.fanoutfanin.GetWordLengthActivity : Received input: is
|
||||
```
|
||||
|
||||
> Note that the order of the logs may vary.
|
||||
|
|
|
|||
|
|
@ -40,9 +40,10 @@ graph LR
|
|||
The input for the workflow is a string with the value `This`. The expected app logs are as follows:
|
||||
|
||||
```text
|
||||
== APP - chaining == Activity1: Received input: This.
|
||||
== APP - chaining == Activity2: Received input: This is.
|
||||
== APP - chaining == Activity3: Received input: This is task.
|
||||
io.dapr.workflows.WorkflowContext : Starting Workflow: io.dapr.springboot.examples.chain.ChainingWorkflow
|
||||
i.d.springboot.examples.chain.Activity1 : io.dapr.springboot.examples.chain.Activity1 : Received input: This
|
||||
i.d.springboot.examples.chain.Activity2 : io.dapr.springboot.examples.chain.Activity2 : Received input: This is
|
||||
i.d.springboot.examples.chain.Activity3 : io.dapr.springboot.examples.chain.Activity3 : Received input: This is task
|
||||
```
|
||||
|
||||
4. Use the GET request in the [`chaining.http`](./chaining.http) file to get the status of the workflow, or use this cURL command:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ For more information on workflow management, see the [Dapr docs](https://docs.da
|
|||
|
||||
## Inspect the code
|
||||
|
||||
Open the `Program.cs` file in the `tutorials/workflow/csharp/workflow-management/WorkflowManagement` folder. This file contains the endpoint definitions that use the workflow management API. The workflow that is being managed is named `NeverEndingWorkflow` and is a counter that will keep running once it's started.
|
||||
Open the [`WorkflowManagementRestController.java`](src/main/java/io/dapr/springboot/examples/chain/WorkflowManagementRestController.java) file in the `tutorials/workflow/java/workflow-management/` folder. This file contains the endpoint definitions that use the workflow management API. The workflow that is being managed is named `NeverEndingWorkflow` and is a counter that will keep running once it's started.
|
||||
|
||||
## Run the tutorial
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue