从空白的操作系统开始,运行 dapr 的 quickstarts 。
1 - Quickstart的准备工作
1.1 - 安装docker
安装 docker
参考: https://skyao.io/learning-docker/docs/installation.html
ubuntu 20.04
参考: https://skyao.io/learning-docker/docs/installation/ubuntu.html
添加 GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
准备用于 apt 的仓库:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
执行 apt update :
sudo apt-get update
安装 20.10.21 版本:
VERSION_STRING=5:20.10.21~3-0~ubuntu-focal
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
为了以非 root 用户使用 docker:
sudo usermod -aG docker sky
重新登录或者重启。
1.2 - 安装pythod
安装 pythod
docker 的 quickstart 要求 quickstart 3.7 版本及以上
ubuntu 20.04
默认自带 pythod 3.8, 可以直接使用:
$ which python3
/usr/bin/python3
但奇怪的是默认不自带pip3:
$ pip3 install -r requirements.txt
zsh: command not found: pip3
因此需要手工安装 python3-pip :
sudo apt install -y python3-pip
1.3 - 安装.net
安装 .net
docker 的 quickstart 对 .net 的要求是
实际测试不能用 .NET 7, 只能用 .NET 6
ubuntu 20.04
参考: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-2004
添加仓库:
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
安装 dotnet-sdk-6.0 :
sudo apt-get install -y dotnet-sdk-6.0
安装 aspnetcore-runtime-6.0:
sudo apt-get install -y aspnetcore-runtime-6.0
1.4 - 安装jdk
要求
docker 的 quickstart 对 java 的要求是 jdk 11
为了方便管理不同版本的 jdk, 推荐使用 sdkman
安装 sdkman
参考: https://skyao.io/learning-ubuntu-server/docs/development/common/sdkman.html
ubuntu 20.04
sudo apt install unzip zip
curl -s "https://get.sdkman.io" | bash
安装 jdk 11
ubuntu 20.04
执行
sdk list java
可以看到各种可选择的 jdk ,选择 11.0.20-zulu
:
sdk install java 11.0.20-zulu
安装 maven
ubuntu20.04
sudo apt install maven
2 - 安装 dapr cli
安装 dapr CLI
参考: https://docs.dapr.io/getting-started/install-dapr-cli/
ubuntu 20.04
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
输出为:
Getting the latest Dapr CLI...
Your system is linux_amd64
Installing Dapr CLI...
Installing v1.11.0 Dapr CLI...
Downloading https://github.com/dapr/cli/releases/download/v1.11.0/dapr_linux_amd64.tar.gz ...
dapr installed into /usr/local/bin successfully.
CLI version: 1.11.0
Runtime version: 1.11.3
To get started with Dapr, please visit https://docs.dapr.io/getting-started/
安装后检查:
dapr -h
初始化 dapr
参考: https://docs.dapr.io/getting-started/install-dapr-selfhost/
ubuntu 20.04
dapr init
输出为:
⌛ Making the jump to hyperspace...
ℹ️ Container images will be pulled from Docker Hub
ℹ️ Installing runtime version 1.11.3
← Downloading binaries and setting up components...
Dapr runtime installed to /home/sky/.dapr/bin, you may run the following to add it to your path if you want to run daprd directly:
export PATH=$PATH:/home/sky/.dapr/bin
✅ Downloading binaries and setting up components...
✅ Downloaded binaries and completed components set up.
ℹ️ daprd binary has been installed to /home/sky/.dapr/bin.
ℹ️ dapr_placement container is running.
ℹ️ dapr_redis container is running.
ℹ️ dapr_zipkin container is running.
ℹ️ Use `docker ps` to check running containers.
✅ Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started
此时执行:
docker ps
可以看到当前和 dapr 相关的几个容器正在运行:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bf674f47c1b9 daprio/dapr:1.11.3 "./placement" About a minute ago Up About a minute 0.0.0.0:50005->50005/tcp, :::50005->50005/tcp dapr_placement
b26edce4fd09 openzipkin/zipkin "start-zipkin" 6 hours ago Up 2 minutes (healthy) 9410/tcp, 0.0.0.0:9411->9411/tcp, :::9411->9411/tcp dapr_zipkin
0bb3b7b8e9dc redis:6 "docker-entrypoint.s…" 6 hours ago Up 2 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp dapr_redis
3 - 克隆代码仓库
代码仓库
准备代码目录:
mkdir -p work/code/dapr
cd work/code/dapr
git clone quickstarts 的代码仓库:
git clone https://github.com/dapr/quickstarts.git
cd quickstarts
4 - 运行 workflow 的 quickstart
4.1 - .net
运行 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 没有了,导致无法看到调用关系。
等待修复。
4.2 - python
运行 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
4.3 - Java
背景
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}