Three Practical Tips for Simplifying Activiti Workflows
This article shares three practical techniques for streamlining Activiti BPMN processes—omitting exclusive gateways by moving conditions to outgoing sequence flows, using skip expressions to bypass unnecessary user tasks, and employing parallel gateways with task listeners to enable multi‑role approvals—complete with XML examples and diagrams.
In the context of a three‑party contract system that integrates with a workflow platform, the author explores several Activiti features to simplify complex process definitions.
Tip 1: Omit Exclusive Gateways – By attaching conditionExpression directly to the outgoing sequence flows of a user task, the exclusive (XOR) gateway can be removed, reducing diagram length and improving page rendering. The article shows the original diagram, explains the decision logic of exclusive gateways, and provides the simplified XML where flow3 and flow4 both carry conditions.
Tip 2: Simple Skip of User Tasks – The activiti:skipExpression attribute allows a task to be bypassed when a Boolean expression evaluates to true. When the expression ${execution.getVariable('hasManager')==false} is true, the “商圈经理” task is not created, and the flow proceeds directly to the next task. The article includes the original and simplified diagrams and the corresponding XML snippet.
Tip 3: Multi‑Role User Tasks Using Parallel Gateways and Listeners – When a task can be approved by either a manager or a director, the solution uses a parallel gateway to split the flow into two parallel paths, each leading to a separate user task. Task listeners set local variables and automatically complete the counterpart task when one path finishes, preventing the process from stalling. The full BPMN XML with activiti:taskListener configurations and the parallel‑gateway structure is provided.
All three techniques aim to keep the process model concise while preserving business logic, and the article supplies ready‑to‑use XML fragments for each case.
Beike Product & Technology
As Beike's official product and technology account, we are committed to building a platform for sharing Beike's product and technology insights, targeting internet/O2O developers and product professionals. We share high-quality original articles, tech salon events, and recruitment information weekly. Welcome to follow us.
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.