Sequence diagrams: self-call messages

Sequence diagrams: self-call messages

puml.online

简介 / Introduction

When an object calls one of its own methods while handling a request, the sequence diagram shows a message going from a lifeline back to itself — a “self message”. Both engines support this, but they place the loop slightly differently: PlantUML draws the loop on the right side of the lifeline, Mermaid draws it on the left. This article compares the two notations with the same retry scenario.

PlantUML 版

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

Client -> Order: Submit order
activate Order
Order -> Retry: Get retry policy
Retry --> Order: Up to 3 retries
Order -> Order: retryOrder()
Order -> Order: Refresh local cache
deactivate Order
Client <-- Order: Order placed
@enduml

In PlantUML, pointing both ends of an arrow at the same participant creates a self message: Order -> Order: message. The loop is drawn on the right of the lifeline by default, and multiple self calls on the same participant stack to the right one after another.

Mermaid 版

1
2
3
4
5
6
7
8
9
10
11
12
13
sequenceDiagram
participant Client
participant Order as "Order Service"
participant Retry as "Retry Policy"

Client->>Order: Submit order
activate Order
Order->>Retry: Get retry policy
Retry-->>Order: Up to 3 retries
Order->>Order: retryOrder()
Order->>Order: Refresh local cache
deactivate Order
Order-->>Client: Order placed

In Mermaid, point an arrow (->> for solid or -->> for dashed) at the participant itself, e.g. Order->>Order: retryOrder(). Mermaid draws the self-call loop on the left of the lifeline; switching between solid and dashed is just a matter of changing the arrow symbol.

对比 / Side-by-side

Feature PlantUML Mermaid
Self-call syntax Order -> Order: message Order->>Order: message
Loop side right of the lifeline left of the lifeline
Arrow variants -> solid, --> dashed ->> solid, -->> dashed
Multiple self calls stack to the right stack to the left
Activation state pair with activate / deactivate pair with activate / deactivate

小结 / Wrap-up

Self messages are nearly identical in the two engines: point the arrow at the same participant on both ends. The real differences are the dashed-arrow symbol (PlantUML uses -->, Mermaid uses -->>) and which side of the lifeline the loop appears on. Wrapping self calls in activate / deactivate makes it clear that the object re-enters its own logic while it is still busy.

  • Title: Sequence diagrams: self-call messages
  • Author: puml.online
  • Created at : 2026-11-25 01:00:00
  • Updated at : 2026-11-26 01:07:01
  • Link: https://puml.online/blog/sequence-diagram-self-message-en/
  • License: This work is licensed under CC BY-NC-SA 4.0.