How to use UML to model interaction between server

2019-09-11 12:19发布

问题:

Scenario:

  1. The agent listens to a certain address/port during start up.
  2. When server started, server will send message to agent via the address (multicast). Agent will reply the server.

How to model the first statement using UML (sequence diagram/activity/statemachine) ?

回答1:

I guess any of these types of diagrams could model the interaction, but I would go with a sequence or a communication diagram for these reasons:

  • there is a mix of asynchronous (the server's message) and synchronous (the agent's response) messages;
  • we aren't modelling state changes either in the server or in the agent.

This would be my take on a sequence diagram for the interaction (could possibly include more agents/port listeners to show the multicast):

And on a communication diagram (Agent 0 and Agent 1 could just be called Port Listener 0 and Port Listener 1):

Statement (1), which I take to be the agent listening to the address or port, is shown as a self-call in both cases.

Here are a couple of amusing articles on sequence diagrams:

  • Introduction to UML 2.0 Sequence Diagrams
  • Messages in UML 2.0 Sequence Diagrams.


标签: uml