Search code examples
javascriptnode.jsredismicroservices

NodeJS Microservices, combining data


I'm building a NodeJS platform that consist of several core 'parts' (users, messages and trading signals).

So my idea is to create microservices for each of them, and it works pretty well.. But I can't get my head around how to 'join' data between the microservices (I'm a frontender originally.....)

For example, I have 3 microservices.. Each with its own MongoDB, on its own machine complete isolated.. Imagine the common situation where the messages is retrieved from a single microservice, the message has a 'user_id' and I need to get the username and profilePicture to be combined in the retrieved message object..?

I read a lot about using Redis, but it seems like a 'messaging' service to me, not much of a 'combine' service.. Can anyone help me through the darkness??

Thanks!!

enter image description here

I know its a very general question... But I just can't get a grip of what the 'best practice' is when combining data of multiple micro services..


Solution

  • I believe this can be done using kafka streams, it is a pub/sub model where you can join streams based on a common key. You can either subscribe to a topic or add a data transformation service which joins multiple streams and pushes the joined/transformed data into a new stream. All services who wants to use this data can subscribe to this new stream. I recommend you go through this link