Freely communicating microservices
To create stateful microservices, we need a factory. The factory itself is a microservice. When a request is made, an instance of the service is created, usually in the form of a target. The target is given the owner's target address when it is created. The owner is given the target address of the service in the same way. Now the owner and microservice can communicate with each other.
If the microservice is no longer needed, it is terminated by the owner with a message. If the microservice's communication with the owner is interrupted, there are several options, to terminate the instance automatically.
Often microservices need to send messages themselves to accomplish their tasks. Since they are targets themselves, this is not a problem.
Often, requests from the owner cannot be answered immediately, because even asynchronous communication must be taken care of beforehand. There are various tactics here. One is to defer the automatic response and pass it to a new target to complete a request.
Targets are lightweight, any number of targets can be created to handle complex communications. Example: The job engine easily creates tens of thousands of targets to perform specific activities, such as hashing files in subdirectories.
When its own queries are done, the working target sends the deferred message back as a response and exits. This pattern ( outsourcing communication to another target) is simple to understand and easy to implement.
Thus, many actions will require a session token to verify that a user has the rights to perform the intended action. A request is then made to the session manager to verify the token and rights. The session manager is a separate microservice, which in turn consults the user database.
Another example are dialogs in