Sequence diagrams: lifeline control

Sequence diagrams: lifeline control

puml.online

简介 / Introduction

In sequence diagrams, a participant’s lifeline becomes active at different stages and can be destroyed when its role ends. Both PlantUML and Mermaid provide clean syntax to express these semantics — this article demonstrates the same scenario in both engines.

PlantUML 版

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@startuml
participant Client
participant "Order Service" as Order
participant "Payment Service" as Pay

Client -> Order: Place order
activate Order
Order -> Pay: Check balance
activate Pay
Pay --> Order: Balance OK
deactivate Pay
Order -> Order: Create order
destroy Order
Client <-- Order: Order placed
@enduml

PlantUML uses activate to activate a lifeline, deactivate to release activation, and destroy to terminate it with an × marker. Nested activations can be expressed with color blocks or nested activate blocks.

Mermaid 版

1
2
3
4
5
6
7
8
9
10
11
sequenceDiagram
participant Client
participant Order as "Order Service"
participant Pay as "Payment Service"

Client->>+Order: Place order
Order->>+Pay: Check balance
Pay-->>-Order: Balance OK
Order->>+Order: Create order
Order-->>-Client: Order placed
destroy Order

Mermaid uses the + prefix on an arrow to activate a lifeline and - to release it. The destroy keyword also terminates a lifeline with ×. Color-based activation via activate(name) / deactivate(name) requires plugins; the core syntax relies on +/- arrow modifiers.

对比 / Side-by-side

Feature PlantUML Mermaid
Activate lifeline activate <name> + prefix or activate(name)
Release activation deactivate <name> - prefix or deactivate(name)
Destroy lifeline destroy <name> destroy <name>
Nested activation color blocks or nested activate +/- nesting levels
Syntax style imperative keywords arrow modifiers

小结 / Wrap-up

Both engines share the same conceptual model: activate with +/activate, release with -/deactivate, and destroy with destroy. PlantUML offers richer visuals (color blocks, nested levels) while Mermaid’s +/- prefix notation is more compact. Choose based on your team’s toolchain and diagram complexity.

  • Title: Sequence diagrams: lifeline control
  • Author: puml.online
  • Created at : 2026-08-31 09:00:00
  • Updated at : 2026-08-31 01:06:44
  • Link: https://puml.online/blog/sequence-diagram-lifeline-control-en/
  • License: This work is licensed under CC BY-NC-SA 4.0.