M
M
Matvey Safronov2016-07-27 20:37:08
RabbitMQ
Matvey Safronov, 2016-07-27 20:37:08

How to correctly design the format of messages between microservices?

I practice in the development of projects on microservices. All of them are written in nodejs, each has its own API. They do not know anything about each other, they all have the same implementation of the AMQP protocol, they are connected to the RabbitMQ server. It is assumed that they can exchange information through only this protocol. In the system as a whole, there are several entities that, one way or another, are partially present on several microservices at once (users, monetary system, some other business logic). Each microservice is subscribed to the entity of interest to it, to exchange with the name of the entity, for example. "user". It sends / receives messages there, for example, the password has changed in the account microservice - it sends this information to the appropriate channel, the authorization microservice thinks that this information is interesting to it, and changes the user's password on its side. Question: what should be the format of these messages, structure, data? By what principle do they create communications between microservices using RabbitMQ, where can I read examples (I couldn’t find it anywhere)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim Stepanov, 2016-07-28
@impeee

Judging by your post, you've done the preparatory work (i.e. microservices listen to specific queues in RabbitMQ).
As for the data format - send messages to the queue in JSON format. There are parsers for it for any language. But what exactly to send - so it already depends on what this or that microservice does. Each should have a described and documented data format, a set of fields, etc. And already another microservice (for example, authorization), which is subscribed to events from the accounts microservice, must understand where it received the data from and process it correctly.

D
Dimonchik, 2016-07-27
@dimonchik2013

Duc on the rabbit is full of examples
https://www.rabbitmq.com/getstarted.html
for transactions - https://www.rabbitmq.com/confirms.html

I
Iron Bug, 2016-07-28
@rare

I gave you an example. Look here .
Might be useful.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question