原創不易,請多多支持!對Java技術感興趣的童鞋請關注我,後續技術分享更精彩。
簡介
Camunda is a Java-based framework supporting BPMN for workflow and process automation, CMMN for Case Management and DMN for Business Decision Management.
重要概念
- BPMN - Business Process Model and Notation (BPMN) is a standard for Workflow and Process Automation. Camunda supports the 2.0 version of BPMN.
- https://docs.camunda.org/get-started/bpmn20/
- CMMN - Case Management Model and Notation (CMMN) is a standard for Case Management. Camunda supports the 1.1 version of CMMN.
- https://docs.camunda.org/get-started/cmmn11/
- DMN - Decision Model and Notation (DMN) is a standard for Business Decision Management. Camunda supports the 1.1 version of DMN.
- https://docs.camunda.org/get-started/dmn11/
工作流對比
關鍵人物介紹
Tom Baeyens - 創建了jbpm。離開JBoss後,jBPM的下一個版本jBPM5完全放棄了jBPM4的基礎代碼,基於Drools Flow重頭來過,目前官網已經推出了jBPM6的beta版本;Tom Baeyens加入Alfresco後很快推出了新的基於jBPM4的開源工作流系統Activiti。2012年末,Alfresco的Activity BPM 小組正經歷一系列的轉變:Tom Baeyens將不再領導Activity工程,決定離開Alfresco。camunda是Activity最大的貢獻者之一(除Alfresco以外),同時也是它一個主要的執行諮詢合作夥伴。camunda表示Activity可能太拘束於Alfresco對以文檔為中心的工作流的需求,而忽視了Activity起步時的更為普遍的BPM平台,故而從Activiti分支建立了camunda BPM項目。
框架總覽
流程引擎架構
框架示例
Camunda Tomcat 集成容器下載:
- https://camunda.org/download/
解壓tomcat,切換到目錄server\apache-tomcat-8.0.24\webapps,包含以下子目錄:
•Camunda -- 管理功能模塊,包含admin、cockpit、tasklist
•camunda-invoice – 發票審批demo
•engine-rest – 工作流程引擎Rest API模塊
•Examples – 其他demo例子
資料庫創建:
切換目錄sql\create\選擇對應sql腳本執行
tomcat配置修改:
切換到server\apache-tomcat-8.0.24\conf\目錄
bpm-platform.xml
camunda自有配置維護文件。
可根據具體應用場景修改以下全局配置屬性
<properties>
<property name="history">full</property>
<property name="databaseSchemaUpdate">true</property>
<property name="authorizationEnabled">true</property>
<property name="jobExecutorActivate">true</property>
<property name="jobExecutorDeploymentAware">true</property>
</properties>
tomcat配置修改:
切換到server\apache-tomcat-8.0.24\conf\目錄
server.xml
tomcat容器管理配置維護文件。
<Resource name="jdbc/ProcessEngine"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
uniqueResourceName="process-engine"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@127.0.0.1:1521:camunda"
defaultTransactionIsolation="READ_COMMITTED"
username="camunda"
password="123456"
maxActive="20"
minIdle="5"
removeAbandoned="true"
removeAbandonedTimeout="60"
testOnBorrow="true"
validationQuery="select count(1) from dual"
logAbandoned="true"/>
應用集成
添加依賴包
compile 'org.camunda.bpm:camunda-engine:7.7.0'
compile 'org.camunda.bpm:camunda-engine-spring:7.7.0'
添加spring bean
<bean id="camundaTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="processEngineName" value="engine" />
<property name="historyLevel" value="HISTORY_LEVEL_FULL"/>
<property name="jobExecutorDeploymentAware" value="true"/>
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="camundaTransactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="true" />
<property name="deploymentResources" value="classpath:*.bpmn" />
</bean>
<bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
modeler流程文件
將modeler設計流程模板放到應用工程resources目錄或者子目錄下。
用戶集成方式
Camunda自有user體系
優:無需改動
缺:靈活性差,運維成本高
使用ldap用戶集成
優:可和支持ldap功能對接
缺:依賴ldap功能限制
通過插件擴展用戶體系
優:通過擴展能實現定製化需求
缺:對camunda熟悉,開發成本高
只使用workflow節點流轉功能
優:應用靈活,可滿足不同業務需求
缺:camunda部分豐富功能無法使用,可能重新開發框架存在組件
Job Executor
文檔地址:https://docs.camunda.org/manual/7.7/user-guide/process-engine/the-job-executor/
Job 激活配置:<property name="jobExecutorActivate" value="true" />
job 工作架構:
同構集群部署:
異構集群部署:
支持異構集群部署,部署node設置jobExecutorDeploymentAware=true
<property name="jobExecutorDeploymentAware">true</property>
附錄
- engine-rest api
- https://docs.camunda.org/manual/7.7/reference/rest/
- Web modeler
- http://bpmn.io/toolkit/bpmn-js/walkthrough/
- camunda get-started
- https://docs.camunda.org/get-started/
- Camunda Guid
- https://docs.camunda.org/manual/7.7/introduction/
- LDAP Identity Service
- https://docs.camunda.org/manual/7.7/user-guide/process-engine/identity-service/