I am experimenting with moving some parts of the monolith to external services. I like this idea so far, and it seems cleaner to encapsulate all related functions within a single application. Various applications use RabbitMQ for communication.
I have a user object in one service. If I want to use this exact class in a service, I can easily serialize it and send the serialized object to the message body. But since both the sender and the receiver must contain the user class, I would have to share a library containing some representation of the user object (although it seems strange to put the real user object in the library, since it is the main one for the main application). I think I could just pass in an array with the key userand certain key values.
I also think that if I ever create a service in something other than PHP, then it will not be able to perform arithmetic on the user object and, therefore, will not have access to the data in the message.
Thus, I like the idea of transferring objects between services and the ability to use them as objects in the receiving part, but I'm not sure if this is the right approach.
My question is, what is the best way to transfer objects between these services?
source
share