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

返回本页常规视图.

介绍

Dapr的介绍,以及Dapr的资料收集

1 - Dapr介绍

Dapr介绍

Dapr是什么?

Dapr 是 Distributed Application Runtime (分布式应用运行时)的缩写。

Dapr github首页的介绍是:

Dapr is a portable, event-driven, runtime for building distributed applications across cloud and edge.

Dapr是一种可移植的,事件驱动的运行时,用于构建跨云和边缘的分布式应用。

号称可以:

Any language, any framework, anywhere

详细介绍是:

Dapr是一种可移植的,serverless的,事件驱动的运行时,它使开发人员可以轻松构建弹性,无状态和有状态微服务,这些服务运行在云和边缘上,并包含多种语言和开发框架。

Dapr 整理了构建微服务应用为开放,独立的构建块的最佳实践,使您能够使用自己选择的语言和框架来构建可移植的应用程序。 每个构建块都是独立的,您可以在应用中使用其中的一个或多个。

注意:Dapr目前正处于社区开发中的 Alpha 阶段。 在其1.0稳定版本发布之前,不要将 Dapr 用于生产工作负载。

下图是 Dapr 的概念模型:

以下内容来自:https://github.com/dapr/dapr

目标

  • 使开发人员能够使用任何语言或框架来编写分布式应用
  • 通过提供最佳实践构建模块来解决开发人员构建微服务应用时面临的难题
  • 社区驱动,开放,供应商无关
  • 获得新的贡献者
  • 通过开放的API提供一致性和可移植性
  • 跨云和边缘,与平台无关
  • 拥抱可扩展性并提供可插入组件,而无需供应商锁定
  • 通过高性能和轻量级实现物联网(IoT)和边缘场景
  • 可以从现有代码中逐步采用,而没有运行时依赖

工作方式

Dapr向每个计算单元注入了一个Sidecar容器/进程。Sidecar与事件触发器进行交互,并通过标准HTTP或gRPC协议与计算单元进行通信。这使Dapr能够支持所有现有和将来的编程语言,而无需您导入框架或库。

Dapr通过标准的HTTP verbs 或gRPC interface 提供内置的状态管理,可靠消息传递(至少一次传递),触发器和绑定。这使您可以遵循相同的编程范例编写无状态,有状态和类似于actor的服务。您可以自由选择一致性模型,线程模型和消息传递模式。

Dapr在Kubernetes上原生运行,也可以作为机器上的独立二进制文件,在IoT设备上运行,也可以作为容器注入到任何系统中,无论是在云端还是在本地。

Dapr使用可插拔状态存储和消息总线(例如Redis)以及gRPC来提供广泛的通信方法,包括使用gRPC的直接 dapr-to-dapr 通讯和具有保证传递和至少一次语义的异步Pub-Sub。

为什么用 Dapr?

编写高性能,可伸缩和可靠的分布式应用很困难。 Dapr带给您成熟的模式和实践。 它将事件驱动和 actor 的语义统一到一个简单而一致的编程模型中。 它支持所有编程语言,没有框架锁定。 您不会接触到低级原语,例如线程,并发控制,分区和伸缩。 相反,您可以通过使用所选的熟悉的Web框架实现简单的Web服务器来编写代码。

Dapr在线程和状态一致性模型方面很灵活。 如果愿意,可以利用多线程,还可以在不同的一致性模型中进行选择。 这种灵活性使得无需人为约束即可实施高级方案。 您可能还选择利用其他Actor框架中熟悉的单线程调用。 Dapr是独一无二的,因为您可以在这些模型之间无缝转换而无需重写代码。

特性

  • 事件驱动的Pub-Sub系统,具有可插拔提供商和至少一次的语义
  • 输入和输出绑定,使用可插拔提供商
  • 具有可插拔数据存储的状态管理
  • 一致的服务到服务发现和调用
  • 选择加入状态模型:强大/最终的一致性,首次写入/最后写入获胜
  • 跨平台虚拟 actor
  • 密钥管理,从安全密钥库中提取密钥。
  • 限速
  • 内置可观测性支持
  • 使用专用的Operator和CRD在Kubernetes上原生运行
  • 通过HTTP和gRPC支持所有编程语言
  • 来自Azure,AWS,GCP的多云,开放式组件(绑定,发布-订阅,状态)
  • 在任何地方运行,无论是进程还是容器化
  • 轻量级(58MB二进制,4MB物理内存)
  • 作为Sidecar运行-无需特殊的SDK或类库
  • 专用的CLI-开发人员友好的体验,易于调试
  • Java,.NET Core,Go,Javascript,Python,Rust和C ++的客户端

2 - 概述

Dapr的概述

2.1 - Dapr的构建

Dapr的构建

build

在项目根目录下执行 :

