G
G
grabbee2017-04-23 18:16:43
symfony
grabbee, 2017-04-23 18:16:43

How to correctly connect simple microservices with shared data?

I'm trying to figure out how best.. Having simple data like Users, Contacts, Messages - divide them into three microservices
1. Users - list by ID plus data for each and search
2. Contacts - list of ID + interlocutor ID for each user, contact properties, filters
3. Messages - list of ID + ID of the interlocutor, message text, status, search
The contact list should contain information about the interlocutor from Users and preferably the beginning of the text of the message as a preview from Message
A in Messages information about the interlocutor ( Users ) and Contact status
---
How to properly interact with them? Duplicate data in Contactsas some information about the contact (name, age, city) and part of the message? Or make three requests for one list of contacts ...
The data is requested by the frontend via REST and the whole View is there

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-04-23
@Sanasol

to collect on the backend from three requests one or on the front, that's how much you like it.
That's the beauty of microservices.
You don't need to duplicate anything.
And of course, we must take into account what will happen if one of the services goes down.

A
AlexNomad, 2017-06-26
@AlexNomad

In my opinion, it is not entirely correct to single out the microservices "Users", "Contacts", "Messages". You are drawn to the OOP paradigm (entities, nouns). And microservices are about business tasks (verbs).
Compare:
Users, Contacts, Messages
and
Authorization, Messaging.
Accordingly, "Authorization" has its own database with a list of all logged in users and all (!) Tools (filters, searches, etc.) for working with them.
Similarly, "Messaging" has its own database with all messages and all (!) Tools for working and forwarding messages.
Above them there may (or may not be) a connecting microservice "Combine" (Gateway).
P.S. Think in verbs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question