这是本节的多页打印视图。 点击此处打印.

返回本页常规视图.

运行 workflow 的 quickstart

运行 dapr workflow 的 quickstart

1 - .net

运行 dapr workflow 的 .net quickstart

运行 quickstart

执行:

cd workflows/csharp/sdk/order-processor
dapr run --app-id order-processor dotnet run

输出为:

ℹ️  Starting Dapr with id order-processor. HTTP Port: 43787. gRPC Port: 36499
ℹ️  Checking if Dapr sidecar is listening on HTTP port 43787
INFO[0000] starting Dapr Runtime -- version 1.11.3 -- commit 9f99c6adca78dfc04b8063974f27b3a7534ae798  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] log level set to: info                        app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] metrics server started on :45063/             app_id=order-processor instance=dapr15 scope=dapr.metrics type=log ver=1.11.3
INFO[0000] Resiliency configuration loaded               app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] standalone mode configured                    app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] app id: order-processor                       app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] mTLS is disabled. Skipping certificate request and tls validation  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Dapr trace sampler initialized: DaprTraceSampler(P=1.000000)  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] local service entry announced: order-processor -> 192.168.99.15:46019  app_id=order-processor component="mdns (nameResolution/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0000] Initialized name resolution to mdns           app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading components…                           app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Component loaded: pubsub (pubsub.redis/v1)    app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Waiting for all outstanding components to be processed  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Using 'statestore' as actor state store       app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Component loaded: statestore (state.redis/v1)  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] All outstanding components processed          app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading endpoints                             app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Waiting for all outstanding http endpoints to be processed  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] All outstanding http endpoints processed      app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC proxy enabled                            app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC server listening on TCP address: :36499  app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Enabled gRPC tracing middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Enabled gRPC metrics middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Registering workflow engine for gRPC endpoint: [::]:36499  app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] API gRPC server is running on port 36499      app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] enabled metrics http middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] enabled tracing http middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] HTTP server listening on TCP address: :43787  app_id=order-processor instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] http server is running on port 43787          app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] The request body size parameter is: 4         app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC server listening on TCP address: :46019  app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] Enabled gRPC tracing middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] Enabled gRPC metrics middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] internal gRPC server is running on port 46019  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0000] App channel is not initialized. Did you configure an app-port?  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] actor runtime started. actor idle timeout: 1h0m0s. actor scan interval: 30s  app_id=order-processor instance=dapr15 scope=dapr.runtime.actor type=log ver=1.11.3
INFO[0000] Configuring workflow engine with actors backend  app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0000] Registering component for dapr workflow engine...  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] initializing Dapr workflow component          app_id=order-processor component="dapr (workflow.dapr/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
WARN[0000] app channel not initialized, make sure -app-port is specified if pubsub subscription is required  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0000] failed to read from bindings: app channel not initialized   app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] dapr initialized. Status: Running. Init Elapsed 10ms  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] placement tables updated, version: 0          app_id=order-processor instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
ℹ️  Checking if Dapr sidecar is listening on GRPC port 36499
ℹ️  Dapr sidecar is up and running.
ℹ️  Updating metadata for appPID: 5624
ℹ️  Updating metadata for app command: dotnet run
✅  You're up and running! Both Dapr and your app logs will appear here.

