计算机系统应用教程网站

网站首页 > 技术文章 正文

开源、强大的工作流引擎:camunda入门介绍

btikc 2024-11-16 17:21:22 技术文章 2 ℃ 0 评论
原创不易,请多多支持!对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/

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表