samedi 4 juin 2022

Why are people using a message Bus in their code - when to message vs call code

When building an application before scaling to multiple micro services. You have a codebase consisting of services that are decoupled. IE a services no longer depends on another service, not even loosely via a interface. It receives input from a service via a message buss. It has a method receivePaymentRequest but its callee is not the Order service. Its invoked via the message bus, perhaps in the future on another server. But imagine theres no need to run multiple servers at this point.

  1. a order services posts to the message bus payment-request event
  2. the payment services picks up on this message
  3. payment is completed
  4. payment service send a payment-complete event message to the message bus
  5. the order service picks up this message

I"m not thinking about the patterns that enable this to be fault tolerant. But instead when to use this approach since it adds a lot of complexity. So please ignore what i've left out with regards to this

Correct? Is it stupid to implement it like such before scaling to microservices. How does this. Is SOA the step before actual microservices?

When should a class receive/publish on the message buss and when should it depend on a service as a class (even injected via a interface) ?

Aucun commentaire:

Enregistrer un commentaire