== APP == info: Microsoft.DurableTask[1]
== APP ==       Durable Task worker is connecting to sidecar at localhost:36499.
== APP == info: Microsoft.Hosting.Lifetime[0]
== APP ==       Application started. Press Ctrl+C to shut down.
== APP == info: Microsoft.Hosting.Lifetime[0]
== APP ==       Hosting environment: Production
== APP == info: Microsoft.Hosting.Lifetime[0]
== APP ==       Content root path: /home/sky/work/code/dapr/quickstarts/workflows/csharp/sdk/order-processor
== APP == Starting workflow 375d349f purchasing 10 Cars
INFO[0003] Error processing operation DaprBuiltInActorNotFoundRetries. Retrying in 1s…  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
== APP == info: Microsoft.DurableTask[4]
== APP ==       Sidecar work-item streaming connection established.
INFO[0003] work item stream established by user-agent: [grpc-dotnet/2.50.0 (.NET 6.0.22; CLR 6.0.22; net6.0; linux; x64)]  app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0003] worker started with backend dapr.actors/v1-alpha  app_id=order-processor instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
INFO[0003] Workflow engine started                       app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0006] placement tables updated, version: 1          app_id=order-processor instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
INFO[0006] Recovered processing operation DaprBuiltInActorNotFoundRetries.  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0006] Redis does not support transaction rollbacks and should not be used in production as an actor state store.  app_id=order-processor component="statestore (state.redis/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0006] created new workflow instance with ID '375d349f'  app_id=order-processor component="dapr (workflow.dapr/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0006] 375d349f: starting new 'OrderProcessingWorkflow' instance with ID = '375d349f'.  app_id=order-processor instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == info: WorkflowConsoleApp.Activities.NotifyActivity[0]
== APP ==       Received order 375d349f for 10 Cars at $15000
== APP == Your workflow has started. Here is the status of the workflow: Running
== APP == info: WorkflowConsoleApp.Activities.ReserveInventoryActivity[0]
== APP ==       Reserving inventory for order 375d349f of 10 Cars
== APP == info: WorkflowConsoleApp.Activities.ReserveInventoryActivity[0]
== APP ==       There are: 100, Cars available for purchase
== APP == info: WorkflowConsoleApp.Activities.ProcessPaymentActivity[0]
== APP ==       Processing payment: 375d349f for 10 Cars at $15000
== APP == info: WorkflowConsoleApp.Activities.ProcessPaymentActivity[0]
== APP ==       Payment for request ID '375d349f' processed successfully
== APP == info: WorkflowConsoleApp.Activities.UpdateInventoryActivity[0]
== APP ==       Checking Inventory for: Order# 375d349f for 10 Cars
== APP == info: WorkflowConsoleApp.Activities.UpdateInventoryActivity[0]
== APP ==       There are now: 90 Cars left in stock
== APP == info: WorkflowConsoleApp.Activities.NotifyActivity[0]
== APP ==       Order 375d349f has completed!
INFO[0021] 375d349f: 'OrderProcessingWorkflow' completed with a COMPLETED status.  app_id=order-processor instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == Workflow Status: Completed
INFO[0021] work item stream closed                       app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
✅  Exited App successfully
ℹ️  
terminated signal received: shutting down
✅  Exited Dapr successfully

存在问题

.net quickstart 运行没问题,但是 zipkin 显示的 trace 和文档中不一致,startinstance 这个 span 没有了,导致无法看到调用关系。

等待修复。

2 - python

运行 dapr workflow 的 python quickstart

运行 quickstart

执行:

cd workflows/python/sdk/order-processor
pip3 install -r requirements.txt
dapr run --app-id order-processor --resources-path ../../../components/ -- python3 app.py

输出为:

