I'm developing a website with the microservice architecture, and each of the service owns a database. The database stores the data which the microservice needs.
Post
, Video
services need the user information, so both of the services subscribed to the NEW_USER_EVENT
.
The NEW_USER_EVENT
will be triggered when there's a new user registered.
Once the services received the NEW_USER_EVENT
, they put the incoming user information to each of their own database. So they can do things without asking the User
service.
So far so good. But here comes the question:
- What if I'm going to create a new service? How do I get the registered user informations and put them in the new service?
Maybe I can get the informations from the existing services. But the events are pushed by the messaging queue (NSQ
).
If I'm going to copy the data from one of the microservices, how do I make sure which service has the latest user informations? (Because some services haven't received the latest event)
Read More:
The Hardest Part About Microservices: Your Data
Intro to Microservices, Part 4: Dependencies and Data Sharing