Skip to content

MicroService Messaging Patterns Overview

Wim van Gool edited this page Jul 25, 2019 · 1 revision

On the previous pages, we discussed several common messaging patterns that can be used to send and receive Commands, Queries and Events. In this page, we aim to provide a quick overview of how services communicate using these messages and what common best practices are related to these patterns.

Intra- versus Inter-Service Communication

While discussing all common messaging patterns, you must have noticed that communication between components can be divided into communication that takes place inside a single service (_intra_service communication) and communication between different services (_inter_service communication).

Since run-time independence of services is an important principle in modern Service-Oriented Systems, it is strongly advised that every single connection between services is implemented using an asynchronous messaging pattern (i.e. using queues in between). Synchronous communication between services is allowed, but should only be used if asynchronous communication is not a viable solution.

For _intra_service communication, however, synchronous communication is much more common, especially between the front-end and back-end components of a service. A notable exception are Events that are published and then handled by the same service, because they are always asynchronously processed, and Commands that are sent to itself.

Service Communication Overview

Another thing we mentioned was that it is discouraged to let front-ends of one service speak directly to the back-end of another service, especially not a synchronous fashion. Although it is technically not forbidden, a better approach would be to create a shared client in one service and then include that component in the client of the other service.

Message Properties

Commands, Queries and Events all have their own specific properties and traits in the way they are send, received and processed. As you may have figured out already, they actually perfectly balance each other out on these properties. The following diagram shows each message type within a triangular shape, where each message type carries properties that perfectly oppose the properties of the types that share the opposing axis, providing a nice overview of these properties:

Message Properties

Next up: MicroService Roles & Types >>

Clone this wiki locally