I have a question that has more to do with microservices than with Kotlin but I think here are the experts.
I have my Profile/User - Service (A): there profiles are created and root information is stored e.g.: .
I publish these to my message broker and consumed it in an another service (B). Now the service (B) only needs
{name: String, type: String}
. Should I still share the full model of
User
as interface between the services or are these other types of
User
models?
š¶ 1
Christian
08/07/2021, 9:45 AM
in my opinion these are two different models, one
AUserModel
and
BUserMode
c
cdpjenkins
08/07/2021, 12:43 PM
What event is causing Service A to emit this event? Profile/user creation?
c
Christian
08/07/2021, 12:48 PM
any mutation on the profile
c
cdpjenkins
08/07/2021, 12:48 PM
The approach that Iāve taken in the past is to emit events that describe the domain objects affected and the event that happened, from the perspective of the sending service. So Iād be inclined to ask āhow much information about a user does Service A want to expose to the rest of the system?ā instead of asking what precise fields Service B needs for one particular use case.
c
Christian
08/07/2021, 1:40 PM
service b needs as said only a small part, at the moment itās about 3/10 fields. i send the full profile as a message, because a other service needs also other parts of the model, but in service b i translated only a part of it. š
c
cdpjenkins
08/07/2021, 4:14 PM
What youāve done sounds good to me then.
Incidentally, most of what my opinions about how to do microservices comes from the book Microservices Patterns by Chris Richardson. Itās a looong book but it held my attention from start to finish and Iād recommend it if you havenāt already read it. Two of the patterns in that book that are particularly relevant here (and which are probably the source of my opinions on this stuff) are summarised on Mr Richardsonās website:
⢠https://microservices.io/patterns/data/domain-event.html
⢠https://microservices.io/patterns/data/event-sourcing.html
(Thereās waaaay more detail in the book.)