$ make build
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/daprd ./cmd/daprd/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/placement ./cmd/placement/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/operator ./cmd/operator/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/injector ./cmd/injector/main.go;
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build  -ldflags="-X github.com/dapr/dapr/pkg/version.commit=v0.8.0-rc.2-96-g79a1f14 -X github.com/dapr/dapr/pkg/version.version=edge -s -w" -o ./dist/darwin_amd64/release/sentry ./cmd/sentry/main.go;

构建完成之后得到的文件:

$ ls -lh ./dist/darwin_amd64/release/
total 429128
-rwxr-xr-x  1 aoxiaojian  staff    89M Aug 13 17:19 daprd
-rwxr-xr-x  1 aoxiaojian  staff    33M Aug 13 17:20 injector
-rwxr-xr-x  1 aoxiaojian  staff    35M Aug 13 17:20 operator
-rwxr-xr-x  1 aoxiaojian  staff    12M Aug 13 17:19 placement
-rwxr-xr-x  1 aoxiaojian  staff    33M Aug 13 17:20 sentry

2.2 - Dapr的命令行参数

Dapr的命令行参数
name default value 可选值 说明
mode standalone standalone / kubernetes Runtime mode for Dapr
dapr-http-port 3500 HTTP port for Dapr API to listen on
dapr-grpc-port 50001 gRPC port for the Dapr API to listen on
dapr-internal-grpc-port "" gRPC port for the Dapr Internal API to listen on
如果不指定,则dapr会自动获取一个随机可用的空闲端口
app-port "" The port the application is listening on
如果不设置,则不能建立dapr和应用之间的 app channel
也就意味着dapr 无法发送请求给应用了
同时dapr也无法从应用读取配置: http://localhost:<app_port>/dapr/config
注意:app的地址在代码中写死 127.0.0.1
profile-port 7777 The port for the profile server
app-protocol http http / grpc Protocol for the application: grpc or http
components-path "" Path for components directory. If empty, components will not be loaded. Self-hosted mode only
仅在dapr mode为standalone时有效
config "" Path to config file, or name of a configuration object
被称为 global configuration
如果是kubernetes mode,读取k8s的配置
如果是standalone mode,读取配置文件
如果没有配置,则装载默认配置
app-id "" A unique ID for Dapr. Used for Service Discovery and state
control-plane-address "" Address for a Dapr control plane
仅在dapr mode为kubernetes时有效
sentry-address "" Address for the Sentry CA service
placement-host-address "" Address for the Dapr placement service
allowed-origins * Allowed HTTP origins
enable-profiling false True / false Enable profiling
version false True / false Prints the runtime version (然后dapr就会退出)
app-max-concurrency -1 Controls the concurrency level when forwarding requests to user code
enable-mtls false True / false Enables automatic mTLS for daprd to daprd communication channels

1.0 之后被弃用的flag:

name 说明
placement-address 改为 placement-host-address
如果同时设置,以 placement-host-address 为准
max-concurrency 改为 app-max-concurrency
如果同时设置,以 app-max-concurrency 为准
protocol 改为 app-protocol
如果同时设置,以 app-protocol 为准

-app-id hellogrpc -app-port 3000 -protocol grpc -dapr-http-port 3005 -dapr-grpc-port 52000 -placement-address localhost:50005 -components-path components

3 - Quickstart

Dapr的Quickstarts

从空白的操作系统开始,运行 dapr 的 quickstarts 。

3.1 - Quickstart的准备工作

运行 dapr 的 Quickstart 的准备工作

3.1.1 - 安装docker

quickstart 是运行在 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

重新登录或者重启。

3.1.2 - 安装pythod

为运行基于 pythod 的 quickstart 做准备

安装 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

3.1.3 - 安装.net

为运行基于 .net 的 quickstart 做准备

安装 .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

3.1.4 - 安装jdk

为运行基于 java 的 quickstart 做准备

要求

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

3.2 - 安装 dapr cli

安装Dapr并进行初始化

安装 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.3 - 克隆代码仓库

克隆 quickstarts 的代码仓库

代码仓库

准备代码目录:

mkdir -p work/code/dapr
cd work/code/dapr

git clone quickstarts 的代码仓库:

git clone https://github.com/dapr/quickstarts.git
cd quickstarts

3.4 - 运行 workflow 的 quickstart

运行 dapr workflow 的 quickstart

3.4.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 没有了,导致无法看到调用关系。

等待修复。

3.4.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.4.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}

4 - 资料收集

收集Dapr的各种资料

官方网站

社区

  • dapr-cn :Dapr中文社区,专注于dapr的文档、新闻稿本地化、新特性贡献以及中文社区推广
  • Dapr 中文文档库: Dapr 中文文档库,由 dapr-cn 创建并维护的对 docs.dapr.io 内容的翻译,旨在为更熟悉中文的开发者提供一些文档上的帮助。

备注:由于dapr翻译计划已经启动,我也参与其中,我在学习笔记中翻译的部分官方文档内容都将陆续迁移过去,之后会删除学习笔记中的官方文档翻译内容。

文档

文章&演讲

介绍性的文章:

实践性的文章:

视频

相关资料