Common communication mechanismsin microservices

Communication as well as the overall microservices architecture is supposed to be simplified. Though we have not proposed the mechanism that we will use, it can be either synchronous or asynchronous. We can say for our architecture that all the communication between the user interface services and system interface services will be synchronous over HTTP, and all the communication between system services interfaces will be asynchronous using a message broker.

Synchronous communication

For synchronous communication, the preferred communication mode is by using REST APIs with JSON-based objects over the HTTP protocols. When we talk about synchronous communication with HTTP with scale, it always flows through an API gateway, which acts here more like a proxy though it has its full-feature set as we covered in the previous section. The API gateway enables our services to be location transparent, load balanced, and simply allows them to scale silently without affecting the consumer of the services.

Asynchronous communication

When asynchronous communication is required, it mostly flows through a centralized component called a message bus or a message broker, which provides us at least with message queues. With message queues, the communication pattern is more like a consumer/producer scenario (and less like request/response, which is preferred as a synchronous pattern), where the consumer and producers could be one or many. The only thing that the services consumers need to know is the service queue name, where they could put their message, and they receive an answer asynchronously on the response queue which was provided as part of the metadata of the request message.

For asynchronous messaging, your message bus can be a PaaS like Azure Service Bus or Amazon SQS (Simple Queue Service), or it can reside in a bare metal server, a VM, or as a separate container. Examples of those include TIBCO EMS, Rabbit MQ, IBM WebSphere MQ, IronMQ, Apache Active MQ, Apache Kafka, and more.

There is a bit different and lightweight performance-oriented messaging engine called ZeroMq. ZeroMQ is an asynchronous messaging library specialized for concurrent applications. It provides a message queue, but unlike message-oriented middleware (MOM), a ZeroMQ-based system can work without a dedicated message broker.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.43.36