Still getting to grips with EDA. Suppose in your system you have an Order Service, which first needs to check if the customer's account has enough credit from the Account Service. There are multiple ways of doing this:
- You could achieve this purely with Events over a bus:
Order Service (marks order as pending) --> OrderRequestedEvent --> Account Service --> CreditApprovedEvent --> Order Service (marks order as confirmed)
- You could also use a Command over a bus (request/response?):
Order Service --> ApproveCreditCommand --> Account Service --> ApproveCreditResult --> Order Service
- But could you not also just use an Api?
Order Service --> /account/123/credit --> Account Service --> HttpResponse --> Order Service (checks credit amount)
My question is, can you use all of these approaches in EDA, or must everything be only events or commands? Are some approaches more suitable than others?
If option 3 goes via an API gateway, I'm struggling to see why it would be any more coupled than the others. Yes it assumes there is definitely something somewhere which will respond to that GET, but then they all assume a follow up action (otherwise the order would sit unconfirmed forever).