0

We've two domains: Departments and Employees.

Both of them are microservices and we're using an event bus (kafka) to populate events.

As usual, department can have several employees.

Currently, we've implemented "Deleted Deployment" use case.

Which's the best way to check if a department has X employees before remove it?

Note: we want to avoid to make a synchonous call between microservices.

Jordi
  • 20,868
  • 39
  • 149
  • 333

1 Answers1

1

If you don't want to do a synchronous call, you need to already have that data in the microservice doing the check.

So, if you have an event in the other microservice that tells you when an employee is created for that department you can listen to it and create a counter of employees. Also, if there are any other events that can change the department of an employee you have to listen also to them in order to get the count "eventually in sync"

rascio
  • 8,968
  • 19
  • 68
  • 108