Backend Development 38 min read

Comprehensive Guide to Activiti 7 Workflow Engine: Concepts, Configuration, Deployment, and Usage

This article provides a detailed tutorial on Activiti 7 workflow engine, covering workflow fundamentals, BPMN modeling, environment setup, Maven dependencies, configuration files, process deployment, instance creation, task querying and completion, process definition management, resource extraction, and historical data inspection, all illustrated with Java code examples.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Comprehensive Guide to Activiti 7 Workflow Engine: Concepts, Configuration, Deployment, and Usage

The article begins with an overview of workflow concepts, explaining how workflows automate business processes across various industries and describing typical use cases such as order processing, administrative approvals, and human resources management.

It then introduces Activiti 7, an open‑source BPMN 2.0 workflow engine, outlining its history, core components, and the BPMN standard used for process modeling.

Next, the guide details the development environment requirements (JDK 1.8+, MySQL, Tomcat, IDEA) and shows how to install the Activiti Designer plugin in IntelliJ IDEA.

Configuration files are explained, including activiti.cfg.xml for standalone engine setup and activity-spring.cfg.xml for Spring integration, with examples of datasource and transaction manager beans.

<beans xmlns="http://www.springframework.org/schema/beans" ...>
  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <property name="jdbcDriver" value="com.mysql.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql:///activiti"/>
    <property name="jdbcUsername" value="root"/>
    <property name="jdbcPassword" value="123456"/>
    <property name="databaseSchemaUpdate" value="true"/>
  </bean>
</beans>

Deployment of a process is demonstrated using the RepositoryService, either by adding individual .bpmn and .png resources or by deploying a ZIP archive.

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
Deployment deployment = repositoryService.createDeployment()
    .addClasspathResource("bpmn/evection.bpmn")
    .addClasspathResource("bpmn/evection.png")
    .name("出差申请流程")
    .deploy();

Starting a process instance is shown with RuntimeService, and task handling (querying personal tasks, completing them) is illustrated using TaskService.

RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance pi = runtimeService.startProcessInstanceByKey("myEvection");
TaskService taskService = processEngine.getTaskService();
Task task = taskService.createTaskQuery()
    .processDefinitionKey("myEvection")
    .taskAssignee("zhangsan")
    .singleResult();
taskService.complete(task.getId());

The guide also covers querying process definitions, deleting deployments (with optional cascade), downloading deployed resources (BPMN and PNG files) via RepositoryService, and inspecting historical data using HistoryService.

HistoryService historyService = processEngine.getHistoryService();
List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery()
    .processDefinitionId("myEvection:1:4")
    .orderByHistoricActivityInstanceStartTime().asc()
    .list();

Finally, the article summarizes the covered features and points readers to additional resources for advanced topics such as process suspension, activation, and variables.

JavaworkflowDeploymentBPMNSpringActivitiProcessEngine
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.