Comprehensive Guide to Activiti 7 Workflow Engine: Concepts, Environment Setup, Deployment, and Usage
This article provides a detailed tutorial on the Activiti 7 workflow engine, covering workflow concepts, BPMN modeling, environment configuration, Maven dependencies, database schema creation, deployment methods, process instance management, task handling, and historical data querying, with complete code examples for Java developers.
This tutorial introduces workflow fundamentals and explains how Activiti, an open‑source BPM engine, manages business processes using BPMN 2.0 definitions.
1. Workflow Introduction
Defines workflow, its system components, applicable industries, and typical use cases such as order processing, administrative approvals, HR management, finance, and customer service.
2. Activiti 7 Overview
Describes Activiti’s history, its use of BPMN 2.0 for process modeling, and provides the official website and latest version (7.0.0.Beta).
Key BPMN concepts (Event, Activity, Gateway, Flow) are illustrated with XML examples.
3. Environment Setup
Lists required tools (JDK 1.8+, MySQL, Tomcat 8.5, IDEA) and shows how to install the Activiti Designer plugin in IDEA.
Provides Maven dependency snippets for Activiti core, Spring integration, BPMN model, converters, and database drivers.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-dependencies</artifactId>
<version>7.0.0.Beta1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
...
</dependencies>
</dependencyManagement>Shows how to configure activiti.cfg.xml with a processEngineConfiguration bean, JDBC settings, and databaseSchemaUpdate set to "true".
4. Process Deployment
Demonstrates single‑file and ZIP‑based deployment using the RepositoryService API.
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
RepositoryService repo = engine.getRepositoryService();
Deployment deployment = repo.createDeployment()
.addClasspathResource("bpmn/evection.bpmn")
.addClasspathResource("bpmn/evection.png")
.name("Leave Request Process")
.deploy();Explains related database tables (ACT_RE_DEPLOYMENT, ACT_RE_PROCDEF, ACT_GE_BYTEARRAY) and their relationships.
5. Process Instance Management
Shows how to start a process instance by key, query tasks for a specific assignee, complete tasks, and retrieve process definition details.
RuntimeService runtime = engine.getRuntimeService();
ProcessInstance pi = runtime.startProcessInstanceByKey("myEvection");
TaskService taskService = engine.getTaskService();
Task task = taskService.createTaskQuery()
.processDefinitionKey("myEvection")
.taskAssignee("zhangsan")
.singleResult();
taskService.complete(task.getId());6. History and Resource Retrieval
Uses HistoryService to query historic activity instances and demonstrates downloading the original BPMN and PNG resources from the database via RepositoryService.
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
.processDefinitionId("myEvection:1:4")
.orderByHistoricActivityInstanceStartTime().asc();
List<HistoricActivityInstance> list = query.list();
// iterate and print detailsProvides code for extracting resources using IOUtils.copy to write the streams to local files.
7. Cleanup
Shows how to delete deployments, with optional cascade deletion to remove running instances.
repositoryService.deleteDeployment(deploymentId, true); // cascade deleteThe article concludes with references to further advanced topics such as process suspension, activation, and variables.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.