0

hello everyone i'm new to microservice's architecture , so i have a miscroservice which every entity is linked to the 'user' entity , but the problem is that the 'user' entity is in another microservice , is there any solution ?

  1. I don't know where to user the @onetomany relation if i don't have the two entities in the same microservice)
  2. i can't combine the two microservices together.

what about domain model layer ? is it the best solution to user another microservice's data ?

thanks in advance.

spencergibb
  • 24,471
  • 6
  • 69
  • 75
Chaouss
  • 15
  • 1
  • 7

2 Answers2

0

Cant you pass it as a secure jwt token which contains users data so its accessible in other micro service? Another approach is store it as a thread local object.

MathGuy
  • 183
  • 4
  • 12
0

First answering your questions

1 - I don't know where to user the @onetomany relation if i don't have the two entities in the same microservice)

2 - i can't combine the two microservices together.

--> you can combine 2 services into one (provided considering the load of service)

If the load on your service is big - then

You can utilize something like shared database service for multiple microservices

Go through this blog - it talks about few patterns you can utilize.

http://microservices.io/patterns/data/database-per-service.html.

Also go through this question, it will give you some more undersntading

Microservices: how to handle foreign key relationships

Ashish Shetkar
  • 1,414
  • 2
  • 18
  • 35