mirror of https://github.com/dapr/docs.git
Merge branch 'v1.14' into issue_4117
This commit is contained in:
commit
c8c99e3d90
|
|
@ -646,25 +646,24 @@ OrderPayload orderInfo = new OrderPayload(itemToPurchase, 15000, ammountToPurcha
|
||||||
// Start the workflow
|
// Start the workflow
|
||||||
Console.WriteLine("Starting workflow {0} purchasing {1} {2}", orderId, ammountToPurchase, itemToPurchase);
|
Console.WriteLine("Starting workflow {0} purchasing {1} {2}", orderId, ammountToPurchase, itemToPurchase);
|
||||||
|
|
||||||
await daprClient.StartWorkflowAsync(
|
await daprWorkflowClient.ScheduleNewWorkflowAsync(
|
||||||
workflowComponent: DaprWorkflowComponent,
|
name: nameof(OrderProcessingWorkflow),
|
||||||
workflowName: nameof(OrderProcessingWorkflow),
|
|
||||||
input: orderInfo,
|
input: orderInfo,
|
||||||
instanceId: orderId);
|
instanceId: orderId);
|
||||||
|
|
||||||
// Wait for the workflow to start and confirm the input
|
// Wait for the workflow to start and confirm the input
|
||||||
GetWorkflowResponse state = await daprClient.WaitForWorkflowStartAsync(
|
WorkflowState state = await daprWorkflowClient.WaitForWorkflowStartAsync(
|
||||||
instanceId: orderId,
|
instanceId: orderId);
|
||||||
workflowComponent: DaprWorkflowComponent);
|
|
||||||
|
|
||||||
Console.WriteLine("Your workflow has started. Here is the status of the workflow: {0}", state.RuntimeStatus);
|
Console.WriteLine($"{nameof(OrderProcessingWorkflow)} (ID = {orderId}) started successfully with {state.ReadInputAs<OrderPayload>()}");
|
||||||
|
|
||||||
// Wait for the workflow to complete
|
// Wait for the workflow to complete
|
||||||
|
using var ctx = new CancellationTokenSource(TimeSpan.FromSeconds(5));
|
||||||
state = await daprClient.WaitForWorkflowCompletionAsync(
|
state = await daprClient.WaitForWorkflowCompletionAsync(
|
||||||
instanceId: orderId,
|
instanceId: orderId,
|
||||||
workflowComponent: DaprWorkflowComponent);
|
cancellation: ctx.Token);
|
||||||
|
|
||||||
Console.WriteLine("Workflow Status: {0}", state.RuntimeStatus);
|
Console.WriteLine("Workflow Status: {0}", state.ReadCustomStatusAs<string>());
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `order-processor/Workflows/OrderProcessingWorkflow.cs`
|
#### `order-processor/Workflows/OrderProcessingWorkflow.cs`
|
||||||
|
|
@ -715,7 +714,7 @@ class OrderProcessingWorkflow : Workflow<OrderPayload, OrderResult>
|
||||||
nameof(UpdateInventoryActivity),
|
nameof(UpdateInventoryActivity),
|
||||||
new PaymentRequest(RequestId: orderId, order.Name, order.Quantity, order.TotalCost));
|
new PaymentRequest(RequestId: orderId, order.Name, order.Quantity, order.TotalCost));
|
||||||
}
|
}
|
||||||
catch (TaskFailedException)
|
catch (WorkflowTaskFailedException)
|
||||||
{
|
{
|
||||||
// Let them know their payment was processed
|
// Let them know their payment was processed
|
||||||
await context.CallActivityAsync(
|
await context.CallActivityAsync(
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ Entry | Description | Equivalent
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"@type": "type.googleapis.com/google.protobuf.StringValue",
|
"@type": "type.googleapis.com/google.protobuf.StringValue",
|
||||||
"value": "\"someData\""
|
"value": "someData"
|
||||||
},
|
},
|
||||||
"dueTime": "30s"
|
"dueTime": "30s"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue