构建Zeebe作为下一代工作流引擎,用于新兴用例,例如微服务编排用例,这些用例可能需要引擎每秒处理数十万(或数百万)个新工作流实例。为此,我们使用的图形建模标准已经存在了近15年:BPMN(业务流程模型和表示法)。可以预见,未来微服务编排将会是中台服务化最有力的落地工具之一。
借这个机会和大家分享一下基本的Zeebe部署和一个简单的范例。
准备环境
1.先克隆Git上的repository获得Zeebe + Operate in Docker的文件包
git clone https://github.com/zeebe-io/zeebe-docker-compose
2.解压下载的zeebe-docker-compose-master.zip
3.执行基于docker-compose.yml下载并创建相关组件容器
# change to directory of the profile to start, i.e
# cd operate/
docker-compose up
备注: docker-compose down 用来shutdown容器
例如:
(base) MacBookPro:operate zhengr$ docker-compose up
Pulling operate (camunda/operate:1.0.0-alpha11)...
1.0.0-alpha11: Pulling from camunda/operate
6f2f362378c5: Pull complete
494c27a8a6b8: Pull complete
7596bb83081b: Pull complete
1e739bce2743: Pull complete
4dde2a90460d: Pull complete
1f5b8585072c: Pull complete
883cfe76ed71: Pull complete
c025c61085ef: Pull complete
b060cd7d08ce: Pull complete
93da9e8063ec: Pull complete
Pulling elasticsearch (docker.elastic.co/elasticsearch/elasticsearch-oss:6.7.1)...
6.7.1: Pulling from elasticsearch/elasticsearch-oss
8ba884070f61: Pull complete
2202e0dee1cc: Pull complete
046487a6b47b: Pull complete
2bf203bafcf4: Pull complete
ecabf552c89a: Pull complete
93123b7bf511: Pull complete
2867102d5376: Pull complete
Pulling zeebe (camunda/zeebe:0.18.0)...
0.18.0: Pulling from camunda/zeebe
de8cd8ac2c2a: Pull complete
62def3ffad8c: Pull complete
1dafe0169f91: Pull complete
f4521a1bc960: Pull complete
0c2a2533a883: Pull complete
dfd212cc6b74: Pull complete
65e222ddee27: Pull complete
ce1bf1781edd: Pull complete
4c631900e34b: Pull complete
55bebb03879a: Pull complete
6b22452bf891: Pull complete
8e4a1a2f6114: Pull complete
Pulling kibana (docker.elastic.co/kibana/kibana-oss:6.7.1)...
6.7.1: Pulling from kibana/kibana-oss
8ba884070f61: Already exists
9de755da2607: Pull complete
a530113b5366: Pull complete
fcc058e5c07b: Pull complete
b01d58af14f6: Pull complete
74a53cb7bf61: Pull complete
12a05e912a4b: Pull complete
94203c8a1395: Pull complete
Creating operate_kibana_1 ... done
Creating operate_elasticsearch_1 ... done
Creating operate_operate_1 ... done
Creating operate_zeebe_1 ... done
Attaching to operate_kibana_1, operate_operate_1, operate_elasticsearch_1, operate_zeebe_1
备注:
bin/zbctl*
- cli binary to interact with the broker服务 / 端口
我们启动的docker容器将提供如下服务:
- Zeebe broker - port 26500
- Operate - web interface http://localhost:8080 (login: demo/demo)
- ElasticSearch - port https://localhost:9200
- Kibana - port https://localhost:5601
- Simple Monitor - web interface http://localhost:8082
4.检查服务状态
(base) MacBookPro:bin zhengr$ ./zbctl.darwin status
Cluster size: 1
Partitions count: 1
Replication factor: 1
Brokers:
Broker 0 - 172.18.0.5:26501
Partition 1 : Leader
以上容器部署完成后, Zeebe的服务框架就准备好了,接下来我们做范例流程部署。
流程部署
The zbctl
binary is included to allow you to interact with the running broker. The binary is named:
Operating System | zbctl binary |
---|---|
Linux | bin/zbctl |
OS X | bin/zbctl.darwin |
Windows | bin/zbctl.exe |
cd zeebe-docker-compose
bin/zbctl deploy ../path/to/your-file.bpmn
这里我们用一个已经制作完成的BPMN文件部署测试。order-process.bpmn
这个order-process.bpmn可以用zeebe Modeler可视化编排
(base) MacBookPro:bin zhengr$ ./zbctl.darwin deploy order-process.bpmn
{
"key": 2251799813685259,
"workflows": [
{
"bpmnProcessId": "order-process",
"version": 1,
"workflowKey": 2251799813685251,
"resourceName": "order-process.bpmn"
}
]
}
创建流程实例
./bin/zbctl create instance order-process --variables '{"orderId": XXX}'
例如:
(base) MacBookPro:bin zhengr$ ./zbctl.darwin create instance order-process --variables '{"orderId": 45678}'
{
"workflowKey": 2251799813685258,
"bpmnProcessId": "order-process",
"version": 2,
"workflowInstanceKey": 2251799813685260
}
打开 http://localhost:8080 通过Operate检查部署实例情况: