Reputation: 1321
I'm creating an application with Node.js using microservices architecture. I'm trying to find the best way of communication between nodes. I have a Java background so the best option I can imagine is something like SOAP, where you create a proxy object and by calling it's method a request to a remote node would be made via http.
Currently I only see an option of direct calls like
http.get("remote-node/api/method1", function(res) {
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
However I don't think it's convenient. Are there better approaches?
Thanks.
Upvotes: 3
Views: 4434
Reputation: 56
The most common and simple approach is to communicate between your microservices using a REST-ish approach. You will have to manually do the communication and the discovery of services, which can become messy as the system grows. You can also search for some packages on npm for service discovery and remote procedure calls.
I encourage the usage of Studio which is a microservices framework. It also has a plugin to do automatic clusterization (service discovery + rpc) with minimal configuration. This plugin also uses websockets for communication, which are more lightweight then REST-ish approach
Upvotes: 2