Direct messaging
In direct messaging, each request is sent directly to the microservice on its API endpoint. Such requests may be initiated by users, applications, or by other microservices that integrate with the target microservice to complete a particular task. Mostly the endpoints to handle such requests are implemented using REST (https://en.wikipedia.org/wiki/Representational_state_transfer), which allows resource identifiers to be addressed directly via HTTP based APIs with a simple messaging style.
For example, in a typical microservices-based e-commerce application, an administrative user may wish to create, update, or manage users via the User Service's REST endpoint. In that case, the user can directly call the REST API of the User Service, as shown in the following diagram:
Similarly, a mobile application may want to query user interests via Interest Service's REST endpoint of the e-commerce application. Since the Interest Service depends on both the User Service and the Orders Service, it may further initiate two separate calls to the REST endpoint of these two services to get the desired response which it can merge with the user interests data and generate the response for the requesting application. Mostly, all these kinds of request-response are synchronous in nature as the sender expects a response with the results in the same call. Asynchronous requests are mostly used to send alerts or messages to record an operation, and in those cases, the sender doesn't wait for the response and expects the action to be taken eventually.
Message formats used with REST endpoints are mostly text-based message formats such as JSON, XML, or HTML, as supported by the endpoint implementation. Binary message formats such as Thrift (https://en.wikipedia.org/wiki/Apache_Thrift), ProtoBuf (https://en.wikipedia.org/wiki/Protocol_Buffers), and Avro (https://avro.apache.org/) are also popular due to their wide support across multiple programming languages.