I want to model an asynchronous request-response message exchange in UML.
The request is sent from a client to a server. The server responses asynchronously.
This can be modelled in a component model in two ways:
Request and response are two different interfaces with one method each. The server provides the request interface while the client provides the reponse interface. The interfaces are required vice versa. In UML I would model the server and the client as components having one port each. Both ports expose two interfaces: a provided one and a required one which are linked from client to server (request) and from server to client (response).
Request and response is one interface with one method. The response is simply the return value of this method. The server provides and the client requires this interface. The message exchange is modelled as link from the client to the server.
I think option (1) is more appropriated for asynchronous exchanges while option (2) is the preferred way for synchronous ones. However, making such a distinction would expose a detail in the component model which actually belongs to the behavioural diagrams.
- Is there any standard or "best practice" to model an asynchronous message exchange in component models?
- If option (2) is the "right" way to do it: how should one specifiy that the client must comply with an interface contract in order to receive a response?