Should a service making a request send all the information another service requires from the requesting service to complete the requested service's job? Or should the requesting service send as little information as possible when making a request and let requesting service decide what additional information to call back for? Or does it depend on the circumstances, like the volume of information needed?
If the requesting service is Venmo and the requested service is Bank of America and the request is to withdraw money from a customer's Bank of America account and send it to another bank account, should Venmo send all the details Bank of America needs to do the withdrawal? Or should Venmo send as little information as possible, for example just Venmo's identifier for the payment request and Bank of America can call back to request additional information about Venmo's payment request?
I'm reading Chris Richardson's advice on Microservices https://microservices.io/patterns/communication-style/messaging.html and he seems to imply that the service that initiates a request should send all the information the service that's responding to the request needs. I see the advantages of that: 1) only one message needs to be passed between the services, which reduces the chances of a failure occurring at some point in the communication, 2) Developers also have one object to look at to know everything about how the services communicate.
However, I've noticed disadvantages in practice: The requesting service may send information the requested service does not need. For example, let's say Venmo passes everything Bank of America needs. Now, Venmo wants to work with a bank in a country with high levels of money laundering. This bank needs not just the ordinary payment request but needs Venmo to send information verifying the identity of the people the payment request is for. Now Venmo has to either modify its standard payment request message to contain the identity verification information or banks that need the additional information need to request it. Now we are in a state where the requested service is requesting information from the requester and our communication flow is not as simple. Instead of having one request that contains most of the information from Venmo, Venmo could provide just an internally generated request id, expose a few APIs, and banks can use whichever APIs they need. It will require more messages between the services, but it takes the responsibility totally off of Venmo except for exposing its data to banks.
but it takes the responsibility totally off of Venmo except for exposing its data to banks.Hello, I'm the Bank's CTO and in no meaningful or reasonable scenario my bank is going to send requests to 3rd parties services to fulfil the contracts of my own service. It's me providing a service to you, not otherwise. Feel free to do so or look for another service provider (bank). Best regards!