Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to improve communication between microservices [closed]

In our company we use spring boot, microservices, spring cloud and so on... We are happy with this infrastructure, but I still have some concerns: we use rest as comunication protocoll and even if a I find it great, I still think that we could find something better. With rest:

  • you need to use a client and a server (restcontroller)
  • you need to know the server URI, the http method (POST, GET, PUT,...)
  • you need know where params go (body, querystring)
  • ....

Don't you think It would be much easier if we had something like RMI? I know it's a quite old technology(and it's not language independent), but it made life easier (you just need an interface and its implementation).

Searching around, I found some interesting projects like feign clients or spring cloud stream, but none of them seem to be the silver bullet.

What do you think about this topic? Is that a problem that you feel? If so, how do you approach it?

Thanks in advance.

like image 635
Pirulino Avatar asked Mar 24 '16 10:03

Pirulino


People also ask

What is the best way to communicate between microservices?

The two commonly used protocols are HTTP request/response with resource APIs (when querying most of all), and lightweight asynchronous messaging when communicating updates across multiple microservices. These are explained in more detail in the following sections.

How do you make asynchronous microservices?

Using an asynchronous, microservice architecture. For most applications, the way to make microservices work and to manage distributed data successfully is to use sagas and CQRS views. In such an architecture, services communicate asynchronously using domain events, and command/reply messages.


3 Answers

In my company, we use JMS to add a "intern" communication stack to our microservice stack. It is reliable, simple to use, efficient and very performant.

We use Apache ActiveMQ as implementation, but RabbitMQ is also widely used.

like image 185
Alexandre Cartapanis Avatar answered Sep 30 '22 19:09

Alexandre Cartapanis


Microservices are not meant to be tightly coupled , RMI requires your code on both end , which was fun when you didnt control the other side eg clients who do not want to upgrade and it was a B!@*! to get through firewalls.

Soap solved most of those things you mention unfortunately Java never had a good Soap stack. That said Rest has other advantages especially when accessing the service from a web page and javascript.

like image 27
user1496062 Avatar answered Sep 30 '22 19:09

user1496062


You can use Spring Cloud Netflix and Eureka as Service Discovery and Client-Side Load Balancing with Ribbon.

With the help of those you can communicate between microservice by 'service names' instead of service locations.

Check out this demo. It should be VERY USEFULL for undestanding microservices communications.

Here we have 2 simple microservices and Discovery Service for communications between them.

like image 28
svichkar Avatar answered Sep 30 '22 20:09

svichkar