Plantuml sequence diagram lifeline for async execution

12k views Asked by At

Here is my sample shown also on picture below

@startuml
participant "Client" as C
participant "Server" as S
participant "Third Party" as 3PT

C -> S++: request money
S -> S: do I know you?
S -> 3PT++: give me money for client
return here you have money
S ->> S++ #005500: compute usage
S ->> 3PT: notify about computation details
deactivate S
return money
@enduml

plantuml image

Is it possible in PlantUml sequence diagram somehow define the lifeline for async operation to end after lifeline from which it was started? So in this case I'd like to finish the compute usage in green lifeline after return from request money lifeline. By that I would say that compute usage is asynchronous operation and can end at any time. Don't know whether this is valid from UML point of view though.

1

There are 1 answers

5
bruno On

As I know there is no way for a reflexive message like S ->> S++:... or S ->> S:... to start from an OccurrenceSpecification and finish to an other (and that for a lot of tools, including mine), so the only way seems to represent the Server two times. To clearly indicate it is the same server you can indicate the name the instance, for instance (naming all instances):

@startuml
participant "c:Client" as C
participant "s:Server" as S
participant "tp:Third Party" as 3PT
participant "s:Server" as Sagain

C -> S++: request money
S -> S: do I know you?
S -> 3PT++: give me money for client
return here you have money
S ->> Sagain++: compute usage
C <-- S--: money
Sagain-- ->> 3PT: notify about computation details
@enduml

enter image description here

The norm says §17.12.17.1 lifelines represent only one interacting entity, but an entity can be presented by several lifelines :

represents : ConnectableElement [0..1] (opposite A_represents_lifeline::lifeline) References the ConnectableElement within the classifier that contains the enclosing interaction

lifeline : Lifeline [0..*] (opposite Lifeline::represents)

(notice the multiplicity 0..*)


Out of your problem it is strange to see the message do I know you? alone without consequences depending on the result, PlantUML manages combined fragment alt to indicate alternatives