Instructions for running this version of Activiti:
1.JDK 6+,eclipse preferably Kepler or later.
2. The test function is marked with experimental , and the marked part should not be regarded as stable.
Interested students can go to understand the next Activiti Explorer project, he covers most of the functions of Activiti, there is no activiti concept of the students can see the understanding.
First, the configuration of workflow development
Activiti沿用具有Spring配置文件风格的配置,工作流默认是加载名叫activiti.cfg.xml的文件,配置文件大体:
<Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" > <BeanID= "Processengineconfiguration"class= "Org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> < Propertyname= "Jdbcurl"value= "jdbc:h2:mem:activiti;db_close_delay=1000" /> < Propertyname= "Jdbcdriver"value= "Org.h2.Driver" /> < Propertyname= "Jdbcusername"value= "sa" /> < Propertyname= "Jdbcpassword"value="" /> < Propertyname= "Databaseschemaupdate"value= "true" /> < Propertyname= "Jobexecutoractivate"value= "false" /> < Propertyname= "asyncexecutorenabled"value= "true" /> < Propertyname= "Asyncexecutoractivate"value= "false" /> < Propertyname= "Mailserverhost"value= "Mail.my-corp.com" /> < Propertyname= "Mailserverport"value= "5025" /> </Bean></Beans>
And we write a good configuration file, to Activiti loading in the following ways:
Processengineconfiguration.createprocessengineconfigurationfromresourcedefault (); Processengineconfiguration.createprocessengineconfigurationfromresource (String Resource); Processengineconfiguration.createprocessengineconfigurationfromresource (string resource, string beanname); Processengineconfiguration.createprocessengineconfigurationfrominputstream (InputStream InputStream); Processengineconfiguration.createprocessengineconfigurationfrominputstream (InputStream InputStream, String Beanname);
If you like 0 configuration, you can:
Processengineconfiguration.createstandaloneprocessengineconfiguration (); Processengineconfiguration.createstandaloneinmemprocessengineconfiguration ();
For example, the 0 configuration uses the second of these methods:
1 processengine processengine = Processengineconfiguration.createstandaloneinmemprocessengineconfiguration ()2 . Setdatabaseschemaupdate (processengineconfiguration.db_schema_update_false)3 . Setjdbcurl (" jdbc:h2:mem:my-own-db;db_close_delay=1000 ")4 . setasyncexecutorenabled (true )5 . Setasyncexecutoractivate (false)6 . Buildprocessengine ();
But I personally think that trivial configuration if all the code to maintain, too much bother! Besides, it's not safe to write to a programmer with a low level of code. So give it to the XML, 0 configuration except fresh useless.
1.1 activiti.cfg.xml文件配置
activiti.cfg.xml
必须包含id为processEngineConfiguration的bean节点,例如:
<id= "Processengineconfiguration" class= " Org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration ">
Processengineconfiguration are often used to constructProcessEngine,activiti提供了以下4个类来定义processEngineConfiguration
:
org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration: The process engine object is obtained independently, Activiti will manage the transaction itself, the general , the database is detected only when the system is started.
org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration: It is mainly used for testing. Activiti will manage its own transactions, using the H2 database by default, and the database tables will be destroyed when the startup is created and closed. So there is not much to configure.
org.activiti.spring.SpringProcessEngineConfiguration: It is used for integration with spring.
org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration: In standalone mode, it can be used with a distributed transaction. (I don't know)
1.1.1 Database Connection Configuration
The database connection currently has two configurations, one using the MyBatis default database connection configuration and the other is the mainstream database connection pool. I recommend the latter because the former official documentation has already said in production it is recommended that you do not use the default database connection settings.
The former is configured as follows: (Simple sweep)
< Propertyname= "Jdbcurl"value= "jdbc:h2:mem:activiti;db_close_delay=1000" />< Propertyname= "Jdbcdriver"value= "Org.h2.Driver" />< Propertyname= "Jdbcusername"value= "sa" />< Propertyname= "Jdbcpassword"value="" />
Second scenario: usingjavax.sql.DataSource,比如DBCP,C3P0,Druid等
<BeanID= "DataSource"class= "Org.apache.commons.dbcp.BasicDataSource" > < Propertyname= "Driverclassname"value= "Com.mysql.jdbc.Driver" /> < Propertyname= "url"value= "Jdbc:mysql://localhost:3306/activiti" /> < Propertyname= "username"value= "Activiti" /> < Propertyname= "Password"value= "Activiti" /> < Propertyname= "Defaultautocommit"value= "false" /></Bean><BeanID= "Processengineconfiguration"class= "Org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> < Propertyname= "DataSource"ref= "DataSource" /> ...
The Activiti workflow does not provide a jar package for the database connection pool, and we need to manually download it to the classpath.
Regardless of the database connection scenario, other configurations of some databases require attention:
DatabaseType: generally not required, the workflow will automatically analyze the data elements, only after the automatic analysis failed to read the configuration, currently supported by the database H2, MySQL, Oracle, Postgres, MSSQL, DB2.
databaseschemaupdate:
- False (default)---Check the workflow version of the workflow version and workflow jar package in the matching database when the process engine is created, and the mismatch will throw an exception.
- True---detects the workflow version of the workflow version and workflow jar package in the matching database when the workflow engine is created, without adding it and modifying it.
- Create-update: Add a workflow version when creating a workflow engine, and delete the workflow version when you close the engine.
1.1.2 Creating workflow-related tables
Under the Classpath, add the Activiti jar package, the database connection jar, the activiti.cfg.xml, and then run Dbschemacreate .
Often developers do not have administrator rights to the database in production, so SQL is provided to the relevant people in the jar of Activiti, which generally fall into three broad categories:
- Engine: This is required.
- Identity:activiti provides a table of user management features.
- History: Process Chronicle related tables
Running execute SQL on MySQL can be noted, if the version is in 5.5~5.6.3, use 5.5 version of SQL to execute, or upgrade the database 5.6.4+, because in 5.6.4 the following versions of MySQL timestamps or The date precision does not reach the millisecond level, and an exception is thrown when the workflow creates this type of column.
Introduction to 1.1.3 Workflow related tables
工作流相关的表全部是以“ACT_”开头的,后面紧接着的第二部分是activiti提供的service的简写, 比如:
act_re_*: RE stands for repository
. Contains process definitions, process resources, and so on.
act_ru_*: RU Representative runtime
. These tables contain process run instances, tasks, variables, assignment work, and so on, which only hold the running data and are purged after the execution of the process instance, so that the data in the table is relatively small, which makes the program execute quickly.
act_id_*: ID represents identity
. These tables contain user information data, such as user personal information, group information, and so on.
act_hi_*: HI stands for history
. These tables contain historical data such as past process instances, variables, tasks, and so on.
Act_ge_*: A universal data sheet that is used to store various data.
Activiti Workflow Learning-----Based on 5.19.0 version (1)