ℹ️  Starting Dapr with id order-processor. HTTP Port: 32971. gRPC Port: 43899
ℹ️  Checking if Dapr sidecar is listening on HTTP port 32971
INFO[0000] starting Dapr Runtime -- version 1.11.3 -- commit 9f99c6adca78dfc04b8063974f27b3a7534ae798  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] log level set to: info                        app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] metrics server started on :45495/             app_id=order-processor instance=dapr15 scope=dapr.metrics type=log ver=1.11.3
INFO[0000] Resiliency configuration loaded               app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] standalone mode configured                    app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] app id: order-processor                       app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] mTLS is disabled. Skipping certificate request and tls validation  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Dapr trace sampler initialized: DaprTraceSampler(P=1.000000)  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] local service entry announced: order-processor -> 192.168.99.15:46027  app_id=order-processor component="mdns (nameResolution/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0000] Initialized name resolution to mdns           app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading components…                           app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Waiting for all outstanding components to be processed  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Using 'statestore-actors' as actor state store  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Component loaded: statestore-actors (state.redis/v1)  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] All outstanding components processed          app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading endpoints                             app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Waiting for all outstanding http endpoints to be processed  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] All outstanding http endpoints processed      app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC proxy enabled                            app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC server listening on TCP address: :43899  app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Enabled gRPC tracing middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Enabled gRPC metrics middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Registering workflow engine for gRPC endpoint: [::]:43899  app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] API gRPC server is running on port 43899      app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] enabled metrics http middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] enabled tracing http middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] HTTP server listening on TCP address: :32971  app_id=order-processor instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] http server is running on port 32971          app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] The request body size parameter is: 4         app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC server listening on TCP address: :46027  app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] Enabled gRPC tracing middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] Enabled gRPC metrics middleware               app_id=order-processor instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] internal gRPC server is running on port 46027  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0000] App channel is not initialized. Did you configure an app-port?  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] actor runtime started. actor idle timeout: 1h0m0s. actor scan interval: 30s  app_id=order-processor instance=dapr15 scope=dapr.runtime.actor type=log ver=1.11.3
INFO[0000] Configuring workflow engine with actors backend  app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0000] Registering component for dapr workflow engine...  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] initializing Dapr workflow component          app_id=order-processor component="dapr (workflow.dapr/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
WARN[0000] failed to read from bindings: app channel not initialized   app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] dapr initialized. Status: Running. Init Elapsed 8ms  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] placement tables updated, version: 2          app_id=order-processor instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
ℹ️  Checking if Dapr sidecar is listening on GRPC port 43899
ℹ️  Dapr sidecar is up and running.
ℹ️  Updating metadata for appPID: 11366
ℹ️  Updating metadata for app command: python3 app.py
✅  You're up and running! Both Dapr and your app logs will appear here.

