G
G
Gennady Kruglov2021-09-18 14:06:14
.NET
Gennady Kruglov, 2021-09-18 14:06:14

What are the best practices for updating models through a message broker?

Recently, I began to study the microservice approach to creating distributed systems, the RabbitMQ broker and the MassTransit library for higher-level interaction with the bus from under .NET Core.
Reading a lot of articles on the Internet, I often come across that in the messages that microservices communicate with each other, they often put the DTO of the entity to which a certain event is related.
For example, when changing the amount in the client's account, the AcoountChanged message will be published inside which there will be an AccountDTO with an actual data slice of the required model. Well, in other services, where necessary, a Consumer consuming type AcoountChanged will be registered. Accordingly, on the consumer side, I will simply take the data from AccountDTO and replace it with those that are in his database. BUT (actually getting to the point) if for some reason I have two microservices that change information about the client's account, and both of these microservices periodically publish a message like AcoountChanged, however, the first of them can completely fill the AcoountDTO, and the second does not have a complete set of data about the client's account, and let's say in some fields it just leaves NULL, then on the consumer side we cannot understand - this NULL means
Yes, it would be possible, of course, to introduce a distinction for such situations, for example, by namespaces, and for each microservice to make its own AcoountChanged message type in order to process them in some special way on the consumer side, but in my opinion this contradicts the postulate of that each microservice does not need to know anything about the others.
I hope I did not describe the essence of the issue that I am now thinking about very chaotically, namely, how best to organize and handle such situations.
Thanks in advance and sorry for the multibooks.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question