quickstarts/tutorials/workflow/csharp/combined-patterns
Marc Duiker 7214b5b414
Add workflow input and outputs to READMEs
Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com>
2025-04-14 12:58:16 +02:00
..
ShippingApp Make classes internal sealed 2025-04-01 12:32:09 +01:00
WorkflowApp Add workflow input and outputs to READMEs 2025-04-14 12:58:16 +02:00
resources Combine pattern examples is working 2025-03-26 13:39:09 +01:00
README.md Add workflow input and outputs to READMEs 2025-04-14 12:58:16 +02:00
dapr.yaml Update folder structure 2025-03-21 16:52:43 +01:00
order-workflow.http Add workflow input and outputs to READMEs 2025-04-14 12:58:16 +02:00

README.md

Combined Workflow Patterns

This tutorial demonstrates how several workflow patterns can be combined in a single, more realistic, workflow. Some of the workflow activities are using other Dapr APIs, such as state management, service invocation, and Pub/Sub.

Inspect the code

The demo consist of two applications:

  • WorkflowApp is the main application that orchestrates an order process in the OrderWorkflow.
  • ShippingApp is a supporting service that is being called by the OrderWorkflow.

The OrderWorkflow combines task chaining, fan-out/fan-in, and waiting for external patterns.

graph LR
   SW((Start
   Workflow))
   EW((End
    Workflow))
   subgraph OrderWorkflow
   direction LR
    CHKI[Check inventory]
    CHKD[Check shipping
    destination]
    IF1{Success?}
    PAY[Process
    payment]
    UPD[Update
    inventory]
    REG[Register
    shipment]
    WAIT[Wait for
    confirmation]
    IF2{Success?}
    RI[Reimburse
    customer]
   end
   subgraph Shipping
    direction LR
    REG2[registerShipment]
    CHKD2[checkDestination]
   end
    SW --> CHKI
    SW --> CHKD <--> CHKD2
    CHKI --> IF1
    CHKD --> IF1
    IF1 --> PAY
    PAY --> UPD
    UPD --> REG -.->|pub/sub| REG2
    REG2 -.->|pub/sub| WAIT
    REG --> WAIT
    WAIT --> IF2
    IF2 -->|Yes| EW
    IF2 -->|No| RI
    RI --> EW

Run the tutorial

  1. Use a terminal to navigate to the tutorials/workflow/csharp/combined-patterns folder.

  2. Build the projects using the .NET CLI.

    dotnet build ./WorkflowApp/
    dotnet build ./ShippingApp/
    
  3. Use the Dapr CLI to run the Dapr Multi-App run file

    dapr run -f .
    
  4. Use the POST request in the order-workflow.http file to start the workflow.

    The input for the workflow is an Order object:

    {
        "id": "{{orderId}}",
        "orderItem" : {
            "productId": "RBD001",
            "productName": "Rubber Duck",
            "quantity": 10,
            "totalPrice": 15.00
        },
        "customerInfo" : {
            "id" : "Customer1",
            "country" : "The Netherlands"
        }
    }
    
  5. Use the GET request in the order-workflow.http file to get the status of the workflow.

    The expected serialized output of the workflow is:

    {\"IsSuccess\":true,\"Message\":\"Order 2a28fd28-15c1-4594-93ec-eb088c6be4a3 processed successfully.\"}"
    

    The Order ID is generated when making the request and is different each time.

  6. Stop the Dapr Multi-App run process by pressing Ctrl+C.