== APP == *** Welcome to the Dapr Workflow console app sample!
== APP == *** Using this app, you can place orders that start workflows.
== APP == 2023-09-27 07:44:02.567 durabletask-worker INFO: Starting gRPC worker that connects to 127.0.0.1:43899
INFO[0006] work item stream established by user-agent: [grpc-python/1.58.0 grpc-c/35.0.0 (linux; chttp2)]  app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0006] worker started with backend dapr.actors/v1-alpha  app_id=order-processor instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == 2023-09-27 07:44:02.579 durabletask-worker INFO: Successfully connected to 127.0.0.1:43899. Waiting for work items...
INFO[0006] Workflow engine started                       app_id=order-processor instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
== APP == item: InventoryItem(item_name=Paperclip, per_item_cost=5, quantity=100)
== APP == item: InventoryItem(item_name=Cars, per_item_cost=15000, quantity=100)
== APP == item: InventoryItem(item_name=Computers, per_item_cost=500, quantity=100)
== APP == ==========Begin the purchase of item:==========
== APP == Starting order workflow, purchasing 10 of cars
INFO[0006] Error processing operation DaprBuiltInActorNotFoundRetries. Retrying in 1s…  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0009] placement tables updated, version: 3          app_id=order-processor instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
INFO[0010] Recovered processing operation DaprBuiltInActorNotFoundRetries.  app_id=order-processor instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0010] Redis does not support transaction rollbacks and should not be used in production as an actor state store.  app_id=order-processor component="statestore-actors (state.redis/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0010] created new workflow instance with ID '662f09df-fcfb-4ee1-bda0-1327e3a7116f'  app_id=order-processor component="dapr (workflow.dapr/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0010] 662f09df-fcfb-4ee1-bda0-1327e3a7116f: starting new 'order_processing_workflow' instance with ID = '662f09df-fcfb-4ee1-bda0-1327e3a7116f'.  app_id=order-processor instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == app.py:49: UserWarning: The Workflow API is an Alpha version and is subject to change.
== APP ==   start_resp = daprClient.start_workflow(workflow_component=workflow_component,
== APP == app.py:86: UserWarning: The Workflow API is an Alpha version and is subject to change.
== APP ==   state = daprClient.get_workflow(instance_id=_id, workflow_component=workflow_component)
== APP == 2023-09-27 07:44:06.592 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 1 task(s) and 0 event(s).
== APP == INFO:NotifyActivity:Received order 662f09df-fcfb-4ee1-bda0-1327e3a7116f for 10 cars at $150000 !
== APP == 2023-09-27 07:44:06.605 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 1 task(s) and 0 event(s).
== APP == INFO:VerifyInventoryActivity:Verifying inventory for order 662f09df-fcfb-4ee1-bda0-1327e3a7116f of 10 cars
== APP == INFO:VerifyInventoryActivity:There are 100 Cars available for purchase
== APP == 2023-09-27 07:44:06.617 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 1 task(s) and 0 event(s).
== APP == INFO:RequestApprovalActivity:Requesting approval for payment of 150000 USD for 10 cars
== APP == 2023-09-27 07:44:06.627 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 1 task(s) and 1 event(s).
INFO[0020] Raised event manager_approval on workflow instance '662f09df-fcfb-4ee1-bda0-1327e3a7116f'  app_id=order-processor component="dapr (workflow.dapr/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
== APP == app.py:95: UserWarning: The Workflow API is an Alpha version and is subject to change.
== APP ==   state = daprClient.get_workflow(instance_id=_id, workflow_component=workflow_component)
== APP == app.py:79: UserWarning: The Workflow API is an Alpha version and is subject to change.
== APP ==   daprClient.raise_workflow_event(instance_id=_id, workflow_component=workflow_component,
== APP == 2023-09-27 07:44:16.598 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f Event raised: manager_approval
== APP == 2023-09-27 07:44:16.598 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 2 task(s) and 0 event(s).
== APP == INFO:NotifyActivity:Payment for order 662f09df-fcfb-4ee1-bda0-1327e3a7116f has been approved!
== APP == 2023-09-27 07:44:16.608 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 2 task(s) and 0 event(s).
== APP == INFO:ProcessPaymentActivity:Processing payment: 662f09df-fcfb-4ee1-bda0-1327e3a7116f for 10 cars at 150000 USD
== APP == INFO:ProcessPaymentActivity:Payment for request ID 662f09df-fcfb-4ee1-bda0-1327e3a7116f processed successfully
== APP == 2023-09-27 07:44:16.618 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 2 task(s) and 0 event(s).
== APP == INFO:UpdateInventoryActivity:Checking inventory for order 662f09df-fcfb-4ee1-bda0-1327e3a7116f for 10 cars
== APP == INFO:UpdateInventoryActivity:There are now 90 cars left in stock
== APP == 2023-09-27 07:44:16.633 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Waiting for 2 task(s) and 0 event(s).
== APP == INFO:NotifyActivity:Order 662f09df-fcfb-4ee1-bda0-1327e3a7116f has completed!
== APP == 2023-09-27 07:44:16.643 durabletask-worker INFO: 662f09df-fcfb-4ee1-bda0-1327e3a7116f: Orchestration completed with status: COMPLETED
INFO[0020] 662f09df-fcfb-4ee1-bda0-1327e3a7116f: 'order_processing_workflow' completed with a COMPLETED status.  app_id=order-processor instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == Workflow completed! Result: Completed
== APP == Purchase of item is  Completed

3 - Java

运行 dapr workflow 的 Java quickstart

背景

Java 的 quickstart 还没有 merge:

https://github.com/dapr/quickstarts/pull/925

要执行的话需要用到

https://github.com/skyao/quickstarts/tree/java-workflow-quickstart

运行 quickstart

执行:

cd workflows/java/sdk/order-processor
mvn clean install
dapr run --app-id WorkflowConsoleApp --resources-path ../../../components/ --dapr-grpc-port 50001 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar io.dapr.quickstarts.workflows.WorkflowConsoleApp

输出为:

ℹ️  Starting Dapr with id WorkflowConsoleApp. HTTP Port: 45063. gRPC Port: 50001
ℹ️  Checking if Dapr sidecar is listening on HTTP port 45063
INFO[0000] starting Dapr Runtime -- version 1.11.3 -- commit 9f99c6adca78dfc04b8063974f27b3a7534ae798  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] log level set to: info                        app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] metrics server started on :45793/             app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.metrics type=log ver=1.11.3
INFO[0000] Resiliency configuration loaded               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] standalone mode configured                    app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] app id: WorkflowConsoleApp                    app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] mTLS is disabled. Skipping certificate request and tls validation  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Dapr trace sampler initialized: DaprTraceSampler(P=1.000000)  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] local service entry announced: WorkflowConsoleApp -> 192.168.99.15:43665  app_id=WorkflowConsoleApp component="mdns (nameResolution/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0000] Initialized name resolution to mdns           app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading components…                           app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Waiting for all outstanding components to be processed  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Using 'statestore-actors' as actor state store  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Component loaded: statestore-actors (state.redis/v1)  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] All outstanding components processed          app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Loading endpoints                             app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] Waiting for all outstanding http endpoints to be processed  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] All outstanding http endpoints processed      app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC proxy enabled                            app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC server listening on TCP address: :50001  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Enabled gRPC tracing middleware               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Enabled gRPC metrics middleware               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] Registering workflow engine for gRPC endpoint: [::]:50001  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.api type=log ver=1.11.3
INFO[0000] API gRPC server is running on port 50001      app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] enabled metrics http middleware               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] enabled tracing http middleware               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] HTTP server listening on TCP address: :45063  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.http type=log ver=1.11.3
INFO[0000] http server is running on port 45063          app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] The request body size parameter is: 4         app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] gRPC server listening on TCP address: :43665  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] Enabled gRPC tracing middleware               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] Enabled gRPC metrics middleware               app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.grpc.internal type=log ver=1.11.3
INFO[0000] internal gRPC server is running on port 43665  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0000] App channel is not initialized. Did you configure an app-port?  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] actor runtime started. actor idle timeout: 1h0m0s. actor scan interval: 30s  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.actor type=log ver=1.11.3
INFO[0000] Configuring workflow engine with actors backend  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0000] Registering component for dapr workflow engine...  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] initializing Dapr workflow component          app_id=WorkflowConsoleApp component="dapr (workflow.dapr/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
WARN[0000] failed to read from bindings: app channel not initialized   app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] dapr initialized. Status: Running. Init Elapsed 7ms  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0000] placement tables updated, version: 5          app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
ℹ️  Checking if Dapr sidecar is listening on GRPC port 50001
ℹ️  Dapr sidecar is up and running.
ℹ️  Updating metadata for appPID: 13886
ℹ️  Updating metadata for app command: java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar io.dapr.quickstarts.workflows.WorkflowConsoleApp
✅  You're up and running! Both Dapr and your app logs will appear here.

