Sequence diagrams: async messages and callbacks
简介 / Introduction
Sequence diagrams visualize time-ordered interactions between objects. Synchronous (sync) messages block until a response arrives, while asynchronous (async) messages fire and forget — common in HTTP calls, event-driven systems, and microservice architectures. This article uses the same business scenario to compare PlantUML and Mermaid side by side.
PlantUML 版
1 | @startuml |
PlantUML uses -> for sync messages, --> (dashed) for returns, and activate/deactivate to manage lifelines. Async messages are plain -> arrows with no special keyword. Callbacks are explicitly modelled with dashed return arrows.
Mermaid 版
1 | sequenceDiagram |
Mermaid’s syntax is more compact: ->>+ enters an activation, -->>- leaves and returns in one step. A plain -> arrow without +/- is async — it neither pushes nor pops the activation stack. Callbacks use a dashed return arrow -->>.
对比 / Side-by-side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Sync message | -> |
->>+ (enters activation) |
| Async message | -> (no marker) |
-> |
| Return message | --> |
-->>- |
| Activation/Deactivation | activate / deactivate |
trailing + / - on arrow |
| Callback | --> (dashed return) |
-->> (dashed return) |
| Note/Comment | note over |
%% line comment |
小结 / Wrap-up
Both engines express async and callback semantics clearly. PlantUML is more verbose but more expressive, suitable for complex interactions; Mermaid is terse and ideal for embedded documentation and quick prototypes. Choose based on interaction complexity and team tooling preferences.
- Title: Sequence diagrams: async messages and callbacks
- Author: puml.online
- Created at : 2026-08-28 09:00:00
- Updated at : 2026-08-28 01:01:15
- Link: https://puml.online/blog/sequence-diagram-async-messages-en/
- License: This work is licensed under CC BY-NC-SA 4.0.