== APP == *** Welcome to the Dapr Workflow console app sample!
== APP == *** Using this app, you can place orders that start workflows.
INFO[0003] placement tables updated, version: 6          app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
== APP == Start workflow runtime
== APP == Sep 27, 2023 7:51:22 AM com.microsoft.durabletask.DurableTaskGrpcWorker startAndBlock
== APP == INFO: Durable Task worker is connecting to sidecar at 127.0.0.1:50001.
INFO[0007] work item stream established by user-agent: [dapr-sdk-java/v1.10.0-SNAPSHOT grpc-java-netty/1.46.0]  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
INFO[0007] worker started with backend dapr.actors/v1-alpha  app_id=WorkflowConsoleApp instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
INFO[0007] Workflow engine started                       app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.wfengine type=log ver=1.11.3
== APP == ==========Begin the purchase of item:==========
== APP == Starting order workflow, purchasing 10 of cars
INFO[0007] Error processing operation DaprBuiltInActorNotFoundRetries. Retrying in 1s…  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
INFO[0010] placement tables updated, version: 7          app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime.actor.internal.placement type=log ver=1.11.3
INFO[0010] Recovered processing operation DaprBuiltInActorNotFoundRetries.  app_id=WorkflowConsoleApp instance=dapr15 scope=dapr.runtime type=log ver=1.11.3
WARN[0010] Redis does not support transaction rollbacks and should not be used in production as an actor state store.  app_id=WorkflowConsoleApp component="statestore-actors (state.redis/v1)" instance=dapr15 scope=dapr.contrib type=log ver=1.11.3
INFO[0010] d4d383b9-d615-489f-bfad-f94fad4c169c: starting new 'io.dapr.quickstarts.workflows.OrderProcessingWorkflow' instance with ID = 'd4d383b9-d615-489f-bfad-f94fad4c169c'.  app_id=WorkflowConsoleApp instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == scheduled new workflow instance of OrderProcessingWorkflow with instance ID: d4d383b9-d615-489f-bfad-f94fad4c169c
== APP == [Thread-0] INFO io.dapr.workflows.WorkflowContext - Starting Workflow: io.dapr.quickstarts.workflows.OrderProcessingWorkflow
== APP == [Thread-0] INFO io.dapr.workflows.WorkflowContext - Instance ID(order ID): d4d383b9-d615-489f-bfad-f94fad4c169c
== APP == [Thread-0] INFO io.dapr.workflows.WorkflowContext - Current Orchestration Time: 2023-09-27T07:51:26.473Z
== APP == [Thread-0] INFO io.dapr.workflows.WorkflowContext - Received Order: OrderPayload [itemName=cars, totalCost=150000, quantity=10]
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.NotifyActivity - Received Order: OrderPayload [itemName=cars, totalCost=150000, quantity=10]
== APP == workflow instance d4d383b9-d615-489f-bfad-f94fad4c169c started
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.ReserveInventoryActivity - Reserving inventory for order 'd4d383b9-d615-489f-bfad-f94fad4c169c' of 10 cars
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.ReserveInventoryActivity - There are 100 cars available for purchase
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.ReserveInventoryActivity - Reserved inventory for order 'd4d383b9-d615-489f-bfad-f94fad4c169c' of 10 cars
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.RequestApprovalActivity - Requesting approval for order: OrderPayload [itemName=cars, totalCost=150000, quantity=10]
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.RequestApprovalActivity - Approved requesting approval for order: OrderPayload [itemName=cars, totalCost=150000, quantity=10]
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.ProcessPaymentActivity - Processing payment: d4d383b9-d615-489f-bfad-f94fad4c169c for 10 cars at $150000
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.ProcessPaymentActivity - Payment for request ID 'd4d383b9-d615-489f-bfad-f94fad4c169c' processed successfully
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.UpdateInventoryActivity - Updating inventory for order 'd4d383b9-d615-489f-bfad-f94fad4c169c' of 10 cars
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.UpdateInventoryActivity - Updated inventory for order 'd4d383b9-d615-489f-bfad-f94fad4c169c': there are now 90 cars left in stock
== APP == there are now 90 cars left in stock
== APP == [Thread-0] INFO io.dapr.quickstarts.workflows.activities.NotifyActivity - Order completed! : d4d383b9-d615-489f-bfad-f94fad4c169c
INFO[0021] d4d383b9-d615-489f-bfad-f94fad4c169c: 'io.dapr.quickstarts.workflows.OrderProcessingWorkflow' completed with a COMPLETED status.  app_id=WorkflowConsoleApp instance=dapr15 scope=wfengine.backend type=log ver=1.11.3
== APP == workflow instance completed, out is: {"processed":true}